From 185bd2ec3f7008c7641f40537887bfc9ef4b55bd Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 21 Sep 2023 21:43:57 +0000 Subject: [PATCH 01/92] Transform error messages --- package.json | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 4b790bc..3bbb2a9 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,9 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": {}, + "dependencies": { + "@stdlib/error-tools-fmtprodmsg": "^0.0.2" + }, "devDependencies": { "@stdlib/assert-is-string": "^0.0.8", "@stdlib/bench": "^0.0.12", @@ -79,4 +81,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 62161fadfe4a2c647ad22abefe0baf2ff96fa742 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 21 Sep 2023 21:47:00 +0000 Subject: [PATCH 02/92] Auto-generated commit --- .editorconfig | 186 - .eslintrc.js | 1 - .gitattributes | 49 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 62 - .github/workflows/cancel.yml | 56 - .github/workflows/close_pull_requests.yml | 44 - .github/workflows/examples.yml | 62 - .github/workflows/npm_downloads.yml | 108 - .github/workflows/productionize.yml | 783 --- .github/workflows/publish.yml | 242 - .github/workflows/test.yml | 97 - .github/workflows/test_bundles.yml | 180 - .github/workflows/test_coverage.yml | 123 - .github/workflows/test_install.yml | 83 - .gitignore | 188 - .npmignore | 227 - .npmrc | 28 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 52 +- benchmark/benchmark.js | 56 - branches.md | 53 - browser.js | 3 + browser.js.map | 1 + dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 29 - docs/types/index.d.ts | 53 - docs/types/test.ts | 57 - examples/index.js | 33 - index.js | 3 + index.js.map | 1 + lib/index.js | 43 - lib/main.js | 94 - package.json | 53 +- stats_browser.html | 6177 +++++++++++++++++++++ stats_node.html | 6177 +++++++++++++++++++++ test/test.js | 108 - 43 files changed, 12399 insertions(+), 3710 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md create mode 100644 browser.js create mode 100644 browser.js.map 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/index.d.ts delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js create mode 100644 index.js create mode 100644 index.js.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats_browser.html create mode 100644 stats_node.html delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 13e9c39..0000000 --- a/.editorconfig +++ /dev/null @@ -1,186 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 52cd9c4..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/base/remove-last-code-point) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 cc028ca..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/base/remove-last-code-point) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 fcbf6f1..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: '29 5 * * 0' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - uses: actions/upload-artifact@v3 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - uses: distributhor/workflow-webhook@v3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 91f2b93..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,783 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - uses: actions/checkout@v3 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - uses: actions/checkout@v3 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - uses: act10ns/slack@v2 - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n +``` + +If no recognized module system is present, access bundle contents via the global scope: + +```html + ``` #### removeLastCodePoint( str, n ) @@ -89,8 +97,13 @@ out = removeLastCodePoint( 'foo bar', 10 ); -```javascript -var removeLastCodePoint = require( '@stdlib/string-base-remove-last-code-point' ); +```html + + + + + + + ```
diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index d846d34..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,56 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var removeLast = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var values; - var out; - var i; - - values = [ - 'beep boop', - 'foo bar', - 'xyz abc', - '🐶🐮🐷🐰🐸' - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = removeLast( values[ i%values.length ], 1 ); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( !isString( out ) ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 41f4db9..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/base/remove-last-code-point" -%% click B href "https://github.com/stdlib-js/string-base-remove-last-code-point/tree/main" -%% click C href "https://github.com/stdlib-js/string-base-remove-last-code-point/tree/production" -%% click D href "https://github.com/stdlib-js/string-base-remove-last-code-point/tree/esm" -%% click E href "https://github.com/stdlib-js/string-base-remove-last-code-point/tree/deno" -%% click F href "https://github.com/stdlib-js/string-base-remove-last-code-point/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/base/remove-last-code-point -[production-url]: https://github.com/stdlib-js/string-base-remove-last-code-point/tree/production -[deno-url]: https://github.com/stdlib-js/string-base-remove-last-code-point/tree/deno -[umd-url]: https://github.com/stdlib-js/string-base-remove-last-code-point/tree/umd -[esm-url]: https://github.com/stdlib-js/string-base-remove-last-code-point/tree/esm \ No newline at end of file diff --git a/browser.js b/browser.js new file mode 100644 index 0000000..d3e0f5b --- /dev/null +++ b/browser.js @@ -0,0 +1,3 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +var e,t;e=this,t=function(){"use strict";var e=/[\uDC00-\uDFFF]/,t=/[\uD800-\uDBFF]/;return function(n,f){var i,o,r,u;if(0===f)return n;for(r=0,u=n.length-1;u>=0;u--){if(i=n[u],r+=1,e.test(i)){if(0===u)break;o=n[u-1],t.test(o)&&(u-=1)}if(r===f)break}return n.substring(0,u)}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).removeLastCodePoint=t(); +//# sourceMappingURL=browser.js.map diff --git a/browser.js.map b/browser.js.map new file mode 100644 index 0000000..19908eb --- /dev/null +++ b/browser.js.map @@ -0,0 +1 @@ +{"version":3,"file":"browser.js","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\nvar RE_UTF16_LOW_SURROGATE = /[\\uDC00-\\uDFFF]/; // TODO: replace with stdlib pkg\nvar RE_UTF16_HIGH_SURROGATE = /[\\uD800-\\uDBFF]/; // TODO: replace with stdlib pkg\n\n\n// MAIN //\n\n/**\n* Removes the last `n` Unicode code points of a string.\n*\n* @param {string} str - input string\n* @param {NonNegativeInteger} n - number of Unicode code points to remove\n* @returns {string} output string\n*\n* @example\n* var out = removeLast( 'last man standing', 1 );\n* // returns 'last man standin'\n*\n* @example\n* var out = removeLast( 'presidential election', 1 );\n* // returns 'presidential electio'\n*\n* @example\n* var out = removeLast( 'JavaScript', 1 );\n* // returns 'JavaScrip'\n*\n* @example\n* var out = removeLast( 'Hidden Treasures', 1 );\n* // returns 'Hidden Treasure'\n*/\nfunction removeLast( str, n ) {\n\tvar len;\n\tvar ch1;\n\tvar ch2;\n\tvar cnt;\n\tvar i;\n\tif ( n === 0 ) {\n\t\treturn str;\n\t}\n\tlen = str.length;\n\tcnt = 0;\n\n\t// Process the string one Unicode code unit at a time and count UTF-16 surrogate pairs as a single Unicode code point...\n\tfor ( i = len - 1; i >= 0; i-- ) {\n\t\tch1 = str[ i ];\n\t\tcnt += 1;\n\n\t\t// Check for a low UTF-16 surrogate...\n\t\tif ( RE_UTF16_LOW_SURROGATE.test( ch1 ) ) {\n\t\t\t// Check for an unpaired surrogate at the end of the input string...\n\t\t\tif ( i === 0 ) {\n\t\t\t\t// We found an unpaired surrogate...\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\t// Check whether the high surrogate is paired with a low surrogate...\n\t\t\tch2 = str[ i-1 ];\n\t\t\tif ( RE_UTF16_HIGH_SURROGATE.test( ch2 ) ) {\n\t\t\t\t// We found a surrogate pair:\n\t\t\t\ti -= 1; // bump the index to process the next code unit\n\t\t\t}\n\t\t}\n\t\t// Check whether we've found the desired number of code points...\n\t\tif ( cnt === n ) {\n\t\t\tbreak;\n\t\t}\n\t}\n\treturn str.substring( 0, i );\n}\n\n\n// EXPORTS //\n\nexport default removeLast;\n"],"names":["RE_UTF16_LOW_SURROGATE","RE_UTF16_HIGH_SURROGATE","str","n","ch1","ch2","cnt","i","length","test","substring"],"mappings":";yCAsBA,IAAIA,EAAyB,kBACzBC,EAA0B,yBA4B9B,SAAqBC,EAAKC,GACzB,IACIC,EACAC,EACAC,EACAC,EACJ,GAAW,IAANJ,EACJ,OAAOD,EAMR,IAHAI,EAAM,EAGAC,EAJAL,EAAIM,OAIM,EAAGD,GAAK,EAAGA,IAAM,CAKhC,GAJAH,EAAMF,EAAKK,GACXD,GAAO,EAGFN,EAAuBS,KAAML,GAAQ,CAEzC,GAAW,IAANG,EAEJ,MAGDF,EAAMH,EAAKK,EAAE,GACRN,EAAwBQ,KAAMJ,KAElCE,GAAK,EAEN,CAED,GAAKD,IAAQH,EACZ,KAED,CACD,OAAOD,EAAIQ,UAAW,EAAGH,EAC1B"} \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index 8c96fd7..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import removeLast from '../docs/types/index'; -export = removeLast; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index e6b7220..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var s=function(e,t){return function(){return t||e((t={exports:{}}).exports,t),t.exports}};var f=s(function(D,n){ -var F=/[\uDC00-\uDFFF]/,c=/[\uD800-\uDBFF]/;function R(e,t){var i,u,v,a,r;if(t===0)return e;for(i=e.length,a=0,r=i-1;r>=0;r--){if(u=e[r],a+=1,F.test(u)){if(r===0)break;v=e[r-1],c.test(v)&&(r-=1)}if(a===t)break}return e.substring(0,r)}n.exports=R -});var _=f();module.exports=_; -/** @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 72561cf..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\nvar RE_UTF16_LOW_SURROGATE = /[\\uDC00-\\uDFFF]/; // TODO: replace with stdlib pkg\nvar RE_UTF16_HIGH_SURROGATE = /[\\uD800-\\uDBFF]/; // TODO: replace with stdlib pkg\n\n\n// MAIN //\n\n/**\n* Removes the last `n` Unicode code points of a string.\n*\n* @param {string} str - input string\n* @param {NonNegativeInteger} n - number of Unicode code points to remove\n* @returns {string} output string\n*\n* @example\n* var out = removeLast( 'last man standing', 1 );\n* // returns 'last man standin'\n*\n* @example\n* var out = removeLast( 'presidential election', 1 );\n* // returns 'presidential electio'\n*\n* @example\n* var out = removeLast( 'JavaScript', 1 );\n* // returns 'JavaScrip'\n*\n* @example\n* var out = removeLast( 'Hidden Treasures', 1 );\n* // returns 'Hidden Treasure'\n*/\nfunction removeLast( str, n ) {\n\tvar len;\n\tvar ch1;\n\tvar ch2;\n\tvar cnt;\n\tvar i;\n\tif ( n === 0 ) {\n\t\treturn str;\n\t}\n\tlen = str.length;\n\tcnt = 0;\n\n\t// Process the string one Unicode code unit at a time and count UTF-16 surrogate pairs as a single Unicode code point...\n\tfor ( i = len - 1; i >= 0; i-- ) {\n\t\tch1 = str[ i ];\n\t\tcnt += 1;\n\n\t\t// Check for a low UTF-16 surrogate...\n\t\tif ( RE_UTF16_LOW_SURROGATE.test( ch1 ) ) {\n\t\t\t// Check for an unpaired surrogate at the end of the input string...\n\t\t\tif ( i === 0 ) {\n\t\t\t\t// We found an unpaired surrogate...\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\t// Check whether the high surrogate is paired with a low surrogate...\n\t\t\tch2 = str[ i-1 ];\n\t\t\tif ( RE_UTF16_HIGH_SURROGATE.test( ch2 ) ) {\n\t\t\t\t// We found a surrogate pair:\n\t\t\t\ti -= 1; // bump the index to process the next code unit\n\t\t\t}\n\t\t}\n\t\t// Check whether we've found the desired number of code points...\n\t\tif ( cnt === n ) {\n\t\t\tbreak;\n\t\t}\n\t}\n\treturn str.substring( 0, i );\n}\n\n\n// EXPORTS //\n\nmodule.exports = removeLast;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Remove the last `n` Unicode code points of a string.\n*\n* @module @stdlib/string-base-remove-last-code-point\n*\n* @example\n* var removeLast = require( '@stdlib/string-base-remove-last-code-point' );\n*\n* var out = removeLast( 'last man standing', 1 );\n* // returns 'last man standin'\n*\n* out = removeLast( 'Hidden Treasures', 1 );\n* // returns 'Hidden Treasure';\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,EAAyB,kBACzBC,EAA0B,kBA4B9B,SAASC,EAAYC,EAAKC,EAAI,CAC7B,IAAIC,EACAC,EACAC,EACAC,EACAC,EACJ,GAAKL,IAAM,EACV,OAAOD,EAMR,IAJAE,EAAMF,EAAI,OACVK,EAAM,EAGAC,EAAIJ,EAAM,EAAGI,GAAK,EAAGA,IAAM,CAKhC,GAJAH,EAAMH,EAAKM,CAAE,EACbD,GAAO,EAGFR,EAAuB,KAAMM,CAAI,EAAI,CAEzC,GAAKG,IAAM,EAEV,MAGDF,EAAMJ,EAAKM,EAAE,CAAE,EACVR,EAAwB,KAAMM,CAAI,IAEtCE,GAAK,EAEP,CAEA,GAAKD,IAAQJ,EACZ,KAEF,CACA,OAAOD,EAAI,UAAW,EAAGM,CAAE,CAC5B,CAKAV,EAAO,QAAUG,ICxDjB,IAAIQ,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "RE_UTF16_LOW_SURROGATE", "RE_UTF16_HIGH_SURROGATE", "removeLast", "str", "n", "len", "ch1", "ch2", "cnt", "i", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index a08ea55..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,29 +0,0 @@ - -{{alias}}( str, n ) - Removes the last `n` Unicode code points of a string. - - Parameters - ---------- - str: string - Input string. - - n: integer - Number of Unicode code points to remove. - - Returns - ------- - out: string - Output string. - - Examples - -------- - > var out = {{alias}}( 'beep', 1 ) - 'bee' - > out = {{alias}}( 'Boop', 1 ) - 'Boo' - > out = {{alias}}( 'foo bar', 5 ) - 'fo' - - See Also - -------- - diff --git a/docs/types/index.d.ts b/docs/types/index.d.ts deleted file mode 100644 index 8a1c90b..0000000 --- a/docs/types/index.d.ts +++ /dev/null @@ -1,53 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 - -/** -* Removes the last `n` Unicode code points of a string. -* -* @param str - input string -* @param n - number of code points to remove -* @returns output string -* -* @example -* var out = removeLast( 'last man standing', 1 ); -* // returns 'last man standin' -* -* @example -* var out = removeLast( 'presidential election', 1 ); -* // returns 'presidential electio' -* -* @example -* var out = removeLast( 'JavaScript', 1 ); -* // returns 'JavaScrip' -* -* @example -* var out = removeLast( 'Hidden Treasures', 1 ); -* // returns 'Hidden Treasure' -* -* @example -* var out = removeLast( 'foo bar', 5 ); -* // returns 'fo' -*/ -declare function removeLast( str: string, n: number ): string; - - -// EXPORTS // - -export = removeLast; diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index fd426d2..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,57 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 removeLast = require( './index' ); - - -// TESTS // - -// The function returns a string... -{ - removeLast( 'abc', 1 ); // $ExpectType string -} - -// The compiler throws an error if the function is provided a value other than a string... -{ - removeLast( true, 1 ); // $ExpectError - removeLast( false, 1 ); // $ExpectError - removeLast( null, 1 ); // $ExpectError - removeLast( undefined, 1 ); // $ExpectError - removeLast( 5, 1 ); // $ExpectError - removeLast( [], 1 ); // $ExpectError - removeLast( {}, 1 ); // $ExpectError - removeLast( ( x: number ): number => x, 1 ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument that is not a number... -{ - removeLast( 'abc', true ); // $ExpectError - removeLast( 'abc', false ); // $ExpectError - removeLast( 'abc', null ); // $ExpectError - removeLast( 'abc', 'abc' ); // $ExpectError - removeLast( 'abc', [] ); // $ExpectError - removeLast( 'abc', {} ); // $ExpectError - removeLast( 'abc', ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - removeLast(); // $ExpectError - removeLast( 'abc' ); // $ExpectError - removeLast( 'abc', 1, 2 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 085633e..0000000 --- a/examples/index.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var removeLastCodePoint = require( './../lib' ); - -console.log( removeLastCodePoint( 'presidential election', 1 ) ); -// => 'presidential electio' - -console.log( removeLastCodePoint( 'JavaScript', 1 ) ); -// => 'JavaScrip' - -console.log( removeLastCodePoint( 'The Last of the Mohicans', 5 ) ); -// => 'The Last of the Moh' - -console.log( removeLastCodePoint( 'अनुच्छेद', 1 ) ); -// => 'अनुच्छे' diff --git a/index.js b/index.js new file mode 100644 index 0000000..0185898 --- /dev/null +++ b/index.js @@ -0,0 +1,3 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +var e,t;e=this,t=function(){"use strict";var e=/[\uDC00-\uDFFF]/,t=/[\uD800-\uDBFF]/;return function(n,f){var i,o,r,u;if(0===f)return n;for(r=0,u=n.length-1;u>=0;u--){if(i=n[u],r+=1,e.test(i)){if(0===u)break;o=n[u-1],t.test(o)&&(u-=1)}if(r===f)break}return n.substring(0,u)}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).removeLastCodePoint=t(); +//# sourceMappingURL=index.js.map diff --git a/index.js.map b/index.js.map new file mode 100644 index 0000000..d557af8 --- /dev/null +++ b/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\nvar RE_UTF16_LOW_SURROGATE = /[\\uDC00-\\uDFFF]/; // TODO: replace with stdlib pkg\nvar RE_UTF16_HIGH_SURROGATE = /[\\uD800-\\uDBFF]/; // TODO: replace with stdlib pkg\n\n\n// MAIN //\n\n/**\n* Removes the last `n` Unicode code points of a string.\n*\n* @param {string} str - input string\n* @param {NonNegativeInteger} n - number of Unicode code points to remove\n* @returns {string} output string\n*\n* @example\n* var out = removeLast( 'last man standing', 1 );\n* // returns 'last man standin'\n*\n* @example\n* var out = removeLast( 'presidential election', 1 );\n* // returns 'presidential electio'\n*\n* @example\n* var out = removeLast( 'JavaScript', 1 );\n* // returns 'JavaScrip'\n*\n* @example\n* var out = removeLast( 'Hidden Treasures', 1 );\n* // returns 'Hidden Treasure'\n*/\nfunction removeLast( str, n ) {\n\tvar len;\n\tvar ch1;\n\tvar ch2;\n\tvar cnt;\n\tvar i;\n\tif ( n === 0 ) {\n\t\treturn str;\n\t}\n\tlen = str.length;\n\tcnt = 0;\n\n\t// Process the string one Unicode code unit at a time and count UTF-16 surrogate pairs as a single Unicode code point...\n\tfor ( i = len - 1; i >= 0; i-- ) {\n\t\tch1 = str[ i ];\n\t\tcnt += 1;\n\n\t\t// Check for a low UTF-16 surrogate...\n\t\tif ( RE_UTF16_LOW_SURROGATE.test( ch1 ) ) {\n\t\t\t// Check for an unpaired surrogate at the end of the input string...\n\t\t\tif ( i === 0 ) {\n\t\t\t\t// We found an unpaired surrogate...\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\t// Check whether the high surrogate is paired with a low surrogate...\n\t\t\tch2 = str[ i-1 ];\n\t\t\tif ( RE_UTF16_HIGH_SURROGATE.test( ch2 ) ) {\n\t\t\t\t// We found a surrogate pair:\n\t\t\t\ti -= 1; // bump the index to process the next code unit\n\t\t\t}\n\t\t}\n\t\t// Check whether we've found the desired number of code points...\n\t\tif ( cnt === n ) {\n\t\t\tbreak;\n\t\t}\n\t}\n\treturn str.substring( 0, i );\n}\n\n\n// EXPORTS //\n\nexport default removeLast;\n"],"names":["RE_UTF16_LOW_SURROGATE","RE_UTF16_HIGH_SURROGATE","str","n","ch1","ch2","cnt","i","length","test","substring"],"mappings":";yCAsBA,IAAIA,EAAyB,kBACzBC,EAA0B,yBA4B9B,SAAqBC,EAAKC,GACzB,IACIC,EACAC,EACAC,EACAC,EACJ,GAAW,IAANJ,EACJ,OAAOD,EAMR,IAHAI,EAAM,EAGAC,EAJAL,EAAIM,OAIM,EAAGD,GAAK,EAAGA,IAAM,CAKhC,GAJAH,EAAMF,EAAKK,GACXD,GAAO,EAGFN,EAAuBS,KAAML,GAAQ,CAEzC,GAAW,IAANG,EAEJ,MAGDF,EAAMH,EAAKK,EAAE,GACRN,EAAwBQ,KAAMJ,KAElCE,GAAK,EAEN,CAED,GAAKD,IAAQH,EACZ,KAED,CACD,OAAOD,EAAIQ,UAAW,EAAGH,EAC1B"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 9860da0..0000000 --- a/lib/index.js +++ /dev/null @@ -1,43 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Remove the last `n` Unicode code points of a string. -* -* @module @stdlib/string-base-remove-last-code-point -* -* @example -* var removeLast = require( '@stdlib/string-base-remove-last-code-point' ); -* -* var out = removeLast( 'last man standing', 1 ); -* // returns 'last man standin' -* -* out = removeLast( 'Hidden Treasures', 1 ); -* // returns 'Hidden Treasure'; -*/ - -// 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 fc34187..0000000 --- a/lib/main.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// VARIABLES // - -var RE_UTF16_LOW_SURROGATE = /[\uDC00-\uDFFF]/; // TODO: replace with stdlib pkg -var RE_UTF16_HIGH_SURROGATE = /[\uD800-\uDBFF]/; // TODO: replace with stdlib pkg - - -// MAIN // - -/** -* Removes the last `n` Unicode code points of a string. -* -* @param {string} str - input string -* @param {NonNegativeInteger} n - number of Unicode code points to remove -* @returns {string} output string -* -* @example -* var out = removeLast( 'last man standing', 1 ); -* // returns 'last man standin' -* -* @example -* var out = removeLast( 'presidential election', 1 ); -* // returns 'presidential electio' -* -* @example -* var out = removeLast( 'JavaScript', 1 ); -* // returns 'JavaScrip' -* -* @example -* var out = removeLast( 'Hidden Treasures', 1 ); -* // returns 'Hidden Treasure' -*/ -function removeLast( str, n ) { - var len; - var ch1; - var ch2; - var cnt; - var i; - if ( n === 0 ) { - return str; - } - len = str.length; - cnt = 0; - - // Process the string one Unicode code unit at a time and count UTF-16 surrogate pairs as a single Unicode code point... - for ( i = len - 1; i >= 0; i-- ) { - ch1 = str[ i ]; - cnt += 1; - - // Check for a low UTF-16 surrogate... - if ( RE_UTF16_LOW_SURROGATE.test( ch1 ) ) { - // Check for an unpaired surrogate at the end of the input string... - if ( i === 0 ) { - // We found an unpaired surrogate... - break; - } - // Check whether the high surrogate is paired with a low surrogate... - ch2 = str[ i-1 ]; - if ( RE_UTF16_HIGH_SURROGATE.test( ch2 ) ) { - // We found a surrogate pair: - i -= 1; // bump the index to process the next code unit - } - } - // Check whether we've found the desired number of code points... - if ( cnt === n ) { - break; - } - } - return str.substring( 0, i ); -} - - -// EXPORTS // - -module.exports = removeLast; diff --git a/package.json b/package.json index 3bbb2a9..0594acf 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,7 @@ "version": "0.0.0", "description": "Remove the last Unicode code point of a string.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "main": "./index.js", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,31 +12,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/error-tools-fmtprodmsg": "^0.0.2" - }, - "devDependencies": { - "@stdlib/assert-is-string": "^0.0.8", - "@stdlib/bench": "^0.0.12", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdstring", @@ -81,4 +32,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/stats_browser.html b/stats_browser.html new file mode 100644 index 0000000..4c175de --- /dev/null +++ b/stats_browser.html @@ -0,0 +1,6177 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/stats_node.html b/stats_node.html new file mode 100644 index 0000000..3560e79 --- /dev/null +++ b/stats_node.html @@ -0,0 +1,6177 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/test.js b/test/test.js deleted file mode 100644 index a25545e..0000000 --- a/test/test.js +++ /dev/null @@ -1,108 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var removeLast = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof removeLast, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns an empty string if provided an empty string', function test( t ) { - t.strictEqual( removeLast( '', 1 ), '', 'returns expected value' ); - t.strictEqual( removeLast( '', 2 ), '', 'returns expected value' ); - t.strictEqual( removeLast( '', 3 ), '', 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns the input string if provided zero as the second argument', function test( t ) { - t.strictEqual( removeLast( 'hello world', 0 ), 'hello world', 'returns expected value' ); - t.end(); -}); - -tape( 'the function removes the last Unicode code point of a provided string (ascii)', function test( t ) { - var out; - - out = removeLast( 'hello world', 1 ); - t.strictEqual( out, 'hello worl', 'returns expected value' ); - - out = removeLast( '!!!', 1 ); - t.strictEqual( out, '!!', 'returns expected value' ); - - out = removeLast( 'Hello World', 1 ); - t.strictEqual( out, 'Hello Worl', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function removes the last Unicode code point of a provided string (Unicode)', function test( t ) { - var out; - - out = removeLast( 'अनुच्छेद', 1 ); - t.strictEqual( out, 'अनुच्छे', 'returns expected value' ); - - out = removeLast( '六书/六書', 1 ); - t.strictEqual( out, '六书/六', 'returns expected value' ); - - out = removeLast( '𐒻𐓟', 1 ); - t.strictEqual( out, '𐒻', 'returns expected value' ); - - out = removeLast( '𐒻𐓟', 1 ); - t.strictEqual( out, '𐒻', 'returns expected value' ); - - out = removeLast( '\uDC00', 1 ); - t.strictEqual( out, '', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports removing the last `n` Unicode code points of a provided string', function test( t ) { - var out; - - out = removeLast( 'hello world', 1 ); - t.strictEqual( out, 'hello worl', 'returns expected value' ); - - out = removeLast( 'hello world', 7 ); - t.strictEqual( out, 'hell', 'returns expected value' ); - - out = removeLast( '!!!', 1 ); - t.strictEqual( out, '!!', 'returns expected value' ); - - out = removeLast( '!!!', 2 ); - t.strictEqual( out, '!', 'returns expected value' ); - - out = removeLast( 'अनुच्छेद', 1 ); - t.strictEqual( out, 'अनुच्छे', 'returns expected value' ); - - out = removeLast( '六书/六書', 3 ); - t.strictEqual( out, '六书', 'returns expected value' ); - - out = removeLast( '𐒻𐓟𐓟', 2 ); - t.strictEqual( out, '𐒻', 'returns expected value' ); - - t.end(); -}); From fb819bd55cf7f0a578c852a55b2b13b724471243 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 22 Sep 2023 01:46:36 +0000 Subject: [PATCH 03/92] Transform error messages --- package.json | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index bd538db..508efe9 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,9 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": {}, + "dependencies": { + "@stdlib/error-tools-fmtprodmsg": "^0.0.2" + }, "devDependencies": { "@stdlib/assert-is-string": "^0.0.8", "@stdlib/bench": "^0.0.12", @@ -79,4 +81,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 639da831535413a9968f6acd72702b8094187ea0 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 22 Sep 2023 01:47:09 +0000 Subject: [PATCH 04/92] Remove files --- browser.js | 3 - browser.js.map | 1 - index.js | 3 - index.js.map | 1 - stats_browser.html | 6177 -------------------------------------------- stats_node.html | 6177 -------------------------------------------- 6 files changed, 12362 deletions(-) delete mode 100644 browser.js delete mode 100644 browser.js.map delete mode 100644 index.js delete mode 100644 index.js.map delete mode 100644 stats_browser.html delete mode 100644 stats_node.html diff --git a/browser.js b/browser.js deleted file mode 100644 index d3e0f5b..0000000 --- a/browser.js +++ /dev/null @@ -1,3 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -var e,t;e=this,t=function(){"use strict";var e=/[\uDC00-\uDFFF]/,t=/[\uD800-\uDBFF]/;return function(n,f){var i,o,r,u;if(0===f)return n;for(r=0,u=n.length-1;u>=0;u--){if(i=n[u],r+=1,e.test(i)){if(0===u)break;o=n[u-1],t.test(o)&&(u-=1)}if(r===f)break}return n.substring(0,u)}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).removeLastCodePoint=t(); -//# sourceMappingURL=browser.js.map diff --git a/browser.js.map b/browser.js.map deleted file mode 100644 index 19908eb..0000000 --- a/browser.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"browser.js","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\nvar RE_UTF16_LOW_SURROGATE = /[\\uDC00-\\uDFFF]/; // TODO: replace with stdlib pkg\nvar RE_UTF16_HIGH_SURROGATE = /[\\uD800-\\uDBFF]/; // TODO: replace with stdlib pkg\n\n\n// MAIN //\n\n/**\n* Removes the last `n` Unicode code points of a string.\n*\n* @param {string} str - input string\n* @param {NonNegativeInteger} n - number of Unicode code points to remove\n* @returns {string} output string\n*\n* @example\n* var out = removeLast( 'last man standing', 1 );\n* // returns 'last man standin'\n*\n* @example\n* var out = removeLast( 'presidential election', 1 );\n* // returns 'presidential electio'\n*\n* @example\n* var out = removeLast( 'JavaScript', 1 );\n* // returns 'JavaScrip'\n*\n* @example\n* var out = removeLast( 'Hidden Treasures', 1 );\n* // returns 'Hidden Treasure'\n*/\nfunction removeLast( str, n ) {\n\tvar len;\n\tvar ch1;\n\tvar ch2;\n\tvar cnt;\n\tvar i;\n\tif ( n === 0 ) {\n\t\treturn str;\n\t}\n\tlen = str.length;\n\tcnt = 0;\n\n\t// Process the string one Unicode code unit at a time and count UTF-16 surrogate pairs as a single Unicode code point...\n\tfor ( i = len - 1; i >= 0; i-- ) {\n\t\tch1 = str[ i ];\n\t\tcnt += 1;\n\n\t\t// Check for a low UTF-16 surrogate...\n\t\tif ( RE_UTF16_LOW_SURROGATE.test( ch1 ) ) {\n\t\t\t// Check for an unpaired surrogate at the end of the input string...\n\t\t\tif ( i === 0 ) {\n\t\t\t\t// We found an unpaired surrogate...\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\t// Check whether the high surrogate is paired with a low surrogate...\n\t\t\tch2 = str[ i-1 ];\n\t\t\tif ( RE_UTF16_HIGH_SURROGATE.test( ch2 ) ) {\n\t\t\t\t// We found a surrogate pair:\n\t\t\t\ti -= 1; // bump the index to process the next code unit\n\t\t\t}\n\t\t}\n\t\t// Check whether we've found the desired number of code points...\n\t\tif ( cnt === n ) {\n\t\t\tbreak;\n\t\t}\n\t}\n\treturn str.substring( 0, i );\n}\n\n\n// EXPORTS //\n\nexport default removeLast;\n"],"names":["RE_UTF16_LOW_SURROGATE","RE_UTF16_HIGH_SURROGATE","str","n","ch1","ch2","cnt","i","length","test","substring"],"mappings":";yCAsBA,IAAIA,EAAyB,kBACzBC,EAA0B,yBA4B9B,SAAqBC,EAAKC,GACzB,IACIC,EACAC,EACAC,EACAC,EACJ,GAAW,IAANJ,EACJ,OAAOD,EAMR,IAHAI,EAAM,EAGAC,EAJAL,EAAIM,OAIM,EAAGD,GAAK,EAAGA,IAAM,CAKhC,GAJAH,EAAMF,EAAKK,GACXD,GAAO,EAGFN,EAAuBS,KAAML,GAAQ,CAEzC,GAAW,IAANG,EAEJ,MAGDF,EAAMH,EAAKK,EAAE,GACRN,EAAwBQ,KAAMJ,KAElCE,GAAK,EAEN,CAED,GAAKD,IAAQH,EACZ,KAED,CACD,OAAOD,EAAIQ,UAAW,EAAGH,EAC1B"} \ No newline at end of file diff --git a/index.js b/index.js deleted file mode 100644 index 0185898..0000000 --- a/index.js +++ /dev/null @@ -1,3 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -var e,t;e=this,t=function(){"use strict";var e=/[\uDC00-\uDFFF]/,t=/[\uD800-\uDBFF]/;return function(n,f){var i,o,r,u;if(0===f)return n;for(r=0,u=n.length-1;u>=0;u--){if(i=n[u],r+=1,e.test(i)){if(0===u)break;o=n[u-1],t.test(o)&&(u-=1)}if(r===f)break}return n.substring(0,u)}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).removeLastCodePoint=t(); -//# sourceMappingURL=index.js.map diff --git a/index.js.map b/index.js.map deleted file mode 100644 index d557af8..0000000 --- a/index.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.js","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\nvar RE_UTF16_LOW_SURROGATE = /[\\uDC00-\\uDFFF]/; // TODO: replace with stdlib pkg\nvar RE_UTF16_HIGH_SURROGATE = /[\\uD800-\\uDBFF]/; // TODO: replace with stdlib pkg\n\n\n// MAIN //\n\n/**\n* Removes the last `n` Unicode code points of a string.\n*\n* @param {string} str - input string\n* @param {NonNegativeInteger} n - number of Unicode code points to remove\n* @returns {string} output string\n*\n* @example\n* var out = removeLast( 'last man standing', 1 );\n* // returns 'last man standin'\n*\n* @example\n* var out = removeLast( 'presidential election', 1 );\n* // returns 'presidential electio'\n*\n* @example\n* var out = removeLast( 'JavaScript', 1 );\n* // returns 'JavaScrip'\n*\n* @example\n* var out = removeLast( 'Hidden Treasures', 1 );\n* // returns 'Hidden Treasure'\n*/\nfunction removeLast( str, n ) {\n\tvar len;\n\tvar ch1;\n\tvar ch2;\n\tvar cnt;\n\tvar i;\n\tif ( n === 0 ) {\n\t\treturn str;\n\t}\n\tlen = str.length;\n\tcnt = 0;\n\n\t// Process the string one Unicode code unit at a time and count UTF-16 surrogate pairs as a single Unicode code point...\n\tfor ( i = len - 1; i >= 0; i-- ) {\n\t\tch1 = str[ i ];\n\t\tcnt += 1;\n\n\t\t// Check for a low UTF-16 surrogate...\n\t\tif ( RE_UTF16_LOW_SURROGATE.test( ch1 ) ) {\n\t\t\t// Check for an unpaired surrogate at the end of the input string...\n\t\t\tif ( i === 0 ) {\n\t\t\t\t// We found an unpaired surrogate...\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\t// Check whether the high surrogate is paired with a low surrogate...\n\t\t\tch2 = str[ i-1 ];\n\t\t\tif ( RE_UTF16_HIGH_SURROGATE.test( ch2 ) ) {\n\t\t\t\t// We found a surrogate pair:\n\t\t\t\ti -= 1; // bump the index to process the next code unit\n\t\t\t}\n\t\t}\n\t\t// Check whether we've found the desired number of code points...\n\t\tif ( cnt === n ) {\n\t\t\tbreak;\n\t\t}\n\t}\n\treturn str.substring( 0, i );\n}\n\n\n// EXPORTS //\n\nexport default removeLast;\n"],"names":["RE_UTF16_LOW_SURROGATE","RE_UTF16_HIGH_SURROGATE","str","n","ch1","ch2","cnt","i","length","test","substring"],"mappings":";yCAsBA,IAAIA,EAAyB,kBACzBC,EAA0B,yBA4B9B,SAAqBC,EAAKC,GACzB,IACIC,EACAC,EACAC,EACAC,EACJ,GAAW,IAANJ,EACJ,OAAOD,EAMR,IAHAI,EAAM,EAGAC,EAJAL,EAAIM,OAIM,EAAGD,GAAK,EAAGA,IAAM,CAKhC,GAJAH,EAAMF,EAAKK,GACXD,GAAO,EAGFN,EAAuBS,KAAML,GAAQ,CAEzC,GAAW,IAANG,EAEJ,MAGDF,EAAMH,EAAKK,EAAE,GACRN,EAAwBQ,KAAMJ,KAElCE,GAAK,EAEN,CAED,GAAKD,IAAQH,EACZ,KAED,CACD,OAAOD,EAAIQ,UAAW,EAAGH,EAC1B"} \ No newline at end of file diff --git a/stats_browser.html b/stats_browser.html deleted file mode 100644 index 4c175de..0000000 --- a/stats_browser.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - diff --git a/stats_node.html b/stats_node.html deleted file mode 100644 index 3560e79..0000000 --- a/stats_node.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 940811f719c4690f879e71c8169d3283947a0c00 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 22 Sep 2023 01:47:52 +0000 Subject: [PATCH 05/92] Auto-generated commit --- .editorconfig | 186 - .eslintrc.js | 1 - .gitattributes | 49 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 62 - .github/workflows/cancel.yml | 56 - .github/workflows/close_pull_requests.yml | 44 - .github/workflows/examples.yml | 62 - .github/workflows/npm_downloads.yml | 108 - .github/workflows/productionize.yml | 783 --- .github/workflows/publish.yml | 242 - .github/workflows/test.yml | 97 - .github/workflows/test_bundles.yml | 180 - .github/workflows/test_coverage.yml | 123 - .github/workflows/test_install.yml | 83 - .gitignore | 188 - .npmignore | 227 - .npmrc | 28 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 52 +- benchmark/benchmark.js | 56 - branches.md | 53 - browser.js | 3 + browser.js.map | 1 + dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 29 - docs/types/index.d.ts | 53 - docs/types/test.ts | 57 - examples/index.js | 33 - index.js | 3 + index.js.map | 1 + lib/index.js | 43 - lib/main.js | 94 - package.json | 53 +- stats_browser.html | 6177 +++++++++++++++++++++ stats_node.html | 6177 +++++++++++++++++++++ test/test.js | 108 - 43 files changed, 12399 insertions(+), 3710 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md create mode 100644 browser.js create mode 100644 browser.js.map 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/index.d.ts delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js create mode 100644 index.js create mode 100644 index.js.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats_browser.html create mode 100644 stats_node.html delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 13e9c39..0000000 --- a/.editorconfig +++ /dev/null @@ -1,186 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 52cd9c4..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/base/remove-last-code-point) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 cc028ca..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/base/remove-last-code-point) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 fcbf6f1..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: '29 5 * * 0' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - uses: actions/upload-artifact@v3 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - uses: distributhor/workflow-webhook@v3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 91f2b93..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,783 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - uses: actions/checkout@v3 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - uses: actions/checkout@v3 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - uses: act10ns/slack@v2 - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n +``` + +If no recognized module system is present, access bundle contents via the global scope: + +```html + ``` #### removeLastCodePoint( str, n ) @@ -89,8 +97,13 @@ out = removeLastCodePoint( 'foo bar', 10 ); -```javascript -var removeLastCodePoint = require( '@stdlib/string-base-remove-last-code-point' ); +```html + + + + + + + ```
diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index d846d34..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,56 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var removeLast = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var values; - var out; - var i; - - values = [ - 'beep boop', - 'foo bar', - 'xyz abc', - '🐶🐮🐷🐰🐸' - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = removeLast( values[ i%values.length ], 1 ); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( !isString( out ) ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 41f4db9..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/base/remove-last-code-point" -%% click B href "https://github.com/stdlib-js/string-base-remove-last-code-point/tree/main" -%% click C href "https://github.com/stdlib-js/string-base-remove-last-code-point/tree/production" -%% click D href "https://github.com/stdlib-js/string-base-remove-last-code-point/tree/esm" -%% click E href "https://github.com/stdlib-js/string-base-remove-last-code-point/tree/deno" -%% click F href "https://github.com/stdlib-js/string-base-remove-last-code-point/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/base/remove-last-code-point -[production-url]: https://github.com/stdlib-js/string-base-remove-last-code-point/tree/production -[deno-url]: https://github.com/stdlib-js/string-base-remove-last-code-point/tree/deno -[umd-url]: https://github.com/stdlib-js/string-base-remove-last-code-point/tree/umd -[esm-url]: https://github.com/stdlib-js/string-base-remove-last-code-point/tree/esm \ No newline at end of file diff --git a/browser.js b/browser.js new file mode 100644 index 0000000..d3e0f5b --- /dev/null +++ b/browser.js @@ -0,0 +1,3 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +var e,t;e=this,t=function(){"use strict";var e=/[\uDC00-\uDFFF]/,t=/[\uD800-\uDBFF]/;return function(n,f){var i,o,r,u;if(0===f)return n;for(r=0,u=n.length-1;u>=0;u--){if(i=n[u],r+=1,e.test(i)){if(0===u)break;o=n[u-1],t.test(o)&&(u-=1)}if(r===f)break}return n.substring(0,u)}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).removeLastCodePoint=t(); +//# sourceMappingURL=browser.js.map diff --git a/browser.js.map b/browser.js.map new file mode 100644 index 0000000..19908eb --- /dev/null +++ b/browser.js.map @@ -0,0 +1 @@ +{"version":3,"file":"browser.js","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\nvar RE_UTF16_LOW_SURROGATE = /[\\uDC00-\\uDFFF]/; // TODO: replace with stdlib pkg\nvar RE_UTF16_HIGH_SURROGATE = /[\\uD800-\\uDBFF]/; // TODO: replace with stdlib pkg\n\n\n// MAIN //\n\n/**\n* Removes the last `n` Unicode code points of a string.\n*\n* @param {string} str - input string\n* @param {NonNegativeInteger} n - number of Unicode code points to remove\n* @returns {string} output string\n*\n* @example\n* var out = removeLast( 'last man standing', 1 );\n* // returns 'last man standin'\n*\n* @example\n* var out = removeLast( 'presidential election', 1 );\n* // returns 'presidential electio'\n*\n* @example\n* var out = removeLast( 'JavaScript', 1 );\n* // returns 'JavaScrip'\n*\n* @example\n* var out = removeLast( 'Hidden Treasures', 1 );\n* // returns 'Hidden Treasure'\n*/\nfunction removeLast( str, n ) {\n\tvar len;\n\tvar ch1;\n\tvar ch2;\n\tvar cnt;\n\tvar i;\n\tif ( n === 0 ) {\n\t\treturn str;\n\t}\n\tlen = str.length;\n\tcnt = 0;\n\n\t// Process the string one Unicode code unit at a time and count UTF-16 surrogate pairs as a single Unicode code point...\n\tfor ( i = len - 1; i >= 0; i-- ) {\n\t\tch1 = str[ i ];\n\t\tcnt += 1;\n\n\t\t// Check for a low UTF-16 surrogate...\n\t\tif ( RE_UTF16_LOW_SURROGATE.test( ch1 ) ) {\n\t\t\t// Check for an unpaired surrogate at the end of the input string...\n\t\t\tif ( i === 0 ) {\n\t\t\t\t// We found an unpaired surrogate...\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\t// Check whether the high surrogate is paired with a low surrogate...\n\t\t\tch2 = str[ i-1 ];\n\t\t\tif ( RE_UTF16_HIGH_SURROGATE.test( ch2 ) ) {\n\t\t\t\t// We found a surrogate pair:\n\t\t\t\ti -= 1; // bump the index to process the next code unit\n\t\t\t}\n\t\t}\n\t\t// Check whether we've found the desired number of code points...\n\t\tif ( cnt === n ) {\n\t\t\tbreak;\n\t\t}\n\t}\n\treturn str.substring( 0, i );\n}\n\n\n// EXPORTS //\n\nexport default removeLast;\n"],"names":["RE_UTF16_LOW_SURROGATE","RE_UTF16_HIGH_SURROGATE","str","n","ch1","ch2","cnt","i","length","test","substring"],"mappings":";yCAsBA,IAAIA,EAAyB,kBACzBC,EAA0B,yBA4B9B,SAAqBC,EAAKC,GACzB,IACIC,EACAC,EACAC,EACAC,EACJ,GAAW,IAANJ,EACJ,OAAOD,EAMR,IAHAI,EAAM,EAGAC,EAJAL,EAAIM,OAIM,EAAGD,GAAK,EAAGA,IAAM,CAKhC,GAJAH,EAAMF,EAAKK,GACXD,GAAO,EAGFN,EAAuBS,KAAML,GAAQ,CAEzC,GAAW,IAANG,EAEJ,MAGDF,EAAMH,EAAKK,EAAE,GACRN,EAAwBQ,KAAMJ,KAElCE,GAAK,EAEN,CAED,GAAKD,IAAQH,EACZ,KAED,CACD,OAAOD,EAAIQ,UAAW,EAAGH,EAC1B"} \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index 8c96fd7..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import removeLast from '../docs/types/index'; -export = removeLast; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index e6b7220..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var s=function(e,t){return function(){return t||e((t={exports:{}}).exports,t),t.exports}};var f=s(function(D,n){ -var F=/[\uDC00-\uDFFF]/,c=/[\uD800-\uDBFF]/;function R(e,t){var i,u,v,a,r;if(t===0)return e;for(i=e.length,a=0,r=i-1;r>=0;r--){if(u=e[r],a+=1,F.test(u)){if(r===0)break;v=e[r-1],c.test(v)&&(r-=1)}if(a===t)break}return e.substring(0,r)}n.exports=R -});var _=f();module.exports=_; -/** @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 72561cf..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\nvar RE_UTF16_LOW_SURROGATE = /[\\uDC00-\\uDFFF]/; // TODO: replace with stdlib pkg\nvar RE_UTF16_HIGH_SURROGATE = /[\\uD800-\\uDBFF]/; // TODO: replace with stdlib pkg\n\n\n// MAIN //\n\n/**\n* Removes the last `n` Unicode code points of a string.\n*\n* @param {string} str - input string\n* @param {NonNegativeInteger} n - number of Unicode code points to remove\n* @returns {string} output string\n*\n* @example\n* var out = removeLast( 'last man standing', 1 );\n* // returns 'last man standin'\n*\n* @example\n* var out = removeLast( 'presidential election', 1 );\n* // returns 'presidential electio'\n*\n* @example\n* var out = removeLast( 'JavaScript', 1 );\n* // returns 'JavaScrip'\n*\n* @example\n* var out = removeLast( 'Hidden Treasures', 1 );\n* // returns 'Hidden Treasure'\n*/\nfunction removeLast( str, n ) {\n\tvar len;\n\tvar ch1;\n\tvar ch2;\n\tvar cnt;\n\tvar i;\n\tif ( n === 0 ) {\n\t\treturn str;\n\t}\n\tlen = str.length;\n\tcnt = 0;\n\n\t// Process the string one Unicode code unit at a time and count UTF-16 surrogate pairs as a single Unicode code point...\n\tfor ( i = len - 1; i >= 0; i-- ) {\n\t\tch1 = str[ i ];\n\t\tcnt += 1;\n\n\t\t// Check for a low UTF-16 surrogate...\n\t\tif ( RE_UTF16_LOW_SURROGATE.test( ch1 ) ) {\n\t\t\t// Check for an unpaired surrogate at the end of the input string...\n\t\t\tif ( i === 0 ) {\n\t\t\t\t// We found an unpaired surrogate...\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\t// Check whether the high surrogate is paired with a low surrogate...\n\t\t\tch2 = str[ i-1 ];\n\t\t\tif ( RE_UTF16_HIGH_SURROGATE.test( ch2 ) ) {\n\t\t\t\t// We found a surrogate pair:\n\t\t\t\ti -= 1; // bump the index to process the next code unit\n\t\t\t}\n\t\t}\n\t\t// Check whether we've found the desired number of code points...\n\t\tif ( cnt === n ) {\n\t\t\tbreak;\n\t\t}\n\t}\n\treturn str.substring( 0, i );\n}\n\n\n// EXPORTS //\n\nmodule.exports = removeLast;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Remove the last `n` Unicode code points of a string.\n*\n* @module @stdlib/string-base-remove-last-code-point\n*\n* @example\n* var removeLast = require( '@stdlib/string-base-remove-last-code-point' );\n*\n* var out = removeLast( 'last man standing', 1 );\n* // returns 'last man standin'\n*\n* out = removeLast( 'Hidden Treasures', 1 );\n* // returns 'Hidden Treasure';\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,EAAyB,kBACzBC,EAA0B,kBA4B9B,SAASC,EAAYC,EAAKC,EAAI,CAC7B,IAAIC,EACAC,EACAC,EACAC,EACAC,EACJ,GAAKL,IAAM,EACV,OAAOD,EAMR,IAJAE,EAAMF,EAAI,OACVK,EAAM,EAGAC,EAAIJ,EAAM,EAAGI,GAAK,EAAGA,IAAM,CAKhC,GAJAH,EAAMH,EAAKM,CAAE,EACbD,GAAO,EAGFR,EAAuB,KAAMM,CAAI,EAAI,CAEzC,GAAKG,IAAM,EAEV,MAGDF,EAAMJ,EAAKM,EAAE,CAAE,EACVR,EAAwB,KAAMM,CAAI,IAEtCE,GAAK,EAEP,CAEA,GAAKD,IAAQJ,EACZ,KAEF,CACA,OAAOD,EAAI,UAAW,EAAGM,CAAE,CAC5B,CAKAV,EAAO,QAAUG,ICxDjB,IAAIQ,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "RE_UTF16_LOW_SURROGATE", "RE_UTF16_HIGH_SURROGATE", "removeLast", "str", "n", "len", "ch1", "ch2", "cnt", "i", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index a08ea55..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,29 +0,0 @@ - -{{alias}}( str, n ) - Removes the last `n` Unicode code points of a string. - - Parameters - ---------- - str: string - Input string. - - n: integer - Number of Unicode code points to remove. - - Returns - ------- - out: string - Output string. - - Examples - -------- - > var out = {{alias}}( 'beep', 1 ) - 'bee' - > out = {{alias}}( 'Boop', 1 ) - 'Boo' - > out = {{alias}}( 'foo bar', 5 ) - 'fo' - - See Also - -------- - diff --git a/docs/types/index.d.ts b/docs/types/index.d.ts deleted file mode 100644 index 8a1c90b..0000000 --- a/docs/types/index.d.ts +++ /dev/null @@ -1,53 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 - -/** -* Removes the last `n` Unicode code points of a string. -* -* @param str - input string -* @param n - number of code points to remove -* @returns output string -* -* @example -* var out = removeLast( 'last man standing', 1 ); -* // returns 'last man standin' -* -* @example -* var out = removeLast( 'presidential election', 1 ); -* // returns 'presidential electio' -* -* @example -* var out = removeLast( 'JavaScript', 1 ); -* // returns 'JavaScrip' -* -* @example -* var out = removeLast( 'Hidden Treasures', 1 ); -* // returns 'Hidden Treasure' -* -* @example -* var out = removeLast( 'foo bar', 5 ); -* // returns 'fo' -*/ -declare function removeLast( str: string, n: number ): string; - - -// EXPORTS // - -export = removeLast; diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index fd426d2..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,57 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 removeLast = require( './index' ); - - -// TESTS // - -// The function returns a string... -{ - removeLast( 'abc', 1 ); // $ExpectType string -} - -// The compiler throws an error if the function is provided a value other than a string... -{ - removeLast( true, 1 ); // $ExpectError - removeLast( false, 1 ); // $ExpectError - removeLast( null, 1 ); // $ExpectError - removeLast( undefined, 1 ); // $ExpectError - removeLast( 5, 1 ); // $ExpectError - removeLast( [], 1 ); // $ExpectError - removeLast( {}, 1 ); // $ExpectError - removeLast( ( x: number ): number => x, 1 ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument that is not a number... -{ - removeLast( 'abc', true ); // $ExpectError - removeLast( 'abc', false ); // $ExpectError - removeLast( 'abc', null ); // $ExpectError - removeLast( 'abc', 'abc' ); // $ExpectError - removeLast( 'abc', [] ); // $ExpectError - removeLast( 'abc', {} ); // $ExpectError - removeLast( 'abc', ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - removeLast(); // $ExpectError - removeLast( 'abc' ); // $ExpectError - removeLast( 'abc', 1, 2 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 085633e..0000000 --- a/examples/index.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var removeLastCodePoint = require( './../lib' ); - -console.log( removeLastCodePoint( 'presidential election', 1 ) ); -// => 'presidential electio' - -console.log( removeLastCodePoint( 'JavaScript', 1 ) ); -// => 'JavaScrip' - -console.log( removeLastCodePoint( 'The Last of the Mohicans', 5 ) ); -// => 'The Last of the Moh' - -console.log( removeLastCodePoint( 'अनुच्छेद', 1 ) ); -// => 'अनुच्छे' diff --git a/index.js b/index.js new file mode 100644 index 0000000..0185898 --- /dev/null +++ b/index.js @@ -0,0 +1,3 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +var e,t;e=this,t=function(){"use strict";var e=/[\uDC00-\uDFFF]/,t=/[\uD800-\uDBFF]/;return function(n,f){var i,o,r,u;if(0===f)return n;for(r=0,u=n.length-1;u>=0;u--){if(i=n[u],r+=1,e.test(i)){if(0===u)break;o=n[u-1],t.test(o)&&(u-=1)}if(r===f)break}return n.substring(0,u)}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).removeLastCodePoint=t(); +//# sourceMappingURL=index.js.map diff --git a/index.js.map b/index.js.map new file mode 100644 index 0000000..d557af8 --- /dev/null +++ b/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\nvar RE_UTF16_LOW_SURROGATE = /[\\uDC00-\\uDFFF]/; // TODO: replace with stdlib pkg\nvar RE_UTF16_HIGH_SURROGATE = /[\\uD800-\\uDBFF]/; // TODO: replace with stdlib pkg\n\n\n// MAIN //\n\n/**\n* Removes the last `n` Unicode code points of a string.\n*\n* @param {string} str - input string\n* @param {NonNegativeInteger} n - number of Unicode code points to remove\n* @returns {string} output string\n*\n* @example\n* var out = removeLast( 'last man standing', 1 );\n* // returns 'last man standin'\n*\n* @example\n* var out = removeLast( 'presidential election', 1 );\n* // returns 'presidential electio'\n*\n* @example\n* var out = removeLast( 'JavaScript', 1 );\n* // returns 'JavaScrip'\n*\n* @example\n* var out = removeLast( 'Hidden Treasures', 1 );\n* // returns 'Hidden Treasure'\n*/\nfunction removeLast( str, n ) {\n\tvar len;\n\tvar ch1;\n\tvar ch2;\n\tvar cnt;\n\tvar i;\n\tif ( n === 0 ) {\n\t\treturn str;\n\t}\n\tlen = str.length;\n\tcnt = 0;\n\n\t// Process the string one Unicode code unit at a time and count UTF-16 surrogate pairs as a single Unicode code point...\n\tfor ( i = len - 1; i >= 0; i-- ) {\n\t\tch1 = str[ i ];\n\t\tcnt += 1;\n\n\t\t// Check for a low UTF-16 surrogate...\n\t\tif ( RE_UTF16_LOW_SURROGATE.test( ch1 ) ) {\n\t\t\t// Check for an unpaired surrogate at the end of the input string...\n\t\t\tif ( i === 0 ) {\n\t\t\t\t// We found an unpaired surrogate...\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\t// Check whether the high surrogate is paired with a low surrogate...\n\t\t\tch2 = str[ i-1 ];\n\t\t\tif ( RE_UTF16_HIGH_SURROGATE.test( ch2 ) ) {\n\t\t\t\t// We found a surrogate pair:\n\t\t\t\ti -= 1; // bump the index to process the next code unit\n\t\t\t}\n\t\t}\n\t\t// Check whether we've found the desired number of code points...\n\t\tif ( cnt === n ) {\n\t\t\tbreak;\n\t\t}\n\t}\n\treturn str.substring( 0, i );\n}\n\n\n// EXPORTS //\n\nexport default removeLast;\n"],"names":["RE_UTF16_LOW_SURROGATE","RE_UTF16_HIGH_SURROGATE","str","n","ch1","ch2","cnt","i","length","test","substring"],"mappings":";yCAsBA,IAAIA,EAAyB,kBACzBC,EAA0B,yBA4B9B,SAAqBC,EAAKC,GACzB,IACIC,EACAC,EACAC,EACAC,EACJ,GAAW,IAANJ,EACJ,OAAOD,EAMR,IAHAI,EAAM,EAGAC,EAJAL,EAAIM,OAIM,EAAGD,GAAK,EAAGA,IAAM,CAKhC,GAJAH,EAAMF,EAAKK,GACXD,GAAO,EAGFN,EAAuBS,KAAML,GAAQ,CAEzC,GAAW,IAANG,EAEJ,MAGDF,EAAMH,EAAKK,EAAE,GACRN,EAAwBQ,KAAMJ,KAElCE,GAAK,EAEN,CAED,GAAKD,IAAQH,EACZ,KAED,CACD,OAAOD,EAAIQ,UAAW,EAAGH,EAC1B"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 9860da0..0000000 --- a/lib/index.js +++ /dev/null @@ -1,43 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Remove the last `n` Unicode code points of a string. -* -* @module @stdlib/string-base-remove-last-code-point -* -* @example -* var removeLast = require( '@stdlib/string-base-remove-last-code-point' ); -* -* var out = removeLast( 'last man standing', 1 ); -* // returns 'last man standin' -* -* out = removeLast( 'Hidden Treasures', 1 ); -* // returns 'Hidden Treasure'; -*/ - -// 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 fc34187..0000000 --- a/lib/main.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// VARIABLES // - -var RE_UTF16_LOW_SURROGATE = /[\uDC00-\uDFFF]/; // TODO: replace with stdlib pkg -var RE_UTF16_HIGH_SURROGATE = /[\uD800-\uDBFF]/; // TODO: replace with stdlib pkg - - -// MAIN // - -/** -* Removes the last `n` Unicode code points of a string. -* -* @param {string} str - input string -* @param {NonNegativeInteger} n - number of Unicode code points to remove -* @returns {string} output string -* -* @example -* var out = removeLast( 'last man standing', 1 ); -* // returns 'last man standin' -* -* @example -* var out = removeLast( 'presidential election', 1 ); -* // returns 'presidential electio' -* -* @example -* var out = removeLast( 'JavaScript', 1 ); -* // returns 'JavaScrip' -* -* @example -* var out = removeLast( 'Hidden Treasures', 1 ); -* // returns 'Hidden Treasure' -*/ -function removeLast( str, n ) { - var len; - var ch1; - var ch2; - var cnt; - var i; - if ( n === 0 ) { - return str; - } - len = str.length; - cnt = 0; - - // Process the string one Unicode code unit at a time and count UTF-16 surrogate pairs as a single Unicode code point... - for ( i = len - 1; i >= 0; i-- ) { - ch1 = str[ i ]; - cnt += 1; - - // Check for a low UTF-16 surrogate... - if ( RE_UTF16_LOW_SURROGATE.test( ch1 ) ) { - // Check for an unpaired surrogate at the end of the input string... - if ( i === 0 ) { - // We found an unpaired surrogate... - break; - } - // Check whether the high surrogate is paired with a low surrogate... - ch2 = str[ i-1 ]; - if ( RE_UTF16_HIGH_SURROGATE.test( ch2 ) ) { - // We found a surrogate pair: - i -= 1; // bump the index to process the next code unit - } - } - // Check whether we've found the desired number of code points... - if ( cnt === n ) { - break; - } - } - return str.substring( 0, i ); -} - - -// EXPORTS // - -module.exports = removeLast; diff --git a/package.json b/package.json index 508efe9..368c14c 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,7 @@ "version": "0.0.1", "description": "Remove the last Unicode code point of a string.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "main": "./index.js", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,31 +12,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/error-tools-fmtprodmsg": "^0.0.2" - }, - "devDependencies": { - "@stdlib/assert-is-string": "^0.0.8", - "@stdlib/bench": "^0.0.12", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdstring", @@ -81,4 +32,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/stats_browser.html b/stats_browser.html new file mode 100644 index 0000000..d32de91 --- /dev/null +++ b/stats_browser.html @@ -0,0 +1,6177 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/stats_node.html b/stats_node.html new file mode 100644 index 0000000..10601ce --- /dev/null +++ b/stats_node.html @@ -0,0 +1,6177 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/test.js b/test/test.js deleted file mode 100644 index a25545e..0000000 --- a/test/test.js +++ /dev/null @@ -1,108 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var removeLast = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof removeLast, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns an empty string if provided an empty string', function test( t ) { - t.strictEqual( removeLast( '', 1 ), '', 'returns expected value' ); - t.strictEqual( removeLast( '', 2 ), '', 'returns expected value' ); - t.strictEqual( removeLast( '', 3 ), '', 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns the input string if provided zero as the second argument', function test( t ) { - t.strictEqual( removeLast( 'hello world', 0 ), 'hello world', 'returns expected value' ); - t.end(); -}); - -tape( 'the function removes the last Unicode code point of a provided string (ascii)', function test( t ) { - var out; - - out = removeLast( 'hello world', 1 ); - t.strictEqual( out, 'hello worl', 'returns expected value' ); - - out = removeLast( '!!!', 1 ); - t.strictEqual( out, '!!', 'returns expected value' ); - - out = removeLast( 'Hello World', 1 ); - t.strictEqual( out, 'Hello Worl', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function removes the last Unicode code point of a provided string (Unicode)', function test( t ) { - var out; - - out = removeLast( 'अनुच्छेद', 1 ); - t.strictEqual( out, 'अनुच्छे', 'returns expected value' ); - - out = removeLast( '六书/六書', 1 ); - t.strictEqual( out, '六书/六', 'returns expected value' ); - - out = removeLast( '𐒻𐓟', 1 ); - t.strictEqual( out, '𐒻', 'returns expected value' ); - - out = removeLast( '𐒻𐓟', 1 ); - t.strictEqual( out, '𐒻', 'returns expected value' ); - - out = removeLast( '\uDC00', 1 ); - t.strictEqual( out, '', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports removing the last `n` Unicode code points of a provided string', function test( t ) { - var out; - - out = removeLast( 'hello world', 1 ); - t.strictEqual( out, 'hello worl', 'returns expected value' ); - - out = removeLast( 'hello world', 7 ); - t.strictEqual( out, 'hell', 'returns expected value' ); - - out = removeLast( '!!!', 1 ); - t.strictEqual( out, '!!', 'returns expected value' ); - - out = removeLast( '!!!', 2 ); - t.strictEqual( out, '!', 'returns expected value' ); - - out = removeLast( 'अनुच्छेद', 1 ); - t.strictEqual( out, 'अनुच्छे', 'returns expected value' ); - - out = removeLast( '六书/六書', 3 ); - t.strictEqual( out, '六书', 'returns expected value' ); - - out = removeLast( '𐒻𐓟𐓟', 2 ); - t.strictEqual( out, '𐒻', 'returns expected value' ); - - t.end(); -}); From e6b2948e06c3f218b8b051d917b1305fbcb6703f Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 22 Sep 2023 01:48:08 +0000 Subject: [PATCH 06/92] Update README.md for UMD bundle v0.0.1 --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index b5ba4e3..bcc4c42 100644 --- a/README.md +++ b/README.md @@ -44,7 +44,7 @@ limitations under the License. To use in Observable, ```javascript -removeLastCodePoint = require( 'https://cdn.jsdelivr.net/gh/stdlib-js/string-base-remove-last-code-point@umd/browser.js' ) +removeLastCodePoint = require( 'https://cdn.jsdelivr.net/gh/stdlib-js/string-base-remove-last-code-point@v0.0.1-umd/browser.js' ) ``` To vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build: @@ -56,7 +56,7 @@ var removeLastCodePoint = require( 'path/to/vendor/umd/string-base-remove-last-c To include the bundle in a webpage, ```html - + ``` If no recognized module system is present, access bundle contents via the global scope: @@ -101,7 +101,7 @@ out = removeLastCodePoint( 'foo bar', 10 ); - + + ``` If no recognized module system is present, access bundle contents via the global scope: @@ -101,7 +106,7 @@ out = removeLastCodePoint( 'foo bar', 10 ); - + - - - - diff --git a/stats_node.html b/stats_node.html deleted file mode 100644 index 10601ce..0000000 --- a/stats_node.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 5ea627a92012bdb1a23eb0e4081172797969705c Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 22 Sep 2023 03:08:19 +0000 Subject: [PATCH 10/92] Auto-generated commit --- .editorconfig | 186 - .eslintrc.js | 1 - .gitattributes | 49 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 62 - .github/workflows/cancel.yml | 56 - .github/workflows/close_pull_requests.yml | 44 - .github/workflows/examples.yml | 62 - .github/workflows/npm_downloads.yml | 108 - .github/workflows/productionize.yml | 783 --- .github/workflows/publish.yml | 242 - .github/workflows/test.yml | 97 - .github/workflows/test_bundles.yml | 180 - .github/workflows/test_coverage.yml | 123 - .github/workflows/test_install.yml | 83 - .gitignore | 188 - .npmignore | 227 - .npmrc | 28 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 52 +- benchmark/benchmark.js | 56 - branches.md | 53 - browser.js | 3 + browser.js.map | 1 + dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 29 - docs/types/index.d.ts | 53 - docs/types/test.ts | 57 - examples/index.js | 33 - index.js | 3 + index.js.map | 1 + lib/index.js | 43 - lib/main.js | 94 - package.json | 53 +- stats_browser.html | 6177 +++++++++++++++++++++ stats_node.html | 6177 +++++++++++++++++++++ test/test.js | 108 - 43 files changed, 12399 insertions(+), 3710 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md create mode 100644 browser.js create mode 100644 browser.js.map 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/index.d.ts delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js create mode 100644 index.js create mode 100644 index.js.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats_browser.html create mode 100644 stats_node.html delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 13e9c39..0000000 --- a/.editorconfig +++ /dev/null @@ -1,186 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 52cd9c4..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/base/remove-last-code-point) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 cc028ca..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/base/remove-last-code-point) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 fcbf6f1..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: '29 5 * * 0' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - uses: actions/upload-artifact@v3 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - uses: distributhor/workflow-webhook@v3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 91f2b93..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,783 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - uses: actions/checkout@v3 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - uses: actions/checkout@v3 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - uses: act10ns/slack@v2 - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n +``` + +If no recognized module system is present, access bundle contents via the global scope: + +```html + ``` #### removeLastCodePoint( str, n ) @@ -89,8 +97,13 @@ out = removeLastCodePoint( 'foo bar', 10 ); -```javascript -var removeLastCodePoint = require( '@stdlib/string-base-remove-last-code-point' ); +```html + + + + + + + ```
diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index d846d34..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,56 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var removeLast = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var values; - var out; - var i; - - values = [ - 'beep boop', - 'foo bar', - 'xyz abc', - '🐶🐮🐷🐰🐸' - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = removeLast( values[ i%values.length ], 1 ); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( !isString( out ) ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 41f4db9..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/base/remove-last-code-point" -%% click B href "https://github.com/stdlib-js/string-base-remove-last-code-point/tree/main" -%% click C href "https://github.com/stdlib-js/string-base-remove-last-code-point/tree/production" -%% click D href "https://github.com/stdlib-js/string-base-remove-last-code-point/tree/esm" -%% click E href "https://github.com/stdlib-js/string-base-remove-last-code-point/tree/deno" -%% click F href "https://github.com/stdlib-js/string-base-remove-last-code-point/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/base/remove-last-code-point -[production-url]: https://github.com/stdlib-js/string-base-remove-last-code-point/tree/production -[deno-url]: https://github.com/stdlib-js/string-base-remove-last-code-point/tree/deno -[umd-url]: https://github.com/stdlib-js/string-base-remove-last-code-point/tree/umd -[esm-url]: https://github.com/stdlib-js/string-base-remove-last-code-point/tree/esm \ No newline at end of file diff --git a/browser.js b/browser.js new file mode 100644 index 0000000..d3e0f5b --- /dev/null +++ b/browser.js @@ -0,0 +1,3 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +var e,t;e=this,t=function(){"use strict";var e=/[\uDC00-\uDFFF]/,t=/[\uD800-\uDBFF]/;return function(n,f){var i,o,r,u;if(0===f)return n;for(r=0,u=n.length-1;u>=0;u--){if(i=n[u],r+=1,e.test(i)){if(0===u)break;o=n[u-1],t.test(o)&&(u-=1)}if(r===f)break}return n.substring(0,u)}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).removeLastCodePoint=t(); +//# sourceMappingURL=browser.js.map diff --git a/browser.js.map b/browser.js.map new file mode 100644 index 0000000..19908eb --- /dev/null +++ b/browser.js.map @@ -0,0 +1 @@ +{"version":3,"file":"browser.js","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\nvar RE_UTF16_LOW_SURROGATE = /[\\uDC00-\\uDFFF]/; // TODO: replace with stdlib pkg\nvar RE_UTF16_HIGH_SURROGATE = /[\\uD800-\\uDBFF]/; // TODO: replace with stdlib pkg\n\n\n// MAIN //\n\n/**\n* Removes the last `n` Unicode code points of a string.\n*\n* @param {string} str - input string\n* @param {NonNegativeInteger} n - number of Unicode code points to remove\n* @returns {string} output string\n*\n* @example\n* var out = removeLast( 'last man standing', 1 );\n* // returns 'last man standin'\n*\n* @example\n* var out = removeLast( 'presidential election', 1 );\n* // returns 'presidential electio'\n*\n* @example\n* var out = removeLast( 'JavaScript', 1 );\n* // returns 'JavaScrip'\n*\n* @example\n* var out = removeLast( 'Hidden Treasures', 1 );\n* // returns 'Hidden Treasure'\n*/\nfunction removeLast( str, n ) {\n\tvar len;\n\tvar ch1;\n\tvar ch2;\n\tvar cnt;\n\tvar i;\n\tif ( n === 0 ) {\n\t\treturn str;\n\t}\n\tlen = str.length;\n\tcnt = 0;\n\n\t// Process the string one Unicode code unit at a time and count UTF-16 surrogate pairs as a single Unicode code point...\n\tfor ( i = len - 1; i >= 0; i-- ) {\n\t\tch1 = str[ i ];\n\t\tcnt += 1;\n\n\t\t// Check for a low UTF-16 surrogate...\n\t\tif ( RE_UTF16_LOW_SURROGATE.test( ch1 ) ) {\n\t\t\t// Check for an unpaired surrogate at the end of the input string...\n\t\t\tif ( i === 0 ) {\n\t\t\t\t// We found an unpaired surrogate...\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\t// Check whether the high surrogate is paired with a low surrogate...\n\t\t\tch2 = str[ i-1 ];\n\t\t\tif ( RE_UTF16_HIGH_SURROGATE.test( ch2 ) ) {\n\t\t\t\t// We found a surrogate pair:\n\t\t\t\ti -= 1; // bump the index to process the next code unit\n\t\t\t}\n\t\t}\n\t\t// Check whether we've found the desired number of code points...\n\t\tif ( cnt === n ) {\n\t\t\tbreak;\n\t\t}\n\t}\n\treturn str.substring( 0, i );\n}\n\n\n// EXPORTS //\n\nexport default removeLast;\n"],"names":["RE_UTF16_LOW_SURROGATE","RE_UTF16_HIGH_SURROGATE","str","n","ch1","ch2","cnt","i","length","test","substring"],"mappings":";yCAsBA,IAAIA,EAAyB,kBACzBC,EAA0B,yBA4B9B,SAAqBC,EAAKC,GACzB,IACIC,EACAC,EACAC,EACAC,EACJ,GAAW,IAANJ,EACJ,OAAOD,EAMR,IAHAI,EAAM,EAGAC,EAJAL,EAAIM,OAIM,EAAGD,GAAK,EAAGA,IAAM,CAKhC,GAJAH,EAAMF,EAAKK,GACXD,GAAO,EAGFN,EAAuBS,KAAML,GAAQ,CAEzC,GAAW,IAANG,EAEJ,MAGDF,EAAMH,EAAKK,EAAE,GACRN,EAAwBQ,KAAMJ,KAElCE,GAAK,EAEN,CAED,GAAKD,IAAQH,EACZ,KAED,CACD,OAAOD,EAAIQ,UAAW,EAAGH,EAC1B"} \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index 8c96fd7..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import removeLast from '../docs/types/index'; -export = removeLast; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index e6b7220..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var s=function(e,t){return function(){return t||e((t={exports:{}}).exports,t),t.exports}};var f=s(function(D,n){ -var F=/[\uDC00-\uDFFF]/,c=/[\uD800-\uDBFF]/;function R(e,t){var i,u,v,a,r;if(t===0)return e;for(i=e.length,a=0,r=i-1;r>=0;r--){if(u=e[r],a+=1,F.test(u)){if(r===0)break;v=e[r-1],c.test(v)&&(r-=1)}if(a===t)break}return e.substring(0,r)}n.exports=R -});var _=f();module.exports=_; -/** @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 72561cf..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\nvar RE_UTF16_LOW_SURROGATE = /[\\uDC00-\\uDFFF]/; // TODO: replace with stdlib pkg\nvar RE_UTF16_HIGH_SURROGATE = /[\\uD800-\\uDBFF]/; // TODO: replace with stdlib pkg\n\n\n// MAIN //\n\n/**\n* Removes the last `n` Unicode code points of a string.\n*\n* @param {string} str - input string\n* @param {NonNegativeInteger} n - number of Unicode code points to remove\n* @returns {string} output string\n*\n* @example\n* var out = removeLast( 'last man standing', 1 );\n* // returns 'last man standin'\n*\n* @example\n* var out = removeLast( 'presidential election', 1 );\n* // returns 'presidential electio'\n*\n* @example\n* var out = removeLast( 'JavaScript', 1 );\n* // returns 'JavaScrip'\n*\n* @example\n* var out = removeLast( 'Hidden Treasures', 1 );\n* // returns 'Hidden Treasure'\n*/\nfunction removeLast( str, n ) {\n\tvar len;\n\tvar ch1;\n\tvar ch2;\n\tvar cnt;\n\tvar i;\n\tif ( n === 0 ) {\n\t\treturn str;\n\t}\n\tlen = str.length;\n\tcnt = 0;\n\n\t// Process the string one Unicode code unit at a time and count UTF-16 surrogate pairs as a single Unicode code point...\n\tfor ( i = len - 1; i >= 0; i-- ) {\n\t\tch1 = str[ i ];\n\t\tcnt += 1;\n\n\t\t// Check for a low UTF-16 surrogate...\n\t\tif ( RE_UTF16_LOW_SURROGATE.test( ch1 ) ) {\n\t\t\t// Check for an unpaired surrogate at the end of the input string...\n\t\t\tif ( i === 0 ) {\n\t\t\t\t// We found an unpaired surrogate...\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\t// Check whether the high surrogate is paired with a low surrogate...\n\t\t\tch2 = str[ i-1 ];\n\t\t\tif ( RE_UTF16_HIGH_SURROGATE.test( ch2 ) ) {\n\t\t\t\t// We found a surrogate pair:\n\t\t\t\ti -= 1; // bump the index to process the next code unit\n\t\t\t}\n\t\t}\n\t\t// Check whether we've found the desired number of code points...\n\t\tif ( cnt === n ) {\n\t\t\tbreak;\n\t\t}\n\t}\n\treturn str.substring( 0, i );\n}\n\n\n// EXPORTS //\n\nmodule.exports = removeLast;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Remove the last `n` Unicode code points of a string.\n*\n* @module @stdlib/string-base-remove-last-code-point\n*\n* @example\n* var removeLast = require( '@stdlib/string-base-remove-last-code-point' );\n*\n* var out = removeLast( 'last man standing', 1 );\n* // returns 'last man standin'\n*\n* out = removeLast( 'Hidden Treasures', 1 );\n* // returns 'Hidden Treasure';\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,EAAyB,kBACzBC,EAA0B,kBA4B9B,SAASC,EAAYC,EAAKC,EAAI,CAC7B,IAAIC,EACAC,EACAC,EACAC,EACAC,EACJ,GAAKL,IAAM,EACV,OAAOD,EAMR,IAJAE,EAAMF,EAAI,OACVK,EAAM,EAGAC,EAAIJ,EAAM,EAAGI,GAAK,EAAGA,IAAM,CAKhC,GAJAH,EAAMH,EAAKM,CAAE,EACbD,GAAO,EAGFR,EAAuB,KAAMM,CAAI,EAAI,CAEzC,GAAKG,IAAM,EAEV,MAGDF,EAAMJ,EAAKM,EAAE,CAAE,EACVR,EAAwB,KAAMM,CAAI,IAEtCE,GAAK,EAEP,CAEA,GAAKD,IAAQJ,EACZ,KAEF,CACA,OAAOD,EAAI,UAAW,EAAGM,CAAE,CAC5B,CAKAV,EAAO,QAAUG,ICxDjB,IAAIQ,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "RE_UTF16_LOW_SURROGATE", "RE_UTF16_HIGH_SURROGATE", "removeLast", "str", "n", "len", "ch1", "ch2", "cnt", "i", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index a08ea55..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,29 +0,0 @@ - -{{alias}}( str, n ) - Removes the last `n` Unicode code points of a string. - - Parameters - ---------- - str: string - Input string. - - n: integer - Number of Unicode code points to remove. - - Returns - ------- - out: string - Output string. - - Examples - -------- - > var out = {{alias}}( 'beep', 1 ) - 'bee' - > out = {{alias}}( 'Boop', 1 ) - 'Boo' - > out = {{alias}}( 'foo bar', 5 ) - 'fo' - - See Also - -------- - diff --git a/docs/types/index.d.ts b/docs/types/index.d.ts deleted file mode 100644 index 8a1c90b..0000000 --- a/docs/types/index.d.ts +++ /dev/null @@ -1,53 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 - -/** -* Removes the last `n` Unicode code points of a string. -* -* @param str - input string -* @param n - number of code points to remove -* @returns output string -* -* @example -* var out = removeLast( 'last man standing', 1 ); -* // returns 'last man standin' -* -* @example -* var out = removeLast( 'presidential election', 1 ); -* // returns 'presidential electio' -* -* @example -* var out = removeLast( 'JavaScript', 1 ); -* // returns 'JavaScrip' -* -* @example -* var out = removeLast( 'Hidden Treasures', 1 ); -* // returns 'Hidden Treasure' -* -* @example -* var out = removeLast( 'foo bar', 5 ); -* // returns 'fo' -*/ -declare function removeLast( str: string, n: number ): string; - - -// EXPORTS // - -export = removeLast; diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index fd426d2..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,57 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 removeLast = require( './index' ); - - -// TESTS // - -// The function returns a string... -{ - removeLast( 'abc', 1 ); // $ExpectType string -} - -// The compiler throws an error if the function is provided a value other than a string... -{ - removeLast( true, 1 ); // $ExpectError - removeLast( false, 1 ); // $ExpectError - removeLast( null, 1 ); // $ExpectError - removeLast( undefined, 1 ); // $ExpectError - removeLast( 5, 1 ); // $ExpectError - removeLast( [], 1 ); // $ExpectError - removeLast( {}, 1 ); // $ExpectError - removeLast( ( x: number ): number => x, 1 ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument that is not a number... -{ - removeLast( 'abc', true ); // $ExpectError - removeLast( 'abc', false ); // $ExpectError - removeLast( 'abc', null ); // $ExpectError - removeLast( 'abc', 'abc' ); // $ExpectError - removeLast( 'abc', [] ); // $ExpectError - removeLast( 'abc', {} ); // $ExpectError - removeLast( 'abc', ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - removeLast(); // $ExpectError - removeLast( 'abc' ); // $ExpectError - removeLast( 'abc', 1, 2 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 085633e..0000000 --- a/examples/index.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var removeLastCodePoint = require( './../lib' ); - -console.log( removeLastCodePoint( 'presidential election', 1 ) ); -// => 'presidential electio' - -console.log( removeLastCodePoint( 'JavaScript', 1 ) ); -// => 'JavaScrip' - -console.log( removeLastCodePoint( 'The Last of the Mohicans', 5 ) ); -// => 'The Last of the Moh' - -console.log( removeLastCodePoint( 'अनुच्छेद', 1 ) ); -// => 'अनुच्छे' diff --git a/index.js b/index.js new file mode 100644 index 0000000..0185898 --- /dev/null +++ b/index.js @@ -0,0 +1,3 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +var e,t;e=this,t=function(){"use strict";var e=/[\uDC00-\uDFFF]/,t=/[\uD800-\uDBFF]/;return function(n,f){var i,o,r,u;if(0===f)return n;for(r=0,u=n.length-1;u>=0;u--){if(i=n[u],r+=1,e.test(i)){if(0===u)break;o=n[u-1],t.test(o)&&(u-=1)}if(r===f)break}return n.substring(0,u)}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).removeLastCodePoint=t(); +//# sourceMappingURL=index.js.map diff --git a/index.js.map b/index.js.map new file mode 100644 index 0000000..d557af8 --- /dev/null +++ b/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\nvar RE_UTF16_LOW_SURROGATE = /[\\uDC00-\\uDFFF]/; // TODO: replace with stdlib pkg\nvar RE_UTF16_HIGH_SURROGATE = /[\\uD800-\\uDBFF]/; // TODO: replace with stdlib pkg\n\n\n// MAIN //\n\n/**\n* Removes the last `n` Unicode code points of a string.\n*\n* @param {string} str - input string\n* @param {NonNegativeInteger} n - number of Unicode code points to remove\n* @returns {string} output string\n*\n* @example\n* var out = removeLast( 'last man standing', 1 );\n* // returns 'last man standin'\n*\n* @example\n* var out = removeLast( 'presidential election', 1 );\n* // returns 'presidential electio'\n*\n* @example\n* var out = removeLast( 'JavaScript', 1 );\n* // returns 'JavaScrip'\n*\n* @example\n* var out = removeLast( 'Hidden Treasures', 1 );\n* // returns 'Hidden Treasure'\n*/\nfunction removeLast( str, n ) {\n\tvar len;\n\tvar ch1;\n\tvar ch2;\n\tvar cnt;\n\tvar i;\n\tif ( n === 0 ) {\n\t\treturn str;\n\t}\n\tlen = str.length;\n\tcnt = 0;\n\n\t// Process the string one Unicode code unit at a time and count UTF-16 surrogate pairs as a single Unicode code point...\n\tfor ( i = len - 1; i >= 0; i-- ) {\n\t\tch1 = str[ i ];\n\t\tcnt += 1;\n\n\t\t// Check for a low UTF-16 surrogate...\n\t\tif ( RE_UTF16_LOW_SURROGATE.test( ch1 ) ) {\n\t\t\t// Check for an unpaired surrogate at the end of the input string...\n\t\t\tif ( i === 0 ) {\n\t\t\t\t// We found an unpaired surrogate...\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\t// Check whether the high surrogate is paired with a low surrogate...\n\t\t\tch2 = str[ i-1 ];\n\t\t\tif ( RE_UTF16_HIGH_SURROGATE.test( ch2 ) ) {\n\t\t\t\t// We found a surrogate pair:\n\t\t\t\ti -= 1; // bump the index to process the next code unit\n\t\t\t}\n\t\t}\n\t\t// Check whether we've found the desired number of code points...\n\t\tif ( cnt === n ) {\n\t\t\tbreak;\n\t\t}\n\t}\n\treturn str.substring( 0, i );\n}\n\n\n// EXPORTS //\n\nexport default removeLast;\n"],"names":["RE_UTF16_LOW_SURROGATE","RE_UTF16_HIGH_SURROGATE","str","n","ch1","ch2","cnt","i","length","test","substring"],"mappings":";yCAsBA,IAAIA,EAAyB,kBACzBC,EAA0B,yBA4B9B,SAAqBC,EAAKC,GACzB,IACIC,EACAC,EACAC,EACAC,EACJ,GAAW,IAANJ,EACJ,OAAOD,EAMR,IAHAI,EAAM,EAGAC,EAJAL,EAAIM,OAIM,EAAGD,GAAK,EAAGA,IAAM,CAKhC,GAJAH,EAAMF,EAAKK,GACXD,GAAO,EAGFN,EAAuBS,KAAML,GAAQ,CAEzC,GAAW,IAANG,EAEJ,MAGDF,EAAMH,EAAKK,EAAE,GACRN,EAAwBQ,KAAMJ,KAElCE,GAAK,EAEN,CAED,GAAKD,IAAQH,EACZ,KAED,CACD,OAAOD,EAAIQ,UAAW,EAAGH,EAC1B"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 9860da0..0000000 --- a/lib/index.js +++ /dev/null @@ -1,43 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Remove the last `n` Unicode code points of a string. -* -* @module @stdlib/string-base-remove-last-code-point -* -* @example -* var removeLast = require( '@stdlib/string-base-remove-last-code-point' ); -* -* var out = removeLast( 'last man standing', 1 ); -* // returns 'last man standin' -* -* out = removeLast( 'Hidden Treasures', 1 ); -* // returns 'Hidden Treasure'; -*/ - -// 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 fc34187..0000000 --- a/lib/main.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// VARIABLES // - -var RE_UTF16_LOW_SURROGATE = /[\uDC00-\uDFFF]/; // TODO: replace with stdlib pkg -var RE_UTF16_HIGH_SURROGATE = /[\uD800-\uDBFF]/; // TODO: replace with stdlib pkg - - -// MAIN // - -/** -* Removes the last `n` Unicode code points of a string. -* -* @param {string} str - input string -* @param {NonNegativeInteger} n - number of Unicode code points to remove -* @returns {string} output string -* -* @example -* var out = removeLast( 'last man standing', 1 ); -* // returns 'last man standin' -* -* @example -* var out = removeLast( 'presidential election', 1 ); -* // returns 'presidential electio' -* -* @example -* var out = removeLast( 'JavaScript', 1 ); -* // returns 'JavaScrip' -* -* @example -* var out = removeLast( 'Hidden Treasures', 1 ); -* // returns 'Hidden Treasure' -*/ -function removeLast( str, n ) { - var len; - var ch1; - var ch2; - var cnt; - var i; - if ( n === 0 ) { - return str; - } - len = str.length; - cnt = 0; - - // Process the string one Unicode code unit at a time and count UTF-16 surrogate pairs as a single Unicode code point... - for ( i = len - 1; i >= 0; i-- ) { - ch1 = str[ i ]; - cnt += 1; - - // Check for a low UTF-16 surrogate... - if ( RE_UTF16_LOW_SURROGATE.test( ch1 ) ) { - // Check for an unpaired surrogate at the end of the input string... - if ( i === 0 ) { - // We found an unpaired surrogate... - break; - } - // Check whether the high surrogate is paired with a low surrogate... - ch2 = str[ i-1 ]; - if ( RE_UTF16_HIGH_SURROGATE.test( ch2 ) ) { - // We found a surrogate pair: - i -= 1; // bump the index to process the next code unit - } - } - // Check whether we've found the desired number of code points... - if ( cnt === n ) { - break; - } - } - return str.substring( 0, i ); -} - - -// EXPORTS // - -module.exports = removeLast; diff --git a/package.json b/package.json index 6f15a25..aae81be 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,7 @@ "version": "0.1.0", "description": "Remove the last Unicode code point of a string.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "main": "./index.js", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,31 +12,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/error-tools-fmtprodmsg": "^0.0.2" - }, - "devDependencies": { - "@stdlib/assert-is-string": "^0.0.8", - "@stdlib/bench": "^0.0.12", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdstring", @@ -81,4 +32,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/stats_browser.html b/stats_browser.html new file mode 100644 index 0000000..87f4b01 --- /dev/null +++ b/stats_browser.html @@ -0,0 +1,6177 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/stats_node.html b/stats_node.html new file mode 100644 index 0000000..d4c95c2 --- /dev/null +++ b/stats_node.html @@ -0,0 +1,6177 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/test.js b/test/test.js deleted file mode 100644 index a25545e..0000000 --- a/test/test.js +++ /dev/null @@ -1,108 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var removeLast = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof removeLast, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns an empty string if provided an empty string', function test( t ) { - t.strictEqual( removeLast( '', 1 ), '', 'returns expected value' ); - t.strictEqual( removeLast( '', 2 ), '', 'returns expected value' ); - t.strictEqual( removeLast( '', 3 ), '', 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns the input string if provided zero as the second argument', function test( t ) { - t.strictEqual( removeLast( 'hello world', 0 ), 'hello world', 'returns expected value' ); - t.end(); -}); - -tape( 'the function removes the last Unicode code point of a provided string (ascii)', function test( t ) { - var out; - - out = removeLast( 'hello world', 1 ); - t.strictEqual( out, 'hello worl', 'returns expected value' ); - - out = removeLast( '!!!', 1 ); - t.strictEqual( out, '!!', 'returns expected value' ); - - out = removeLast( 'Hello World', 1 ); - t.strictEqual( out, 'Hello Worl', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function removes the last Unicode code point of a provided string (Unicode)', function test( t ) { - var out; - - out = removeLast( 'अनुच्छेद', 1 ); - t.strictEqual( out, 'अनुच्छे', 'returns expected value' ); - - out = removeLast( '六书/六書', 1 ); - t.strictEqual( out, '六书/六', 'returns expected value' ); - - out = removeLast( '𐒻𐓟', 1 ); - t.strictEqual( out, '𐒻', 'returns expected value' ); - - out = removeLast( '𐒻𐓟', 1 ); - t.strictEqual( out, '𐒻', 'returns expected value' ); - - out = removeLast( '\uDC00', 1 ); - t.strictEqual( out, '', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports removing the last `n` Unicode code points of a provided string', function test( t ) { - var out; - - out = removeLast( 'hello world', 1 ); - t.strictEqual( out, 'hello worl', 'returns expected value' ); - - out = removeLast( 'hello world', 7 ); - t.strictEqual( out, 'hell', 'returns expected value' ); - - out = removeLast( '!!!', 1 ); - t.strictEqual( out, '!!', 'returns expected value' ); - - out = removeLast( '!!!', 2 ); - t.strictEqual( out, '!', 'returns expected value' ); - - out = removeLast( 'अनुच्छेद', 1 ); - t.strictEqual( out, 'अनुच्छे', 'returns expected value' ); - - out = removeLast( '六书/六書', 3 ); - t.strictEqual( out, '六书', 'returns expected value' ); - - out = removeLast( '𐒻𐓟𐓟', 2 ); - t.strictEqual( out, '𐒻', 'returns expected value' ); - - t.end(); -}); From 21dd65a87d6af493fd6116c369d40b605df0bcbc Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 22 Sep 2023 03:12:06 +0000 Subject: [PATCH 11/92] Update README.md for UMD bundle v0.1.0 --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index cb6e7c0..c1f7eb9 100644 --- a/README.md +++ b/README.md @@ -44,7 +44,7 @@ limitations under the License. To use in Observable, ```javascript -removeLastCodePoint = require( 'https://cdn.jsdelivr.net/gh/stdlib-js/string-base-remove-last-code-point@umd/browser.js' ) +removeLastCodePoint = require( 'https://cdn.jsdelivr.net/gh/stdlib-js/string-base-remove-last-code-point@v0.1.0-umd/browser.js' ) ``` To vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build: @@ -56,7 +56,7 @@ var removeLastCodePoint = require( 'path/to/vendor/umd/string-base-remove-last-c To include the bundle in a webpage, ```html - + ``` If no recognized module system is present, access bundle contents via the global scope: @@ -101,7 +101,7 @@ out = removeLastCodePoint( 'foo bar', 10 ); - + + ``` If no recognized module system is present, access bundle contents via the global scope: @@ -101,7 +106,7 @@ out = removeLastCodePoint( 'foo bar', 10 ); - + - - - - diff --git a/stats_node.html b/stats_node.html deleted file mode 100644 index d4c95c2..0000000 --- a/stats_node.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From bf61bd97399db04ecbcbf3be1c007c05d21247af Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Oct 2023 00:41:03 +0000 Subject: [PATCH 15/92] Auto-generated commit --- .editorconfig | 186 - .eslintrc.js | 1 - .gitattributes | 49 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 797 --- .github/workflows/publish.yml | 247 - .github/workflows/test.yml | 100 - .github/workflows/test_bundles.yml | 189 - .github/workflows/test_coverage.yml | 128 - .github/workflows/test_install.yml | 86 - .gitignore | 188 - .npmignore | 227 - .npmrc | 28 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 52 +- benchmark/benchmark.js | 56 - branches.md | 53 - browser.js | 3 + browser.js.map | 1 + dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 29 - docs/types/index.d.ts | 53 - docs/types/test.ts | 57 - examples/index.js | 33 - index.js | 3 + index.js.map | 1 + lib/index.js | 43 - lib/main.js | 94 - package.json | 53 +- stats_browser.html | 6177 +++++++++++++++++++++ stats_node.html | 6177 +++++++++++++++++++++ test/dist/test.js | 108 - test/test.js | 108 - 45 files changed, 12399 insertions(+), 3877 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md create mode 100644 browser.js create mode 100644 browser.js.map 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/index.d.ts delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js create mode 100644 index.js create mode 100644 index.js.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats_browser.html create mode 100644 stats_node.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 13e9c39..0000000 --- a/.editorconfig +++ /dev/null @@ -1,186 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index d8364de..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-10-01T00:31:28.447Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 52cd9c4..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/base/remove-last-code-point) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 533eeee..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/base/remove-last-code-point) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 33382c1..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: '29 5 * * 0' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA corresponding to v3.1.3 - uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA corresponding to v3.0.3: - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 265afda..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,797 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA corresponding to v2.0.0 - uses: act10ns/slack@ed1309ab9862e57e9e583e51c7889486b9a00b0f - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n +``` + +If no recognized module system is present, access bundle contents via the global scope: + +```html + ``` #### removeLastCodePoint( str, n ) @@ -89,8 +97,13 @@ out = removeLastCodePoint( 'foo bar', 10 ); -```javascript -var removeLastCodePoint = require( '@stdlib/string-base-remove-last-code-point' ); +```html + + + + + + + ```
diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index d846d34..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,56 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var removeLast = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var values; - var out; - var i; - - values = [ - 'beep boop', - 'foo bar', - 'xyz abc', - '🐶🐮🐷🐰🐸' - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = removeLast( values[ i%values.length ], 1 ); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( !isString( out ) ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 41f4db9..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/base/remove-last-code-point" -%% click B href "https://github.com/stdlib-js/string-base-remove-last-code-point/tree/main" -%% click C href "https://github.com/stdlib-js/string-base-remove-last-code-point/tree/production" -%% click D href "https://github.com/stdlib-js/string-base-remove-last-code-point/tree/esm" -%% click E href "https://github.com/stdlib-js/string-base-remove-last-code-point/tree/deno" -%% click F href "https://github.com/stdlib-js/string-base-remove-last-code-point/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/base/remove-last-code-point -[production-url]: https://github.com/stdlib-js/string-base-remove-last-code-point/tree/production -[deno-url]: https://github.com/stdlib-js/string-base-remove-last-code-point/tree/deno -[umd-url]: https://github.com/stdlib-js/string-base-remove-last-code-point/tree/umd -[esm-url]: https://github.com/stdlib-js/string-base-remove-last-code-point/tree/esm \ No newline at end of file diff --git a/browser.js b/browser.js new file mode 100644 index 0000000..d3e0f5b --- /dev/null +++ b/browser.js @@ -0,0 +1,3 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +var e,t;e=this,t=function(){"use strict";var e=/[\uDC00-\uDFFF]/,t=/[\uD800-\uDBFF]/;return function(n,f){var i,o,r,u;if(0===f)return n;for(r=0,u=n.length-1;u>=0;u--){if(i=n[u],r+=1,e.test(i)){if(0===u)break;o=n[u-1],t.test(o)&&(u-=1)}if(r===f)break}return n.substring(0,u)}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).removeLastCodePoint=t(); +//# sourceMappingURL=browser.js.map diff --git a/browser.js.map b/browser.js.map new file mode 100644 index 0000000..19908eb --- /dev/null +++ b/browser.js.map @@ -0,0 +1 @@ +{"version":3,"file":"browser.js","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\nvar RE_UTF16_LOW_SURROGATE = /[\\uDC00-\\uDFFF]/; // TODO: replace with stdlib pkg\nvar RE_UTF16_HIGH_SURROGATE = /[\\uD800-\\uDBFF]/; // TODO: replace with stdlib pkg\n\n\n// MAIN //\n\n/**\n* Removes the last `n` Unicode code points of a string.\n*\n* @param {string} str - input string\n* @param {NonNegativeInteger} n - number of Unicode code points to remove\n* @returns {string} output string\n*\n* @example\n* var out = removeLast( 'last man standing', 1 );\n* // returns 'last man standin'\n*\n* @example\n* var out = removeLast( 'presidential election', 1 );\n* // returns 'presidential electio'\n*\n* @example\n* var out = removeLast( 'JavaScript', 1 );\n* // returns 'JavaScrip'\n*\n* @example\n* var out = removeLast( 'Hidden Treasures', 1 );\n* // returns 'Hidden Treasure'\n*/\nfunction removeLast( str, n ) {\n\tvar len;\n\tvar ch1;\n\tvar ch2;\n\tvar cnt;\n\tvar i;\n\tif ( n === 0 ) {\n\t\treturn str;\n\t}\n\tlen = str.length;\n\tcnt = 0;\n\n\t// Process the string one Unicode code unit at a time and count UTF-16 surrogate pairs as a single Unicode code point...\n\tfor ( i = len - 1; i >= 0; i-- ) {\n\t\tch1 = str[ i ];\n\t\tcnt += 1;\n\n\t\t// Check for a low UTF-16 surrogate...\n\t\tif ( RE_UTF16_LOW_SURROGATE.test( ch1 ) ) {\n\t\t\t// Check for an unpaired surrogate at the end of the input string...\n\t\t\tif ( i === 0 ) {\n\t\t\t\t// We found an unpaired surrogate...\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\t// Check whether the high surrogate is paired with a low surrogate...\n\t\t\tch2 = str[ i-1 ];\n\t\t\tif ( RE_UTF16_HIGH_SURROGATE.test( ch2 ) ) {\n\t\t\t\t// We found a surrogate pair:\n\t\t\t\ti -= 1; // bump the index to process the next code unit\n\t\t\t}\n\t\t}\n\t\t// Check whether we've found the desired number of code points...\n\t\tif ( cnt === n ) {\n\t\t\tbreak;\n\t\t}\n\t}\n\treturn str.substring( 0, i );\n}\n\n\n// EXPORTS //\n\nexport default removeLast;\n"],"names":["RE_UTF16_LOW_SURROGATE","RE_UTF16_HIGH_SURROGATE","str","n","ch1","ch2","cnt","i","length","test","substring"],"mappings":";yCAsBA,IAAIA,EAAyB,kBACzBC,EAA0B,yBA4B9B,SAAqBC,EAAKC,GACzB,IACIC,EACAC,EACAC,EACAC,EACJ,GAAW,IAANJ,EACJ,OAAOD,EAMR,IAHAI,EAAM,EAGAC,EAJAL,EAAIM,OAIM,EAAGD,GAAK,EAAGA,IAAM,CAKhC,GAJAH,EAAMF,EAAKK,GACXD,GAAO,EAGFN,EAAuBS,KAAML,GAAQ,CAEzC,GAAW,IAANG,EAEJ,MAGDF,EAAMH,EAAKK,EAAE,GACRN,EAAwBQ,KAAMJ,KAElCE,GAAK,EAEN,CAED,GAAKD,IAAQH,EACZ,KAED,CACD,OAAOD,EAAIQ,UAAW,EAAGH,EAC1B"} \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index 8c96fd7..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import removeLast from '../docs/types/index'; -export = removeLast; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index e6b7220..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var s=function(e,t){return function(){return t||e((t={exports:{}}).exports,t),t.exports}};var f=s(function(D,n){ -var F=/[\uDC00-\uDFFF]/,c=/[\uD800-\uDBFF]/;function R(e,t){var i,u,v,a,r;if(t===0)return e;for(i=e.length,a=0,r=i-1;r>=0;r--){if(u=e[r],a+=1,F.test(u)){if(r===0)break;v=e[r-1],c.test(v)&&(r-=1)}if(a===t)break}return e.substring(0,r)}n.exports=R -});var _=f();module.exports=_; -/** @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 72561cf..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\nvar RE_UTF16_LOW_SURROGATE = /[\\uDC00-\\uDFFF]/; // TODO: replace with stdlib pkg\nvar RE_UTF16_HIGH_SURROGATE = /[\\uD800-\\uDBFF]/; // TODO: replace with stdlib pkg\n\n\n// MAIN //\n\n/**\n* Removes the last `n` Unicode code points of a string.\n*\n* @param {string} str - input string\n* @param {NonNegativeInteger} n - number of Unicode code points to remove\n* @returns {string} output string\n*\n* @example\n* var out = removeLast( 'last man standing', 1 );\n* // returns 'last man standin'\n*\n* @example\n* var out = removeLast( 'presidential election', 1 );\n* // returns 'presidential electio'\n*\n* @example\n* var out = removeLast( 'JavaScript', 1 );\n* // returns 'JavaScrip'\n*\n* @example\n* var out = removeLast( 'Hidden Treasures', 1 );\n* // returns 'Hidden Treasure'\n*/\nfunction removeLast( str, n ) {\n\tvar len;\n\tvar ch1;\n\tvar ch2;\n\tvar cnt;\n\tvar i;\n\tif ( n === 0 ) {\n\t\treturn str;\n\t}\n\tlen = str.length;\n\tcnt = 0;\n\n\t// Process the string one Unicode code unit at a time and count UTF-16 surrogate pairs as a single Unicode code point...\n\tfor ( i = len - 1; i >= 0; i-- ) {\n\t\tch1 = str[ i ];\n\t\tcnt += 1;\n\n\t\t// Check for a low UTF-16 surrogate...\n\t\tif ( RE_UTF16_LOW_SURROGATE.test( ch1 ) ) {\n\t\t\t// Check for an unpaired surrogate at the end of the input string...\n\t\t\tif ( i === 0 ) {\n\t\t\t\t// We found an unpaired surrogate...\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\t// Check whether the high surrogate is paired with a low surrogate...\n\t\t\tch2 = str[ i-1 ];\n\t\t\tif ( RE_UTF16_HIGH_SURROGATE.test( ch2 ) ) {\n\t\t\t\t// We found a surrogate pair:\n\t\t\t\ti -= 1; // bump the index to process the next code unit\n\t\t\t}\n\t\t}\n\t\t// Check whether we've found the desired number of code points...\n\t\tif ( cnt === n ) {\n\t\t\tbreak;\n\t\t}\n\t}\n\treturn str.substring( 0, i );\n}\n\n\n// EXPORTS //\n\nmodule.exports = removeLast;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Remove the last `n` Unicode code points of a string.\n*\n* @module @stdlib/string-base-remove-last-code-point\n*\n* @example\n* var removeLast = require( '@stdlib/string-base-remove-last-code-point' );\n*\n* var out = removeLast( 'last man standing', 1 );\n* // returns 'last man standin'\n*\n* out = removeLast( 'Hidden Treasures', 1 );\n* // returns 'Hidden Treasure';\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,EAAyB,kBACzBC,EAA0B,kBA4B9B,SAASC,EAAYC,EAAKC,EAAI,CAC7B,IAAIC,EACAC,EACAC,EACAC,EACAC,EACJ,GAAKL,IAAM,EACV,OAAOD,EAMR,IAJAE,EAAMF,EAAI,OACVK,EAAM,EAGAC,EAAIJ,EAAM,EAAGI,GAAK,EAAGA,IAAM,CAKhC,GAJAH,EAAMH,EAAKM,CAAE,EACbD,GAAO,EAGFR,EAAuB,KAAMM,CAAI,EAAI,CAEzC,GAAKG,IAAM,EAEV,MAGDF,EAAMJ,EAAKM,EAAE,CAAE,EACVR,EAAwB,KAAMM,CAAI,IAEtCE,GAAK,EAEP,CAEA,GAAKD,IAAQJ,EACZ,KAEF,CACA,OAAOD,EAAI,UAAW,EAAGM,CAAE,CAC5B,CAKAV,EAAO,QAAUG,ICxDjB,IAAIQ,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "RE_UTF16_LOW_SURROGATE", "RE_UTF16_HIGH_SURROGATE", "removeLast", "str", "n", "len", "ch1", "ch2", "cnt", "i", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index a08ea55..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,29 +0,0 @@ - -{{alias}}( str, n ) - Removes the last `n` Unicode code points of a string. - - Parameters - ---------- - str: string - Input string. - - n: integer - Number of Unicode code points to remove. - - Returns - ------- - out: string - Output string. - - Examples - -------- - > var out = {{alias}}( 'beep', 1 ) - 'bee' - > out = {{alias}}( 'Boop', 1 ) - 'Boo' - > out = {{alias}}( 'foo bar', 5 ) - 'fo' - - See Also - -------- - diff --git a/docs/types/index.d.ts b/docs/types/index.d.ts deleted file mode 100644 index 8a1c90b..0000000 --- a/docs/types/index.d.ts +++ /dev/null @@ -1,53 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 - -/** -* Removes the last `n` Unicode code points of a string. -* -* @param str - input string -* @param n - number of code points to remove -* @returns output string -* -* @example -* var out = removeLast( 'last man standing', 1 ); -* // returns 'last man standin' -* -* @example -* var out = removeLast( 'presidential election', 1 ); -* // returns 'presidential electio' -* -* @example -* var out = removeLast( 'JavaScript', 1 ); -* // returns 'JavaScrip' -* -* @example -* var out = removeLast( 'Hidden Treasures', 1 ); -* // returns 'Hidden Treasure' -* -* @example -* var out = removeLast( 'foo bar', 5 ); -* // returns 'fo' -*/ -declare function removeLast( str: string, n: number ): string; - - -// EXPORTS // - -export = removeLast; diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index fd426d2..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,57 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 removeLast = require( './index' ); - - -// TESTS // - -// The function returns a string... -{ - removeLast( 'abc', 1 ); // $ExpectType string -} - -// The compiler throws an error if the function is provided a value other than a string... -{ - removeLast( true, 1 ); // $ExpectError - removeLast( false, 1 ); // $ExpectError - removeLast( null, 1 ); // $ExpectError - removeLast( undefined, 1 ); // $ExpectError - removeLast( 5, 1 ); // $ExpectError - removeLast( [], 1 ); // $ExpectError - removeLast( {}, 1 ); // $ExpectError - removeLast( ( x: number ): number => x, 1 ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument that is not a number... -{ - removeLast( 'abc', true ); // $ExpectError - removeLast( 'abc', false ); // $ExpectError - removeLast( 'abc', null ); // $ExpectError - removeLast( 'abc', 'abc' ); // $ExpectError - removeLast( 'abc', [] ); // $ExpectError - removeLast( 'abc', {} ); // $ExpectError - removeLast( 'abc', ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - removeLast(); // $ExpectError - removeLast( 'abc' ); // $ExpectError - removeLast( 'abc', 1, 2 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 085633e..0000000 --- a/examples/index.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var removeLastCodePoint = require( './../lib' ); - -console.log( removeLastCodePoint( 'presidential election', 1 ) ); -// => 'presidential electio' - -console.log( removeLastCodePoint( 'JavaScript', 1 ) ); -// => 'JavaScrip' - -console.log( removeLastCodePoint( 'The Last of the Mohicans', 5 ) ); -// => 'The Last of the Moh' - -console.log( removeLastCodePoint( 'अनुच्छेद', 1 ) ); -// => 'अनुच्छे' diff --git a/index.js b/index.js new file mode 100644 index 0000000..0185898 --- /dev/null +++ b/index.js @@ -0,0 +1,3 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +var e,t;e=this,t=function(){"use strict";var e=/[\uDC00-\uDFFF]/,t=/[\uD800-\uDBFF]/;return function(n,f){var i,o,r,u;if(0===f)return n;for(r=0,u=n.length-1;u>=0;u--){if(i=n[u],r+=1,e.test(i)){if(0===u)break;o=n[u-1],t.test(o)&&(u-=1)}if(r===f)break}return n.substring(0,u)}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).removeLastCodePoint=t(); +//# sourceMappingURL=index.js.map diff --git a/index.js.map b/index.js.map new file mode 100644 index 0000000..d557af8 --- /dev/null +++ b/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\nvar RE_UTF16_LOW_SURROGATE = /[\\uDC00-\\uDFFF]/; // TODO: replace with stdlib pkg\nvar RE_UTF16_HIGH_SURROGATE = /[\\uD800-\\uDBFF]/; // TODO: replace with stdlib pkg\n\n\n// MAIN //\n\n/**\n* Removes the last `n` Unicode code points of a string.\n*\n* @param {string} str - input string\n* @param {NonNegativeInteger} n - number of Unicode code points to remove\n* @returns {string} output string\n*\n* @example\n* var out = removeLast( 'last man standing', 1 );\n* // returns 'last man standin'\n*\n* @example\n* var out = removeLast( 'presidential election', 1 );\n* // returns 'presidential electio'\n*\n* @example\n* var out = removeLast( 'JavaScript', 1 );\n* // returns 'JavaScrip'\n*\n* @example\n* var out = removeLast( 'Hidden Treasures', 1 );\n* // returns 'Hidden Treasure'\n*/\nfunction removeLast( str, n ) {\n\tvar len;\n\tvar ch1;\n\tvar ch2;\n\tvar cnt;\n\tvar i;\n\tif ( n === 0 ) {\n\t\treturn str;\n\t}\n\tlen = str.length;\n\tcnt = 0;\n\n\t// Process the string one Unicode code unit at a time and count UTF-16 surrogate pairs as a single Unicode code point...\n\tfor ( i = len - 1; i >= 0; i-- ) {\n\t\tch1 = str[ i ];\n\t\tcnt += 1;\n\n\t\t// Check for a low UTF-16 surrogate...\n\t\tif ( RE_UTF16_LOW_SURROGATE.test( ch1 ) ) {\n\t\t\t// Check for an unpaired surrogate at the end of the input string...\n\t\t\tif ( i === 0 ) {\n\t\t\t\t// We found an unpaired surrogate...\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\t// Check whether the high surrogate is paired with a low surrogate...\n\t\t\tch2 = str[ i-1 ];\n\t\t\tif ( RE_UTF16_HIGH_SURROGATE.test( ch2 ) ) {\n\t\t\t\t// We found a surrogate pair:\n\t\t\t\ti -= 1; // bump the index to process the next code unit\n\t\t\t}\n\t\t}\n\t\t// Check whether we've found the desired number of code points...\n\t\tif ( cnt === n ) {\n\t\t\tbreak;\n\t\t}\n\t}\n\treturn str.substring( 0, i );\n}\n\n\n// EXPORTS //\n\nexport default removeLast;\n"],"names":["RE_UTF16_LOW_SURROGATE","RE_UTF16_HIGH_SURROGATE","str","n","ch1","ch2","cnt","i","length","test","substring"],"mappings":";yCAsBA,IAAIA,EAAyB,kBACzBC,EAA0B,yBA4B9B,SAAqBC,EAAKC,GACzB,IACIC,EACAC,EACAC,EACAC,EACJ,GAAW,IAANJ,EACJ,OAAOD,EAMR,IAHAI,EAAM,EAGAC,EAJAL,EAAIM,OAIM,EAAGD,GAAK,EAAGA,IAAM,CAKhC,GAJAH,EAAMF,EAAKK,GACXD,GAAO,EAGFN,EAAuBS,KAAML,GAAQ,CAEzC,GAAW,IAANG,EAEJ,MAGDF,EAAMH,EAAKK,EAAE,GACRN,EAAwBQ,KAAMJ,KAElCE,GAAK,EAEN,CAED,GAAKD,IAAQH,EACZ,KAED,CACD,OAAOD,EAAIQ,UAAW,EAAGH,EAC1B"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 9860da0..0000000 --- a/lib/index.js +++ /dev/null @@ -1,43 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Remove the last `n` Unicode code points of a string. -* -* @module @stdlib/string-base-remove-last-code-point -* -* @example -* var removeLast = require( '@stdlib/string-base-remove-last-code-point' ); -* -* var out = removeLast( 'last man standing', 1 ); -* // returns 'last man standin' -* -* out = removeLast( 'Hidden Treasures', 1 ); -* // returns 'Hidden Treasure'; -*/ - -// 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 fc34187..0000000 --- a/lib/main.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// VARIABLES // - -var RE_UTF16_LOW_SURROGATE = /[\uDC00-\uDFFF]/; // TODO: replace with stdlib pkg -var RE_UTF16_HIGH_SURROGATE = /[\uD800-\uDBFF]/; // TODO: replace with stdlib pkg - - -// MAIN // - -/** -* Removes the last `n` Unicode code points of a string. -* -* @param {string} str - input string -* @param {NonNegativeInteger} n - number of Unicode code points to remove -* @returns {string} output string -* -* @example -* var out = removeLast( 'last man standing', 1 ); -* // returns 'last man standin' -* -* @example -* var out = removeLast( 'presidential election', 1 ); -* // returns 'presidential electio' -* -* @example -* var out = removeLast( 'JavaScript', 1 ); -* // returns 'JavaScrip' -* -* @example -* var out = removeLast( 'Hidden Treasures', 1 ); -* // returns 'Hidden Treasure' -*/ -function removeLast( str, n ) { - var len; - var ch1; - var ch2; - var cnt; - var i; - if ( n === 0 ) { - return str; - } - len = str.length; - cnt = 0; - - // Process the string one Unicode code unit at a time and count UTF-16 surrogate pairs as a single Unicode code point... - for ( i = len - 1; i >= 0; i-- ) { - ch1 = str[ i ]; - cnt += 1; - - // Check for a low UTF-16 surrogate... - if ( RE_UTF16_LOW_SURROGATE.test( ch1 ) ) { - // Check for an unpaired surrogate at the end of the input string... - if ( i === 0 ) { - // We found an unpaired surrogate... - break; - } - // Check whether the high surrogate is paired with a low surrogate... - ch2 = str[ i-1 ]; - if ( RE_UTF16_HIGH_SURROGATE.test( ch2 ) ) { - // We found a surrogate pair: - i -= 1; // bump the index to process the next code unit - } - } - // Check whether we've found the desired number of code points... - if ( cnt === n ) { - break; - } - } - return str.substring( 0, i ); -} - - -// EXPORTS // - -module.exports = removeLast; diff --git a/package.json b/package.json index d8226c0..aae81be 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,7 @@ "version": "0.1.0", "description": "Remove the last Unicode code point of a string.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "main": "./index.js", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,31 +12,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/error-tools-fmtprodmsg": "^0.1.0" - }, - "devDependencies": { - "@stdlib/assert-is-string": "^0.1.0", - "@stdlib/bench": "^0.1.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdstring", @@ -81,4 +32,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/stats_browser.html b/stats_browser.html new file mode 100644 index 0000000..fac5b7e --- /dev/null +++ b/stats_browser.html @@ -0,0 +1,6177 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/stats_node.html b/stats_node.html new file mode 100644 index 0000000..cae1a37 --- /dev/null +++ b/stats_node.html @@ -0,0 +1,6177 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index 7be2304..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,108 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var removeLast = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof removeLast, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns an empty string if provided an empty string', function test( t ) { - t.strictEqual( removeLast( '', 1 ), '', 'returns expected value' ); - t.strictEqual( removeLast( '', 2 ), '', 'returns expected value' ); - t.strictEqual( removeLast( '', 3 ), '', 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns the input string if provided zero as the second argument', function test( t ) { - t.strictEqual( removeLast( 'hello world', 0 ), 'hello world', 'returns expected value' ); - t.end(); -}); - -tape( 'the function removes the last Unicode code point of a provided string (ascii)', function test( t ) { - var out; - - out = removeLast( 'hello world', 1 ); - t.strictEqual( out, 'hello worl', 'returns expected value' ); - - out = removeLast( '!!!', 1 ); - t.strictEqual( out, '!!', 'returns expected value' ); - - out = removeLast( 'Hello World', 1 ); - t.strictEqual( out, 'Hello Worl', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function removes the last Unicode code point of a provided string (Unicode)', function test( t ) { - var out; - - out = removeLast( 'अनुच्छेद', 1 ); - t.strictEqual( out, 'अनुच्छे', 'returns expected value' ); - - out = removeLast( '六书/六書', 1 ); - t.strictEqual( out, '六书/六', 'returns expected value' ); - - out = removeLast( '𐒻𐓟', 1 ); - t.strictEqual( out, '𐒻', 'returns expected value' ); - - out = removeLast( '𐒻𐓟', 1 ); - t.strictEqual( out, '𐒻', 'returns expected value' ); - - out = removeLast( '\uDC00', 1 ); - t.strictEqual( out, '', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports removing the last `n` Unicode code points of a provided string', function test( t ) { - var out; - - out = removeLast( 'hello world', 1 ); - t.strictEqual( out, 'hello worl', 'returns expected value' ); - - out = removeLast( 'hello world', 7 ); - t.strictEqual( out, 'hell', 'returns expected value' ); - - out = removeLast( '!!!', 1 ); - t.strictEqual( out, '!!', 'returns expected value' ); - - out = removeLast( '!!!', 2 ); - t.strictEqual( out, '!', 'returns expected value' ); - - out = removeLast( 'अनुच्छेद', 1 ); - t.strictEqual( out, 'अनुच्छे', 'returns expected value' ); - - out = removeLast( '六书/六書', 3 ); - t.strictEqual( out, '六书', 'returns expected value' ); - - out = removeLast( '𐒻𐓟𐓟', 2 ); - t.strictEqual( out, '𐒻', 'returns expected value' ); - - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index a25545e..0000000 --- a/test/test.js +++ /dev/null @@ -1,108 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var removeLast = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof removeLast, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns an empty string if provided an empty string', function test( t ) { - t.strictEqual( removeLast( '', 1 ), '', 'returns expected value' ); - t.strictEqual( removeLast( '', 2 ), '', 'returns expected value' ); - t.strictEqual( removeLast( '', 3 ), '', 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns the input string if provided zero as the second argument', function test( t ) { - t.strictEqual( removeLast( 'hello world', 0 ), 'hello world', 'returns expected value' ); - t.end(); -}); - -tape( 'the function removes the last Unicode code point of a provided string (ascii)', function test( t ) { - var out; - - out = removeLast( 'hello world', 1 ); - t.strictEqual( out, 'hello worl', 'returns expected value' ); - - out = removeLast( '!!!', 1 ); - t.strictEqual( out, '!!', 'returns expected value' ); - - out = removeLast( 'Hello World', 1 ); - t.strictEqual( out, 'Hello Worl', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function removes the last Unicode code point of a provided string (Unicode)', function test( t ) { - var out; - - out = removeLast( 'अनुच्छेद', 1 ); - t.strictEqual( out, 'अनुच्छे', 'returns expected value' ); - - out = removeLast( '六书/六書', 1 ); - t.strictEqual( out, '六书/六', 'returns expected value' ); - - out = removeLast( '𐒻𐓟', 1 ); - t.strictEqual( out, '𐒻', 'returns expected value' ); - - out = removeLast( '𐒻𐓟', 1 ); - t.strictEqual( out, '𐒻', 'returns expected value' ); - - out = removeLast( '\uDC00', 1 ); - t.strictEqual( out, '', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports removing the last `n` Unicode code points of a provided string', function test( t ) { - var out; - - out = removeLast( 'hello world', 1 ); - t.strictEqual( out, 'hello worl', 'returns expected value' ); - - out = removeLast( 'hello world', 7 ); - t.strictEqual( out, 'hell', 'returns expected value' ); - - out = removeLast( '!!!', 1 ); - t.strictEqual( out, '!!', 'returns expected value' ); - - out = removeLast( '!!!', 2 ); - t.strictEqual( out, '!', 'returns expected value' ); - - out = removeLast( 'अनुच्छेद', 1 ); - t.strictEqual( out, 'अनुच्छे', 'returns expected value' ); - - out = removeLast( '六书/六書', 3 ); - t.strictEqual( out, '六书', 'returns expected value' ); - - out = removeLast( '𐒻𐓟𐓟', 2 ); - t.strictEqual( out, '𐒻', 'returns expected value' ); - - t.end(); -}); From c8d819eb37e1eabd17a3fc1e892ed69b070147ae Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 3 Oct 2023 22:46:56 +0000 Subject: [PATCH 16/92] Transform error messages --- package.json | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 28c67df..04fb369 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,9 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": {}, + "dependencies": { + "@stdlib/error-tools-fmtprodmsg": "^0.1.0" + }, "devDependencies": { "@stdlib/assert-is-string": "^0.1.0", "@stdlib/bench": "^0.1.0", @@ -79,4 +81,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 1350de5c633d1eb9b0ac8cfc94a83be1a3f57cd3 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 3 Oct 2023 23:04:14 +0000 Subject: [PATCH 17/92] Remove files --- browser.js | 3 - browser.js.map | 1 - index.js | 3 - index.js.map | 1 - stats_browser.html | 6177 -------------------------------------------- stats_node.html | 6177 -------------------------------------------- 6 files changed, 12362 deletions(-) delete mode 100644 browser.js delete mode 100644 browser.js.map delete mode 100644 index.js delete mode 100644 index.js.map delete mode 100644 stats_browser.html delete mode 100644 stats_node.html diff --git a/browser.js b/browser.js deleted file mode 100644 index d3e0f5b..0000000 --- a/browser.js +++ /dev/null @@ -1,3 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -var e,t;e=this,t=function(){"use strict";var e=/[\uDC00-\uDFFF]/,t=/[\uD800-\uDBFF]/;return function(n,f){var i,o,r,u;if(0===f)return n;for(r=0,u=n.length-1;u>=0;u--){if(i=n[u],r+=1,e.test(i)){if(0===u)break;o=n[u-1],t.test(o)&&(u-=1)}if(r===f)break}return n.substring(0,u)}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).removeLastCodePoint=t(); -//# sourceMappingURL=browser.js.map diff --git a/browser.js.map b/browser.js.map deleted file mode 100644 index 19908eb..0000000 --- a/browser.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"browser.js","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\nvar RE_UTF16_LOW_SURROGATE = /[\\uDC00-\\uDFFF]/; // TODO: replace with stdlib pkg\nvar RE_UTF16_HIGH_SURROGATE = /[\\uD800-\\uDBFF]/; // TODO: replace with stdlib pkg\n\n\n// MAIN //\n\n/**\n* Removes the last `n` Unicode code points of a string.\n*\n* @param {string} str - input string\n* @param {NonNegativeInteger} n - number of Unicode code points to remove\n* @returns {string} output string\n*\n* @example\n* var out = removeLast( 'last man standing', 1 );\n* // returns 'last man standin'\n*\n* @example\n* var out = removeLast( 'presidential election', 1 );\n* // returns 'presidential electio'\n*\n* @example\n* var out = removeLast( 'JavaScript', 1 );\n* // returns 'JavaScrip'\n*\n* @example\n* var out = removeLast( 'Hidden Treasures', 1 );\n* // returns 'Hidden Treasure'\n*/\nfunction removeLast( str, n ) {\n\tvar len;\n\tvar ch1;\n\tvar ch2;\n\tvar cnt;\n\tvar i;\n\tif ( n === 0 ) {\n\t\treturn str;\n\t}\n\tlen = str.length;\n\tcnt = 0;\n\n\t// Process the string one Unicode code unit at a time and count UTF-16 surrogate pairs as a single Unicode code point...\n\tfor ( i = len - 1; i >= 0; i-- ) {\n\t\tch1 = str[ i ];\n\t\tcnt += 1;\n\n\t\t// Check for a low UTF-16 surrogate...\n\t\tif ( RE_UTF16_LOW_SURROGATE.test( ch1 ) ) {\n\t\t\t// Check for an unpaired surrogate at the end of the input string...\n\t\t\tif ( i === 0 ) {\n\t\t\t\t// We found an unpaired surrogate...\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\t// Check whether the high surrogate is paired with a low surrogate...\n\t\t\tch2 = str[ i-1 ];\n\t\t\tif ( RE_UTF16_HIGH_SURROGATE.test( ch2 ) ) {\n\t\t\t\t// We found a surrogate pair:\n\t\t\t\ti -= 1; // bump the index to process the next code unit\n\t\t\t}\n\t\t}\n\t\t// Check whether we've found the desired number of code points...\n\t\tif ( cnt === n ) {\n\t\t\tbreak;\n\t\t}\n\t}\n\treturn str.substring( 0, i );\n}\n\n\n// EXPORTS //\n\nexport default removeLast;\n"],"names":["RE_UTF16_LOW_SURROGATE","RE_UTF16_HIGH_SURROGATE","str","n","ch1","ch2","cnt","i","length","test","substring"],"mappings":";yCAsBA,IAAIA,EAAyB,kBACzBC,EAA0B,yBA4B9B,SAAqBC,EAAKC,GACzB,IACIC,EACAC,EACAC,EACAC,EACJ,GAAW,IAANJ,EACJ,OAAOD,EAMR,IAHAI,EAAM,EAGAC,EAJAL,EAAIM,OAIM,EAAGD,GAAK,EAAGA,IAAM,CAKhC,GAJAH,EAAMF,EAAKK,GACXD,GAAO,EAGFN,EAAuBS,KAAML,GAAQ,CAEzC,GAAW,IAANG,EAEJ,MAGDF,EAAMH,EAAKK,EAAE,GACRN,EAAwBQ,KAAMJ,KAElCE,GAAK,EAEN,CAED,GAAKD,IAAQH,EACZ,KAED,CACD,OAAOD,EAAIQ,UAAW,EAAGH,EAC1B"} \ No newline at end of file diff --git a/index.js b/index.js deleted file mode 100644 index 0185898..0000000 --- a/index.js +++ /dev/null @@ -1,3 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -var e,t;e=this,t=function(){"use strict";var e=/[\uDC00-\uDFFF]/,t=/[\uD800-\uDBFF]/;return function(n,f){var i,o,r,u;if(0===f)return n;for(r=0,u=n.length-1;u>=0;u--){if(i=n[u],r+=1,e.test(i)){if(0===u)break;o=n[u-1],t.test(o)&&(u-=1)}if(r===f)break}return n.substring(0,u)}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).removeLastCodePoint=t(); -//# sourceMappingURL=index.js.map diff --git a/index.js.map b/index.js.map deleted file mode 100644 index d557af8..0000000 --- a/index.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.js","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\nvar RE_UTF16_LOW_SURROGATE = /[\\uDC00-\\uDFFF]/; // TODO: replace with stdlib pkg\nvar RE_UTF16_HIGH_SURROGATE = /[\\uD800-\\uDBFF]/; // TODO: replace with stdlib pkg\n\n\n// MAIN //\n\n/**\n* Removes the last `n` Unicode code points of a string.\n*\n* @param {string} str - input string\n* @param {NonNegativeInteger} n - number of Unicode code points to remove\n* @returns {string} output string\n*\n* @example\n* var out = removeLast( 'last man standing', 1 );\n* // returns 'last man standin'\n*\n* @example\n* var out = removeLast( 'presidential election', 1 );\n* // returns 'presidential electio'\n*\n* @example\n* var out = removeLast( 'JavaScript', 1 );\n* // returns 'JavaScrip'\n*\n* @example\n* var out = removeLast( 'Hidden Treasures', 1 );\n* // returns 'Hidden Treasure'\n*/\nfunction removeLast( str, n ) {\n\tvar len;\n\tvar ch1;\n\tvar ch2;\n\tvar cnt;\n\tvar i;\n\tif ( n === 0 ) {\n\t\treturn str;\n\t}\n\tlen = str.length;\n\tcnt = 0;\n\n\t// Process the string one Unicode code unit at a time and count UTF-16 surrogate pairs as a single Unicode code point...\n\tfor ( i = len - 1; i >= 0; i-- ) {\n\t\tch1 = str[ i ];\n\t\tcnt += 1;\n\n\t\t// Check for a low UTF-16 surrogate...\n\t\tif ( RE_UTF16_LOW_SURROGATE.test( ch1 ) ) {\n\t\t\t// Check for an unpaired surrogate at the end of the input string...\n\t\t\tif ( i === 0 ) {\n\t\t\t\t// We found an unpaired surrogate...\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\t// Check whether the high surrogate is paired with a low surrogate...\n\t\t\tch2 = str[ i-1 ];\n\t\t\tif ( RE_UTF16_HIGH_SURROGATE.test( ch2 ) ) {\n\t\t\t\t// We found a surrogate pair:\n\t\t\t\ti -= 1; // bump the index to process the next code unit\n\t\t\t}\n\t\t}\n\t\t// Check whether we've found the desired number of code points...\n\t\tif ( cnt === n ) {\n\t\t\tbreak;\n\t\t}\n\t}\n\treturn str.substring( 0, i );\n}\n\n\n// EXPORTS //\n\nexport default removeLast;\n"],"names":["RE_UTF16_LOW_SURROGATE","RE_UTF16_HIGH_SURROGATE","str","n","ch1","ch2","cnt","i","length","test","substring"],"mappings":";yCAsBA,IAAIA,EAAyB,kBACzBC,EAA0B,yBA4B9B,SAAqBC,EAAKC,GACzB,IACIC,EACAC,EACAC,EACAC,EACJ,GAAW,IAANJ,EACJ,OAAOD,EAMR,IAHAI,EAAM,EAGAC,EAJAL,EAAIM,OAIM,EAAGD,GAAK,EAAGA,IAAM,CAKhC,GAJAH,EAAMF,EAAKK,GACXD,GAAO,EAGFN,EAAuBS,KAAML,GAAQ,CAEzC,GAAW,IAANG,EAEJ,MAGDF,EAAMH,EAAKK,EAAE,GACRN,EAAwBQ,KAAMJ,KAElCE,GAAK,EAEN,CAED,GAAKD,IAAQH,EACZ,KAED,CACD,OAAOD,EAAIQ,UAAW,EAAGH,EAC1B"} \ No newline at end of file diff --git a/stats_browser.html b/stats_browser.html deleted file mode 100644 index fac5b7e..0000000 --- a/stats_browser.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - diff --git a/stats_node.html b/stats_node.html deleted file mode 100644 index cae1a37..0000000 --- a/stats_node.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From e0981a727d9118192fde182e5e26261e2f666f6b Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 3 Oct 2023 23:04:51 +0000 Subject: [PATCH 18/92] Auto-generated commit --- .editorconfig | 186 - .eslintrc.js | 1 - .gitattributes | 49 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 797 --- .github/workflows/publish.yml | 247 - .github/workflows/test.yml | 100 - .github/workflows/test_bundles.yml | 189 - .github/workflows/test_coverage.yml | 128 - .github/workflows/test_install.yml | 86 - .gitignore | 188 - .npmignore | 227 - .npmrc | 28 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 52 +- benchmark/benchmark.js | 56 - branches.md | 53 - browser.js | 3 + browser.js.map | 1 + dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 29 - docs/types/index.d.ts | 53 - docs/types/test.ts | 57 - examples/index.js | 33 - index.js | 3 + index.js.map | 1 + lib/index.js | 43 - lib/main.js | 94 - package.json | 53 +- stats_browser.html | 6177 +++++++++++++++++++++ stats_node.html | 6177 +++++++++++++++++++++ test/dist/test.js | 108 - test/test.js | 108 - 44 files changed, 12399 insertions(+), 3876 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md create mode 100644 browser.js create mode 100644 browser.js.map 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/index.d.ts delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js create mode 100644 index.js create mode 100644 index.js.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats_browser.html create mode 100644 stats_node.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 13e9c39..0000000 --- a/.editorconfig +++ /dev/null @@ -1,186 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 52cd9c4..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/base/remove-last-code-point) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 533eeee..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/base/remove-last-code-point) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 33382c1..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: '29 5 * * 0' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA corresponding to v3.1.3 - uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA corresponding to v3.0.3: - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 265afda..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,797 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA corresponding to v2.0.0 - uses: act10ns/slack@ed1309ab9862e57e9e583e51c7889486b9a00b0f - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n +``` + +If no recognized module system is present, access bundle contents via the global scope: + +```html + ``` #### removeLastCodePoint( str, n ) @@ -89,8 +97,13 @@ out = removeLastCodePoint( 'foo bar', 10 ); -```javascript -var removeLastCodePoint = require( '@stdlib/string-base-remove-last-code-point' ); +```html + + + + + + + ```
diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index d846d34..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,56 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var removeLast = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var values; - var out; - var i; - - values = [ - 'beep boop', - 'foo bar', - 'xyz abc', - '🐶🐮🐷🐰🐸' - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = removeLast( values[ i%values.length ], 1 ); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( !isString( out ) ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 41f4db9..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/base/remove-last-code-point" -%% click B href "https://github.com/stdlib-js/string-base-remove-last-code-point/tree/main" -%% click C href "https://github.com/stdlib-js/string-base-remove-last-code-point/tree/production" -%% click D href "https://github.com/stdlib-js/string-base-remove-last-code-point/tree/esm" -%% click E href "https://github.com/stdlib-js/string-base-remove-last-code-point/tree/deno" -%% click F href "https://github.com/stdlib-js/string-base-remove-last-code-point/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/base/remove-last-code-point -[production-url]: https://github.com/stdlib-js/string-base-remove-last-code-point/tree/production -[deno-url]: https://github.com/stdlib-js/string-base-remove-last-code-point/tree/deno -[umd-url]: https://github.com/stdlib-js/string-base-remove-last-code-point/tree/umd -[esm-url]: https://github.com/stdlib-js/string-base-remove-last-code-point/tree/esm \ No newline at end of file diff --git a/browser.js b/browser.js new file mode 100644 index 0000000..d3e0f5b --- /dev/null +++ b/browser.js @@ -0,0 +1,3 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +var e,t;e=this,t=function(){"use strict";var e=/[\uDC00-\uDFFF]/,t=/[\uD800-\uDBFF]/;return function(n,f){var i,o,r,u;if(0===f)return n;for(r=0,u=n.length-1;u>=0;u--){if(i=n[u],r+=1,e.test(i)){if(0===u)break;o=n[u-1],t.test(o)&&(u-=1)}if(r===f)break}return n.substring(0,u)}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).removeLastCodePoint=t(); +//# sourceMappingURL=browser.js.map diff --git a/browser.js.map b/browser.js.map new file mode 100644 index 0000000..19908eb --- /dev/null +++ b/browser.js.map @@ -0,0 +1 @@ +{"version":3,"file":"browser.js","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\nvar RE_UTF16_LOW_SURROGATE = /[\\uDC00-\\uDFFF]/; // TODO: replace with stdlib pkg\nvar RE_UTF16_HIGH_SURROGATE = /[\\uD800-\\uDBFF]/; // TODO: replace with stdlib pkg\n\n\n// MAIN //\n\n/**\n* Removes the last `n` Unicode code points of a string.\n*\n* @param {string} str - input string\n* @param {NonNegativeInteger} n - number of Unicode code points to remove\n* @returns {string} output string\n*\n* @example\n* var out = removeLast( 'last man standing', 1 );\n* // returns 'last man standin'\n*\n* @example\n* var out = removeLast( 'presidential election', 1 );\n* // returns 'presidential electio'\n*\n* @example\n* var out = removeLast( 'JavaScript', 1 );\n* // returns 'JavaScrip'\n*\n* @example\n* var out = removeLast( 'Hidden Treasures', 1 );\n* // returns 'Hidden Treasure'\n*/\nfunction removeLast( str, n ) {\n\tvar len;\n\tvar ch1;\n\tvar ch2;\n\tvar cnt;\n\tvar i;\n\tif ( n === 0 ) {\n\t\treturn str;\n\t}\n\tlen = str.length;\n\tcnt = 0;\n\n\t// Process the string one Unicode code unit at a time and count UTF-16 surrogate pairs as a single Unicode code point...\n\tfor ( i = len - 1; i >= 0; i-- ) {\n\t\tch1 = str[ i ];\n\t\tcnt += 1;\n\n\t\t// Check for a low UTF-16 surrogate...\n\t\tif ( RE_UTF16_LOW_SURROGATE.test( ch1 ) ) {\n\t\t\t// Check for an unpaired surrogate at the end of the input string...\n\t\t\tif ( i === 0 ) {\n\t\t\t\t// We found an unpaired surrogate...\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\t// Check whether the high surrogate is paired with a low surrogate...\n\t\t\tch2 = str[ i-1 ];\n\t\t\tif ( RE_UTF16_HIGH_SURROGATE.test( ch2 ) ) {\n\t\t\t\t// We found a surrogate pair:\n\t\t\t\ti -= 1; // bump the index to process the next code unit\n\t\t\t}\n\t\t}\n\t\t// Check whether we've found the desired number of code points...\n\t\tif ( cnt === n ) {\n\t\t\tbreak;\n\t\t}\n\t}\n\treturn str.substring( 0, i );\n}\n\n\n// EXPORTS //\n\nexport default removeLast;\n"],"names":["RE_UTF16_LOW_SURROGATE","RE_UTF16_HIGH_SURROGATE","str","n","ch1","ch2","cnt","i","length","test","substring"],"mappings":";yCAsBA,IAAIA,EAAyB,kBACzBC,EAA0B,yBA4B9B,SAAqBC,EAAKC,GACzB,IACIC,EACAC,EACAC,EACAC,EACJ,GAAW,IAANJ,EACJ,OAAOD,EAMR,IAHAI,EAAM,EAGAC,EAJAL,EAAIM,OAIM,EAAGD,GAAK,EAAGA,IAAM,CAKhC,GAJAH,EAAMF,EAAKK,GACXD,GAAO,EAGFN,EAAuBS,KAAML,GAAQ,CAEzC,GAAW,IAANG,EAEJ,MAGDF,EAAMH,EAAKK,EAAE,GACRN,EAAwBQ,KAAMJ,KAElCE,GAAK,EAEN,CAED,GAAKD,IAAQH,EACZ,KAED,CACD,OAAOD,EAAIQ,UAAW,EAAGH,EAC1B"} \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index 8c96fd7..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import removeLast from '../docs/types/index'; -export = removeLast; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index e6b7220..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var s=function(e,t){return function(){return t||e((t={exports:{}}).exports,t),t.exports}};var f=s(function(D,n){ -var F=/[\uDC00-\uDFFF]/,c=/[\uD800-\uDBFF]/;function R(e,t){var i,u,v,a,r;if(t===0)return e;for(i=e.length,a=0,r=i-1;r>=0;r--){if(u=e[r],a+=1,F.test(u)){if(r===0)break;v=e[r-1],c.test(v)&&(r-=1)}if(a===t)break}return e.substring(0,r)}n.exports=R -});var _=f();module.exports=_; -/** @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 72561cf..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\nvar RE_UTF16_LOW_SURROGATE = /[\\uDC00-\\uDFFF]/; // TODO: replace with stdlib pkg\nvar RE_UTF16_HIGH_SURROGATE = /[\\uD800-\\uDBFF]/; // TODO: replace with stdlib pkg\n\n\n// MAIN //\n\n/**\n* Removes the last `n` Unicode code points of a string.\n*\n* @param {string} str - input string\n* @param {NonNegativeInteger} n - number of Unicode code points to remove\n* @returns {string} output string\n*\n* @example\n* var out = removeLast( 'last man standing', 1 );\n* // returns 'last man standin'\n*\n* @example\n* var out = removeLast( 'presidential election', 1 );\n* // returns 'presidential electio'\n*\n* @example\n* var out = removeLast( 'JavaScript', 1 );\n* // returns 'JavaScrip'\n*\n* @example\n* var out = removeLast( 'Hidden Treasures', 1 );\n* // returns 'Hidden Treasure'\n*/\nfunction removeLast( str, n ) {\n\tvar len;\n\tvar ch1;\n\tvar ch2;\n\tvar cnt;\n\tvar i;\n\tif ( n === 0 ) {\n\t\treturn str;\n\t}\n\tlen = str.length;\n\tcnt = 0;\n\n\t// Process the string one Unicode code unit at a time and count UTF-16 surrogate pairs as a single Unicode code point...\n\tfor ( i = len - 1; i >= 0; i-- ) {\n\t\tch1 = str[ i ];\n\t\tcnt += 1;\n\n\t\t// Check for a low UTF-16 surrogate...\n\t\tif ( RE_UTF16_LOW_SURROGATE.test( ch1 ) ) {\n\t\t\t// Check for an unpaired surrogate at the end of the input string...\n\t\t\tif ( i === 0 ) {\n\t\t\t\t// We found an unpaired surrogate...\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\t// Check whether the high surrogate is paired with a low surrogate...\n\t\t\tch2 = str[ i-1 ];\n\t\t\tif ( RE_UTF16_HIGH_SURROGATE.test( ch2 ) ) {\n\t\t\t\t// We found a surrogate pair:\n\t\t\t\ti -= 1; // bump the index to process the next code unit\n\t\t\t}\n\t\t}\n\t\t// Check whether we've found the desired number of code points...\n\t\tif ( cnt === n ) {\n\t\t\tbreak;\n\t\t}\n\t}\n\treturn str.substring( 0, i );\n}\n\n\n// EXPORTS //\n\nmodule.exports = removeLast;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Remove the last `n` Unicode code points of a string.\n*\n* @module @stdlib/string-base-remove-last-code-point\n*\n* @example\n* var removeLast = require( '@stdlib/string-base-remove-last-code-point' );\n*\n* var out = removeLast( 'last man standing', 1 );\n* // returns 'last man standin'\n*\n* out = removeLast( 'Hidden Treasures', 1 );\n* // returns 'Hidden Treasure';\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,EAAyB,kBACzBC,EAA0B,kBA4B9B,SAASC,EAAYC,EAAKC,EAAI,CAC7B,IAAIC,EACAC,EACAC,EACAC,EACAC,EACJ,GAAKL,IAAM,EACV,OAAOD,EAMR,IAJAE,EAAMF,EAAI,OACVK,EAAM,EAGAC,EAAIJ,EAAM,EAAGI,GAAK,EAAGA,IAAM,CAKhC,GAJAH,EAAMH,EAAKM,CAAE,EACbD,GAAO,EAGFR,EAAuB,KAAMM,CAAI,EAAI,CAEzC,GAAKG,IAAM,EAEV,MAGDF,EAAMJ,EAAKM,EAAE,CAAE,EACVR,EAAwB,KAAMM,CAAI,IAEtCE,GAAK,EAEP,CAEA,GAAKD,IAAQJ,EACZ,KAEF,CACA,OAAOD,EAAI,UAAW,EAAGM,CAAE,CAC5B,CAKAV,EAAO,QAAUG,ICxDjB,IAAIQ,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "RE_UTF16_LOW_SURROGATE", "RE_UTF16_HIGH_SURROGATE", "removeLast", "str", "n", "len", "ch1", "ch2", "cnt", "i", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index a08ea55..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,29 +0,0 @@ - -{{alias}}( str, n ) - Removes the last `n` Unicode code points of a string. - - Parameters - ---------- - str: string - Input string. - - n: integer - Number of Unicode code points to remove. - - Returns - ------- - out: string - Output string. - - Examples - -------- - > var out = {{alias}}( 'beep', 1 ) - 'bee' - > out = {{alias}}( 'Boop', 1 ) - 'Boo' - > out = {{alias}}( 'foo bar', 5 ) - 'fo' - - See Also - -------- - diff --git a/docs/types/index.d.ts b/docs/types/index.d.ts deleted file mode 100644 index 8a1c90b..0000000 --- a/docs/types/index.d.ts +++ /dev/null @@ -1,53 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 - -/** -* Removes the last `n` Unicode code points of a string. -* -* @param str - input string -* @param n - number of code points to remove -* @returns output string -* -* @example -* var out = removeLast( 'last man standing', 1 ); -* // returns 'last man standin' -* -* @example -* var out = removeLast( 'presidential election', 1 ); -* // returns 'presidential electio' -* -* @example -* var out = removeLast( 'JavaScript', 1 ); -* // returns 'JavaScrip' -* -* @example -* var out = removeLast( 'Hidden Treasures', 1 ); -* // returns 'Hidden Treasure' -* -* @example -* var out = removeLast( 'foo bar', 5 ); -* // returns 'fo' -*/ -declare function removeLast( str: string, n: number ): string; - - -// EXPORTS // - -export = removeLast; diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index fd426d2..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,57 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 removeLast = require( './index' ); - - -// TESTS // - -// The function returns a string... -{ - removeLast( 'abc', 1 ); // $ExpectType string -} - -// The compiler throws an error if the function is provided a value other than a string... -{ - removeLast( true, 1 ); // $ExpectError - removeLast( false, 1 ); // $ExpectError - removeLast( null, 1 ); // $ExpectError - removeLast( undefined, 1 ); // $ExpectError - removeLast( 5, 1 ); // $ExpectError - removeLast( [], 1 ); // $ExpectError - removeLast( {}, 1 ); // $ExpectError - removeLast( ( x: number ): number => x, 1 ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument that is not a number... -{ - removeLast( 'abc', true ); // $ExpectError - removeLast( 'abc', false ); // $ExpectError - removeLast( 'abc', null ); // $ExpectError - removeLast( 'abc', 'abc' ); // $ExpectError - removeLast( 'abc', [] ); // $ExpectError - removeLast( 'abc', {} ); // $ExpectError - removeLast( 'abc', ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - removeLast(); // $ExpectError - removeLast( 'abc' ); // $ExpectError - removeLast( 'abc', 1, 2 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 085633e..0000000 --- a/examples/index.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var removeLastCodePoint = require( './../lib' ); - -console.log( removeLastCodePoint( 'presidential election', 1 ) ); -// => 'presidential electio' - -console.log( removeLastCodePoint( 'JavaScript', 1 ) ); -// => 'JavaScrip' - -console.log( removeLastCodePoint( 'The Last of the Mohicans', 5 ) ); -// => 'The Last of the Moh' - -console.log( removeLastCodePoint( 'अनुच्छेद', 1 ) ); -// => 'अनुच्छे' diff --git a/index.js b/index.js new file mode 100644 index 0000000..0185898 --- /dev/null +++ b/index.js @@ -0,0 +1,3 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +var e,t;e=this,t=function(){"use strict";var e=/[\uDC00-\uDFFF]/,t=/[\uD800-\uDBFF]/;return function(n,f){var i,o,r,u;if(0===f)return n;for(r=0,u=n.length-1;u>=0;u--){if(i=n[u],r+=1,e.test(i)){if(0===u)break;o=n[u-1],t.test(o)&&(u-=1)}if(r===f)break}return n.substring(0,u)}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).removeLastCodePoint=t(); +//# sourceMappingURL=index.js.map diff --git a/index.js.map b/index.js.map new file mode 100644 index 0000000..d557af8 --- /dev/null +++ b/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\nvar RE_UTF16_LOW_SURROGATE = /[\\uDC00-\\uDFFF]/; // TODO: replace with stdlib pkg\nvar RE_UTF16_HIGH_SURROGATE = /[\\uD800-\\uDBFF]/; // TODO: replace with stdlib pkg\n\n\n// MAIN //\n\n/**\n* Removes the last `n` Unicode code points of a string.\n*\n* @param {string} str - input string\n* @param {NonNegativeInteger} n - number of Unicode code points to remove\n* @returns {string} output string\n*\n* @example\n* var out = removeLast( 'last man standing', 1 );\n* // returns 'last man standin'\n*\n* @example\n* var out = removeLast( 'presidential election', 1 );\n* // returns 'presidential electio'\n*\n* @example\n* var out = removeLast( 'JavaScript', 1 );\n* // returns 'JavaScrip'\n*\n* @example\n* var out = removeLast( 'Hidden Treasures', 1 );\n* // returns 'Hidden Treasure'\n*/\nfunction removeLast( str, n ) {\n\tvar len;\n\tvar ch1;\n\tvar ch2;\n\tvar cnt;\n\tvar i;\n\tif ( n === 0 ) {\n\t\treturn str;\n\t}\n\tlen = str.length;\n\tcnt = 0;\n\n\t// Process the string one Unicode code unit at a time and count UTF-16 surrogate pairs as a single Unicode code point...\n\tfor ( i = len - 1; i >= 0; i-- ) {\n\t\tch1 = str[ i ];\n\t\tcnt += 1;\n\n\t\t// Check for a low UTF-16 surrogate...\n\t\tif ( RE_UTF16_LOW_SURROGATE.test( ch1 ) ) {\n\t\t\t// Check for an unpaired surrogate at the end of the input string...\n\t\t\tif ( i === 0 ) {\n\t\t\t\t// We found an unpaired surrogate...\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\t// Check whether the high surrogate is paired with a low surrogate...\n\t\t\tch2 = str[ i-1 ];\n\t\t\tif ( RE_UTF16_HIGH_SURROGATE.test( ch2 ) ) {\n\t\t\t\t// We found a surrogate pair:\n\t\t\t\ti -= 1; // bump the index to process the next code unit\n\t\t\t}\n\t\t}\n\t\t// Check whether we've found the desired number of code points...\n\t\tif ( cnt === n ) {\n\t\t\tbreak;\n\t\t}\n\t}\n\treturn str.substring( 0, i );\n}\n\n\n// EXPORTS //\n\nexport default removeLast;\n"],"names":["RE_UTF16_LOW_SURROGATE","RE_UTF16_HIGH_SURROGATE","str","n","ch1","ch2","cnt","i","length","test","substring"],"mappings":";yCAsBA,IAAIA,EAAyB,kBACzBC,EAA0B,yBA4B9B,SAAqBC,EAAKC,GACzB,IACIC,EACAC,EACAC,EACAC,EACJ,GAAW,IAANJ,EACJ,OAAOD,EAMR,IAHAI,EAAM,EAGAC,EAJAL,EAAIM,OAIM,EAAGD,GAAK,EAAGA,IAAM,CAKhC,GAJAH,EAAMF,EAAKK,GACXD,GAAO,EAGFN,EAAuBS,KAAML,GAAQ,CAEzC,GAAW,IAANG,EAEJ,MAGDF,EAAMH,EAAKK,EAAE,GACRN,EAAwBQ,KAAMJ,KAElCE,GAAK,EAEN,CAED,GAAKD,IAAQH,EACZ,KAED,CACD,OAAOD,EAAIQ,UAAW,EAAGH,EAC1B"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 9860da0..0000000 --- a/lib/index.js +++ /dev/null @@ -1,43 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Remove the last `n` Unicode code points of a string. -* -* @module @stdlib/string-base-remove-last-code-point -* -* @example -* var removeLast = require( '@stdlib/string-base-remove-last-code-point' ); -* -* var out = removeLast( 'last man standing', 1 ); -* // returns 'last man standin' -* -* out = removeLast( 'Hidden Treasures', 1 ); -* // returns 'Hidden Treasure'; -*/ - -// 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 fc34187..0000000 --- a/lib/main.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// VARIABLES // - -var RE_UTF16_LOW_SURROGATE = /[\uDC00-\uDFFF]/; // TODO: replace with stdlib pkg -var RE_UTF16_HIGH_SURROGATE = /[\uD800-\uDBFF]/; // TODO: replace with stdlib pkg - - -// MAIN // - -/** -* Removes the last `n` Unicode code points of a string. -* -* @param {string} str - input string -* @param {NonNegativeInteger} n - number of Unicode code points to remove -* @returns {string} output string -* -* @example -* var out = removeLast( 'last man standing', 1 ); -* // returns 'last man standin' -* -* @example -* var out = removeLast( 'presidential election', 1 ); -* // returns 'presidential electio' -* -* @example -* var out = removeLast( 'JavaScript', 1 ); -* // returns 'JavaScrip' -* -* @example -* var out = removeLast( 'Hidden Treasures', 1 ); -* // returns 'Hidden Treasure' -*/ -function removeLast( str, n ) { - var len; - var ch1; - var ch2; - var cnt; - var i; - if ( n === 0 ) { - return str; - } - len = str.length; - cnt = 0; - - // Process the string one Unicode code unit at a time and count UTF-16 surrogate pairs as a single Unicode code point... - for ( i = len - 1; i >= 0; i-- ) { - ch1 = str[ i ]; - cnt += 1; - - // Check for a low UTF-16 surrogate... - if ( RE_UTF16_LOW_SURROGATE.test( ch1 ) ) { - // Check for an unpaired surrogate at the end of the input string... - if ( i === 0 ) { - // We found an unpaired surrogate... - break; - } - // Check whether the high surrogate is paired with a low surrogate... - ch2 = str[ i-1 ]; - if ( RE_UTF16_HIGH_SURROGATE.test( ch2 ) ) { - // We found a surrogate pair: - i -= 1; // bump the index to process the next code unit - } - } - // Check whether we've found the desired number of code points... - if ( cnt === n ) { - break; - } - } - return str.substring( 0, i ); -} - - -// EXPORTS // - -module.exports = removeLast; diff --git a/package.json b/package.json index 04fb369..2328e01 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,7 @@ "version": "0.1.1", "description": "Remove the last Unicode code point of a string.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "main": "./index.js", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,31 +12,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/error-tools-fmtprodmsg": "^0.1.0" - }, - "devDependencies": { - "@stdlib/assert-is-string": "^0.1.0", - "@stdlib/bench": "^0.1.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdstring", @@ -81,4 +32,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/stats_browser.html b/stats_browser.html new file mode 100644 index 0000000..3f6e8cc --- /dev/null +++ b/stats_browser.html @@ -0,0 +1,6177 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/stats_node.html b/stats_node.html new file mode 100644 index 0000000..d9e4180 --- /dev/null +++ b/stats_node.html @@ -0,0 +1,6177 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index 7be2304..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,108 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var removeLast = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof removeLast, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns an empty string if provided an empty string', function test( t ) { - t.strictEqual( removeLast( '', 1 ), '', 'returns expected value' ); - t.strictEqual( removeLast( '', 2 ), '', 'returns expected value' ); - t.strictEqual( removeLast( '', 3 ), '', 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns the input string if provided zero as the second argument', function test( t ) { - t.strictEqual( removeLast( 'hello world', 0 ), 'hello world', 'returns expected value' ); - t.end(); -}); - -tape( 'the function removes the last Unicode code point of a provided string (ascii)', function test( t ) { - var out; - - out = removeLast( 'hello world', 1 ); - t.strictEqual( out, 'hello worl', 'returns expected value' ); - - out = removeLast( '!!!', 1 ); - t.strictEqual( out, '!!', 'returns expected value' ); - - out = removeLast( 'Hello World', 1 ); - t.strictEqual( out, 'Hello Worl', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function removes the last Unicode code point of a provided string (Unicode)', function test( t ) { - var out; - - out = removeLast( 'अनुच्छेद', 1 ); - t.strictEqual( out, 'अनुच्छे', 'returns expected value' ); - - out = removeLast( '六书/六書', 1 ); - t.strictEqual( out, '六书/六', 'returns expected value' ); - - out = removeLast( '𐒻𐓟', 1 ); - t.strictEqual( out, '𐒻', 'returns expected value' ); - - out = removeLast( '𐒻𐓟', 1 ); - t.strictEqual( out, '𐒻', 'returns expected value' ); - - out = removeLast( '\uDC00', 1 ); - t.strictEqual( out, '', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports removing the last `n` Unicode code points of a provided string', function test( t ) { - var out; - - out = removeLast( 'hello world', 1 ); - t.strictEqual( out, 'hello worl', 'returns expected value' ); - - out = removeLast( 'hello world', 7 ); - t.strictEqual( out, 'hell', 'returns expected value' ); - - out = removeLast( '!!!', 1 ); - t.strictEqual( out, '!!', 'returns expected value' ); - - out = removeLast( '!!!', 2 ); - t.strictEqual( out, '!', 'returns expected value' ); - - out = removeLast( 'अनुच्छेद', 1 ); - t.strictEqual( out, 'अनुच्छे', 'returns expected value' ); - - out = removeLast( '六书/六書', 3 ); - t.strictEqual( out, '六书', 'returns expected value' ); - - out = removeLast( '𐒻𐓟𐓟', 2 ); - t.strictEqual( out, '𐒻', 'returns expected value' ); - - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index a25545e..0000000 --- a/test/test.js +++ /dev/null @@ -1,108 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var removeLast = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof removeLast, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns an empty string if provided an empty string', function test( t ) { - t.strictEqual( removeLast( '', 1 ), '', 'returns expected value' ); - t.strictEqual( removeLast( '', 2 ), '', 'returns expected value' ); - t.strictEqual( removeLast( '', 3 ), '', 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns the input string if provided zero as the second argument', function test( t ) { - t.strictEqual( removeLast( 'hello world', 0 ), 'hello world', 'returns expected value' ); - t.end(); -}); - -tape( 'the function removes the last Unicode code point of a provided string (ascii)', function test( t ) { - var out; - - out = removeLast( 'hello world', 1 ); - t.strictEqual( out, 'hello worl', 'returns expected value' ); - - out = removeLast( '!!!', 1 ); - t.strictEqual( out, '!!', 'returns expected value' ); - - out = removeLast( 'Hello World', 1 ); - t.strictEqual( out, 'Hello Worl', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function removes the last Unicode code point of a provided string (Unicode)', function test( t ) { - var out; - - out = removeLast( 'अनुच्छेद', 1 ); - t.strictEqual( out, 'अनुच्छे', 'returns expected value' ); - - out = removeLast( '六书/六書', 1 ); - t.strictEqual( out, '六书/六', 'returns expected value' ); - - out = removeLast( '𐒻𐓟', 1 ); - t.strictEqual( out, '𐒻', 'returns expected value' ); - - out = removeLast( '𐒻𐓟', 1 ); - t.strictEqual( out, '𐒻', 'returns expected value' ); - - out = removeLast( '\uDC00', 1 ); - t.strictEqual( out, '', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports removing the last `n` Unicode code points of a provided string', function test( t ) { - var out; - - out = removeLast( 'hello world', 1 ); - t.strictEqual( out, 'hello worl', 'returns expected value' ); - - out = removeLast( 'hello world', 7 ); - t.strictEqual( out, 'hell', 'returns expected value' ); - - out = removeLast( '!!!', 1 ); - t.strictEqual( out, '!!', 'returns expected value' ); - - out = removeLast( '!!!', 2 ); - t.strictEqual( out, '!', 'returns expected value' ); - - out = removeLast( 'अनुच्छेद', 1 ); - t.strictEqual( out, 'अनुच्छे', 'returns expected value' ); - - out = removeLast( '六书/六書', 3 ); - t.strictEqual( out, '六书', 'returns expected value' ); - - out = removeLast( '𐒻𐓟𐓟', 2 ); - t.strictEqual( out, '𐒻', 'returns expected value' ); - - t.end(); -}); From 7291b90b5767693a6182059e20574d80047602db Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 3 Oct 2023 23:35:56 +0000 Subject: [PATCH 19/92] Update README.md for UMD bundle v0.1.1 --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index b11b7e8..5f26178 100644 --- a/README.md +++ b/README.md @@ -44,7 +44,7 @@ limitations under the License. To use in Observable, ```javascript -removeLastCodePoint = require( 'https://cdn.jsdelivr.net/gh/stdlib-js/string-base-remove-last-code-point@umd/browser.js' ) +removeLastCodePoint = require( 'https://cdn.jsdelivr.net/gh/stdlib-js/string-base-remove-last-code-point@v0.1.1-umd/browser.js' ) ``` To vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build: @@ -56,7 +56,7 @@ var removeLastCodePoint = require( 'path/to/vendor/umd/string-base-remove-last-c To include the bundle in a webpage, ```html - + ``` If no recognized module system is present, access bundle contents via the global scope: @@ -101,7 +101,7 @@ out = removeLastCodePoint( 'foo bar', 10 ); - + + ``` If no recognized module system is present, access bundle contents via the global scope: @@ -101,7 +106,7 @@ out = removeLastCodePoint( 'foo bar', 10 ); - + - - - - diff --git a/stats_node.html b/stats_node.html deleted file mode 100644 index d9e4180..0000000 --- a/stats_node.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 0552abd75088f62d95101cd500b24f88ff820cf9 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 5 Oct 2023 03:05:22 +0000 Subject: [PATCH 23/92] Auto-generated commit --- .editorconfig | 186 - .eslintrc.js | 1 - .gitattributes | 49 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 797 --- .github/workflows/publish.yml | 247 - .github/workflows/test.yml | 100 - .github/workflows/test_bundles.yml | 189 - .github/workflows/test_coverage.yml | 128 - .github/workflows/test_install.yml | 86 - .gitignore | 188 - .npmignore | 227 - .npmrc | 28 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 52 +- benchmark/benchmark.js | 56 - branches.md | 53 - browser.js | 3 + browser.js.map | 1 + dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 29 - docs/types/index.d.ts | 53 - docs/types/test.ts | 57 - examples/index.js | 33 - index.js | 3 + index.js.map | 1 + lib/index.js | 43 - lib/main.js | 94 - package.json | 53 +- stats_browser.html | 6177 +++++++++++++++++++++ stats_node.html | 6177 +++++++++++++++++++++ test/dist/test.js | 108 - test/test.js | 108 - 44 files changed, 12399 insertions(+), 3876 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md create mode 100644 browser.js create mode 100644 browser.js.map 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/index.d.ts delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js create mode 100644 index.js create mode 100644 index.js.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats_browser.html create mode 100644 stats_node.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 13e9c39..0000000 --- a/.editorconfig +++ /dev/null @@ -1,186 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 52cd9c4..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/base/remove-last-code-point) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 533eeee..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/base/remove-last-code-point) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 33382c1..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: '29 5 * * 0' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA corresponding to v3.1.3 - uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA corresponding to v3.0.3: - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 265afda..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,797 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA corresponding to v2.0.0 - uses: act10ns/slack@ed1309ab9862e57e9e583e51c7889486b9a00b0f - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n +``` + +If no recognized module system is present, access bundle contents via the global scope: + +```html + ``` #### removeLastCodePoint( str, n ) @@ -89,8 +97,13 @@ out = removeLastCodePoint( 'foo bar', 10 ); -```javascript -var removeLastCodePoint = require( '@stdlib/string-base-remove-last-code-point' ); +```html + + + + + + + ```
diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index d846d34..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,56 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var removeLast = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var values; - var out; - var i; - - values = [ - 'beep boop', - 'foo bar', - 'xyz abc', - '🐶🐮🐷🐰🐸' - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = removeLast( values[ i%values.length ], 1 ); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( !isString( out ) ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 41f4db9..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/base/remove-last-code-point" -%% click B href "https://github.com/stdlib-js/string-base-remove-last-code-point/tree/main" -%% click C href "https://github.com/stdlib-js/string-base-remove-last-code-point/tree/production" -%% click D href "https://github.com/stdlib-js/string-base-remove-last-code-point/tree/esm" -%% click E href "https://github.com/stdlib-js/string-base-remove-last-code-point/tree/deno" -%% click F href "https://github.com/stdlib-js/string-base-remove-last-code-point/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/base/remove-last-code-point -[production-url]: https://github.com/stdlib-js/string-base-remove-last-code-point/tree/production -[deno-url]: https://github.com/stdlib-js/string-base-remove-last-code-point/tree/deno -[umd-url]: https://github.com/stdlib-js/string-base-remove-last-code-point/tree/umd -[esm-url]: https://github.com/stdlib-js/string-base-remove-last-code-point/tree/esm \ No newline at end of file diff --git a/browser.js b/browser.js new file mode 100644 index 0000000..d3e0f5b --- /dev/null +++ b/browser.js @@ -0,0 +1,3 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +var e,t;e=this,t=function(){"use strict";var e=/[\uDC00-\uDFFF]/,t=/[\uD800-\uDBFF]/;return function(n,f){var i,o,r,u;if(0===f)return n;for(r=0,u=n.length-1;u>=0;u--){if(i=n[u],r+=1,e.test(i)){if(0===u)break;o=n[u-1],t.test(o)&&(u-=1)}if(r===f)break}return n.substring(0,u)}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).removeLastCodePoint=t(); +//# sourceMappingURL=browser.js.map diff --git a/browser.js.map b/browser.js.map new file mode 100644 index 0000000..19908eb --- /dev/null +++ b/browser.js.map @@ -0,0 +1 @@ +{"version":3,"file":"browser.js","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\nvar RE_UTF16_LOW_SURROGATE = /[\\uDC00-\\uDFFF]/; // TODO: replace with stdlib pkg\nvar RE_UTF16_HIGH_SURROGATE = /[\\uD800-\\uDBFF]/; // TODO: replace with stdlib pkg\n\n\n// MAIN //\n\n/**\n* Removes the last `n` Unicode code points of a string.\n*\n* @param {string} str - input string\n* @param {NonNegativeInteger} n - number of Unicode code points to remove\n* @returns {string} output string\n*\n* @example\n* var out = removeLast( 'last man standing', 1 );\n* // returns 'last man standin'\n*\n* @example\n* var out = removeLast( 'presidential election', 1 );\n* // returns 'presidential electio'\n*\n* @example\n* var out = removeLast( 'JavaScript', 1 );\n* // returns 'JavaScrip'\n*\n* @example\n* var out = removeLast( 'Hidden Treasures', 1 );\n* // returns 'Hidden Treasure'\n*/\nfunction removeLast( str, n ) {\n\tvar len;\n\tvar ch1;\n\tvar ch2;\n\tvar cnt;\n\tvar i;\n\tif ( n === 0 ) {\n\t\treturn str;\n\t}\n\tlen = str.length;\n\tcnt = 0;\n\n\t// Process the string one Unicode code unit at a time and count UTF-16 surrogate pairs as a single Unicode code point...\n\tfor ( i = len - 1; i >= 0; i-- ) {\n\t\tch1 = str[ i ];\n\t\tcnt += 1;\n\n\t\t// Check for a low UTF-16 surrogate...\n\t\tif ( RE_UTF16_LOW_SURROGATE.test( ch1 ) ) {\n\t\t\t// Check for an unpaired surrogate at the end of the input string...\n\t\t\tif ( i === 0 ) {\n\t\t\t\t// We found an unpaired surrogate...\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\t// Check whether the high surrogate is paired with a low surrogate...\n\t\t\tch2 = str[ i-1 ];\n\t\t\tif ( RE_UTF16_HIGH_SURROGATE.test( ch2 ) ) {\n\t\t\t\t// We found a surrogate pair:\n\t\t\t\ti -= 1; // bump the index to process the next code unit\n\t\t\t}\n\t\t}\n\t\t// Check whether we've found the desired number of code points...\n\t\tif ( cnt === n ) {\n\t\t\tbreak;\n\t\t}\n\t}\n\treturn str.substring( 0, i );\n}\n\n\n// EXPORTS //\n\nexport default removeLast;\n"],"names":["RE_UTF16_LOW_SURROGATE","RE_UTF16_HIGH_SURROGATE","str","n","ch1","ch2","cnt","i","length","test","substring"],"mappings":";yCAsBA,IAAIA,EAAyB,kBACzBC,EAA0B,yBA4B9B,SAAqBC,EAAKC,GACzB,IACIC,EACAC,EACAC,EACAC,EACJ,GAAW,IAANJ,EACJ,OAAOD,EAMR,IAHAI,EAAM,EAGAC,EAJAL,EAAIM,OAIM,EAAGD,GAAK,EAAGA,IAAM,CAKhC,GAJAH,EAAMF,EAAKK,GACXD,GAAO,EAGFN,EAAuBS,KAAML,GAAQ,CAEzC,GAAW,IAANG,EAEJ,MAGDF,EAAMH,EAAKK,EAAE,GACRN,EAAwBQ,KAAMJ,KAElCE,GAAK,EAEN,CAED,GAAKD,IAAQH,EACZ,KAED,CACD,OAAOD,EAAIQ,UAAW,EAAGH,EAC1B"} \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index 8c96fd7..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import removeLast from '../docs/types/index'; -export = removeLast; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index e6b7220..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var s=function(e,t){return function(){return t||e((t={exports:{}}).exports,t),t.exports}};var f=s(function(D,n){ -var F=/[\uDC00-\uDFFF]/,c=/[\uD800-\uDBFF]/;function R(e,t){var i,u,v,a,r;if(t===0)return e;for(i=e.length,a=0,r=i-1;r>=0;r--){if(u=e[r],a+=1,F.test(u)){if(r===0)break;v=e[r-1],c.test(v)&&(r-=1)}if(a===t)break}return e.substring(0,r)}n.exports=R -});var _=f();module.exports=_; -/** @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 72561cf..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\nvar RE_UTF16_LOW_SURROGATE = /[\\uDC00-\\uDFFF]/; // TODO: replace with stdlib pkg\nvar RE_UTF16_HIGH_SURROGATE = /[\\uD800-\\uDBFF]/; // TODO: replace with stdlib pkg\n\n\n// MAIN //\n\n/**\n* Removes the last `n` Unicode code points of a string.\n*\n* @param {string} str - input string\n* @param {NonNegativeInteger} n - number of Unicode code points to remove\n* @returns {string} output string\n*\n* @example\n* var out = removeLast( 'last man standing', 1 );\n* // returns 'last man standin'\n*\n* @example\n* var out = removeLast( 'presidential election', 1 );\n* // returns 'presidential electio'\n*\n* @example\n* var out = removeLast( 'JavaScript', 1 );\n* // returns 'JavaScrip'\n*\n* @example\n* var out = removeLast( 'Hidden Treasures', 1 );\n* // returns 'Hidden Treasure'\n*/\nfunction removeLast( str, n ) {\n\tvar len;\n\tvar ch1;\n\tvar ch2;\n\tvar cnt;\n\tvar i;\n\tif ( n === 0 ) {\n\t\treturn str;\n\t}\n\tlen = str.length;\n\tcnt = 0;\n\n\t// Process the string one Unicode code unit at a time and count UTF-16 surrogate pairs as a single Unicode code point...\n\tfor ( i = len - 1; i >= 0; i-- ) {\n\t\tch1 = str[ i ];\n\t\tcnt += 1;\n\n\t\t// Check for a low UTF-16 surrogate...\n\t\tif ( RE_UTF16_LOW_SURROGATE.test( ch1 ) ) {\n\t\t\t// Check for an unpaired surrogate at the end of the input string...\n\t\t\tif ( i === 0 ) {\n\t\t\t\t// We found an unpaired surrogate...\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\t// Check whether the high surrogate is paired with a low surrogate...\n\t\t\tch2 = str[ i-1 ];\n\t\t\tif ( RE_UTF16_HIGH_SURROGATE.test( ch2 ) ) {\n\t\t\t\t// We found a surrogate pair:\n\t\t\t\ti -= 1; // bump the index to process the next code unit\n\t\t\t}\n\t\t}\n\t\t// Check whether we've found the desired number of code points...\n\t\tif ( cnt === n ) {\n\t\t\tbreak;\n\t\t}\n\t}\n\treturn str.substring( 0, i );\n}\n\n\n// EXPORTS //\n\nmodule.exports = removeLast;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Remove the last `n` Unicode code points of a string.\n*\n* @module @stdlib/string-base-remove-last-code-point\n*\n* @example\n* var removeLast = require( '@stdlib/string-base-remove-last-code-point' );\n*\n* var out = removeLast( 'last man standing', 1 );\n* // returns 'last man standin'\n*\n* out = removeLast( 'Hidden Treasures', 1 );\n* // returns 'Hidden Treasure';\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,EAAyB,kBACzBC,EAA0B,kBA4B9B,SAASC,EAAYC,EAAKC,EAAI,CAC7B,IAAIC,EACAC,EACAC,EACAC,EACAC,EACJ,GAAKL,IAAM,EACV,OAAOD,EAMR,IAJAE,EAAMF,EAAI,OACVK,EAAM,EAGAC,EAAIJ,EAAM,EAAGI,GAAK,EAAGA,IAAM,CAKhC,GAJAH,EAAMH,EAAKM,CAAE,EACbD,GAAO,EAGFR,EAAuB,KAAMM,CAAI,EAAI,CAEzC,GAAKG,IAAM,EAEV,MAGDF,EAAMJ,EAAKM,EAAE,CAAE,EACVR,EAAwB,KAAMM,CAAI,IAEtCE,GAAK,EAEP,CAEA,GAAKD,IAAQJ,EACZ,KAEF,CACA,OAAOD,EAAI,UAAW,EAAGM,CAAE,CAC5B,CAKAV,EAAO,QAAUG,ICxDjB,IAAIQ,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "RE_UTF16_LOW_SURROGATE", "RE_UTF16_HIGH_SURROGATE", "removeLast", "str", "n", "len", "ch1", "ch2", "cnt", "i", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index a08ea55..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,29 +0,0 @@ - -{{alias}}( str, n ) - Removes the last `n` Unicode code points of a string. - - Parameters - ---------- - str: string - Input string. - - n: integer - Number of Unicode code points to remove. - - Returns - ------- - out: string - Output string. - - Examples - -------- - > var out = {{alias}}( 'beep', 1 ) - 'bee' - > out = {{alias}}( 'Boop', 1 ) - 'Boo' - > out = {{alias}}( 'foo bar', 5 ) - 'fo' - - See Also - -------- - diff --git a/docs/types/index.d.ts b/docs/types/index.d.ts deleted file mode 100644 index 8a1c90b..0000000 --- a/docs/types/index.d.ts +++ /dev/null @@ -1,53 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 - -/** -* Removes the last `n` Unicode code points of a string. -* -* @param str - input string -* @param n - number of code points to remove -* @returns output string -* -* @example -* var out = removeLast( 'last man standing', 1 ); -* // returns 'last man standin' -* -* @example -* var out = removeLast( 'presidential election', 1 ); -* // returns 'presidential electio' -* -* @example -* var out = removeLast( 'JavaScript', 1 ); -* // returns 'JavaScrip' -* -* @example -* var out = removeLast( 'Hidden Treasures', 1 ); -* // returns 'Hidden Treasure' -* -* @example -* var out = removeLast( 'foo bar', 5 ); -* // returns 'fo' -*/ -declare function removeLast( str: string, n: number ): string; - - -// EXPORTS // - -export = removeLast; diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index fd426d2..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,57 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 removeLast = require( './index' ); - - -// TESTS // - -// The function returns a string... -{ - removeLast( 'abc', 1 ); // $ExpectType string -} - -// The compiler throws an error if the function is provided a value other than a string... -{ - removeLast( true, 1 ); // $ExpectError - removeLast( false, 1 ); // $ExpectError - removeLast( null, 1 ); // $ExpectError - removeLast( undefined, 1 ); // $ExpectError - removeLast( 5, 1 ); // $ExpectError - removeLast( [], 1 ); // $ExpectError - removeLast( {}, 1 ); // $ExpectError - removeLast( ( x: number ): number => x, 1 ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument that is not a number... -{ - removeLast( 'abc', true ); // $ExpectError - removeLast( 'abc', false ); // $ExpectError - removeLast( 'abc', null ); // $ExpectError - removeLast( 'abc', 'abc' ); // $ExpectError - removeLast( 'abc', [] ); // $ExpectError - removeLast( 'abc', {} ); // $ExpectError - removeLast( 'abc', ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - removeLast(); // $ExpectError - removeLast( 'abc' ); // $ExpectError - removeLast( 'abc', 1, 2 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 085633e..0000000 --- a/examples/index.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var removeLastCodePoint = require( './../lib' ); - -console.log( removeLastCodePoint( 'presidential election', 1 ) ); -// => 'presidential electio' - -console.log( removeLastCodePoint( 'JavaScript', 1 ) ); -// => 'JavaScrip' - -console.log( removeLastCodePoint( 'The Last of the Mohicans', 5 ) ); -// => 'The Last of the Moh' - -console.log( removeLastCodePoint( 'अनुच्छेद', 1 ) ); -// => 'अनुच्छे' diff --git a/index.js b/index.js new file mode 100644 index 0000000..0185898 --- /dev/null +++ b/index.js @@ -0,0 +1,3 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +var e,t;e=this,t=function(){"use strict";var e=/[\uDC00-\uDFFF]/,t=/[\uD800-\uDBFF]/;return function(n,f){var i,o,r,u;if(0===f)return n;for(r=0,u=n.length-1;u>=0;u--){if(i=n[u],r+=1,e.test(i)){if(0===u)break;o=n[u-1],t.test(o)&&(u-=1)}if(r===f)break}return n.substring(0,u)}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).removeLastCodePoint=t(); +//# sourceMappingURL=index.js.map diff --git a/index.js.map b/index.js.map new file mode 100644 index 0000000..d557af8 --- /dev/null +++ b/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\nvar RE_UTF16_LOW_SURROGATE = /[\\uDC00-\\uDFFF]/; // TODO: replace with stdlib pkg\nvar RE_UTF16_HIGH_SURROGATE = /[\\uD800-\\uDBFF]/; // TODO: replace with stdlib pkg\n\n\n// MAIN //\n\n/**\n* Removes the last `n` Unicode code points of a string.\n*\n* @param {string} str - input string\n* @param {NonNegativeInteger} n - number of Unicode code points to remove\n* @returns {string} output string\n*\n* @example\n* var out = removeLast( 'last man standing', 1 );\n* // returns 'last man standin'\n*\n* @example\n* var out = removeLast( 'presidential election', 1 );\n* // returns 'presidential electio'\n*\n* @example\n* var out = removeLast( 'JavaScript', 1 );\n* // returns 'JavaScrip'\n*\n* @example\n* var out = removeLast( 'Hidden Treasures', 1 );\n* // returns 'Hidden Treasure'\n*/\nfunction removeLast( str, n ) {\n\tvar len;\n\tvar ch1;\n\tvar ch2;\n\tvar cnt;\n\tvar i;\n\tif ( n === 0 ) {\n\t\treturn str;\n\t}\n\tlen = str.length;\n\tcnt = 0;\n\n\t// Process the string one Unicode code unit at a time and count UTF-16 surrogate pairs as a single Unicode code point...\n\tfor ( i = len - 1; i >= 0; i-- ) {\n\t\tch1 = str[ i ];\n\t\tcnt += 1;\n\n\t\t// Check for a low UTF-16 surrogate...\n\t\tif ( RE_UTF16_LOW_SURROGATE.test( ch1 ) ) {\n\t\t\t// Check for an unpaired surrogate at the end of the input string...\n\t\t\tif ( i === 0 ) {\n\t\t\t\t// We found an unpaired surrogate...\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\t// Check whether the high surrogate is paired with a low surrogate...\n\t\t\tch2 = str[ i-1 ];\n\t\t\tif ( RE_UTF16_HIGH_SURROGATE.test( ch2 ) ) {\n\t\t\t\t// We found a surrogate pair:\n\t\t\t\ti -= 1; // bump the index to process the next code unit\n\t\t\t}\n\t\t}\n\t\t// Check whether we've found the desired number of code points...\n\t\tif ( cnt === n ) {\n\t\t\tbreak;\n\t\t}\n\t}\n\treturn str.substring( 0, i );\n}\n\n\n// EXPORTS //\n\nexport default removeLast;\n"],"names":["RE_UTF16_LOW_SURROGATE","RE_UTF16_HIGH_SURROGATE","str","n","ch1","ch2","cnt","i","length","test","substring"],"mappings":";yCAsBA,IAAIA,EAAyB,kBACzBC,EAA0B,yBA4B9B,SAAqBC,EAAKC,GACzB,IACIC,EACAC,EACAC,EACAC,EACJ,GAAW,IAANJ,EACJ,OAAOD,EAMR,IAHAI,EAAM,EAGAC,EAJAL,EAAIM,OAIM,EAAGD,GAAK,EAAGA,IAAM,CAKhC,GAJAH,EAAMF,EAAKK,GACXD,GAAO,EAGFN,EAAuBS,KAAML,GAAQ,CAEzC,GAAW,IAANG,EAEJ,MAGDF,EAAMH,EAAKK,EAAE,GACRN,EAAwBQ,KAAMJ,KAElCE,GAAK,EAEN,CAED,GAAKD,IAAQH,EACZ,KAED,CACD,OAAOD,EAAIQ,UAAW,EAAGH,EAC1B"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 9860da0..0000000 --- a/lib/index.js +++ /dev/null @@ -1,43 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Remove the last `n` Unicode code points of a string. -* -* @module @stdlib/string-base-remove-last-code-point -* -* @example -* var removeLast = require( '@stdlib/string-base-remove-last-code-point' ); -* -* var out = removeLast( 'last man standing', 1 ); -* // returns 'last man standin' -* -* out = removeLast( 'Hidden Treasures', 1 ); -* // returns 'Hidden Treasure'; -*/ - -// 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 fc34187..0000000 --- a/lib/main.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// VARIABLES // - -var RE_UTF16_LOW_SURROGATE = /[\uDC00-\uDFFF]/; // TODO: replace with stdlib pkg -var RE_UTF16_HIGH_SURROGATE = /[\uD800-\uDBFF]/; // TODO: replace with stdlib pkg - - -// MAIN // - -/** -* Removes the last `n` Unicode code points of a string. -* -* @param {string} str - input string -* @param {NonNegativeInteger} n - number of Unicode code points to remove -* @returns {string} output string -* -* @example -* var out = removeLast( 'last man standing', 1 ); -* // returns 'last man standin' -* -* @example -* var out = removeLast( 'presidential election', 1 ); -* // returns 'presidential electio' -* -* @example -* var out = removeLast( 'JavaScript', 1 ); -* // returns 'JavaScrip' -* -* @example -* var out = removeLast( 'Hidden Treasures', 1 ); -* // returns 'Hidden Treasure' -*/ -function removeLast( str, n ) { - var len; - var ch1; - var ch2; - var cnt; - var i; - if ( n === 0 ) { - return str; - } - len = str.length; - cnt = 0; - - // Process the string one Unicode code unit at a time and count UTF-16 surrogate pairs as a single Unicode code point... - for ( i = len - 1; i >= 0; i-- ) { - ch1 = str[ i ]; - cnt += 1; - - // Check for a low UTF-16 surrogate... - if ( RE_UTF16_LOW_SURROGATE.test( ch1 ) ) { - // Check for an unpaired surrogate at the end of the input string... - if ( i === 0 ) { - // We found an unpaired surrogate... - break; - } - // Check whether the high surrogate is paired with a low surrogate... - ch2 = str[ i-1 ]; - if ( RE_UTF16_HIGH_SURROGATE.test( ch2 ) ) { - // We found a surrogate pair: - i -= 1; // bump the index to process the next code unit - } - } - // Check whether we've found the desired number of code points... - if ( cnt === n ) { - break; - } - } - return str.substring( 0, i ); -} - - -// EXPORTS // - -module.exports = removeLast; diff --git a/package.json b/package.json index 2f22895..2328e01 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,7 @@ "version": "0.1.1", "description": "Remove the last Unicode code point of a string.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "main": "./index.js", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,31 +12,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/error-tools-fmtprodmsg": "^0.1.1" - }, - "devDependencies": { - "@stdlib/assert-is-string": "^0.1.1", - "@stdlib/bench": "^0.1.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdstring", @@ -81,4 +32,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/stats_browser.html b/stats_browser.html new file mode 100644 index 0000000..0fc9923 --- /dev/null +++ b/stats_browser.html @@ -0,0 +1,6177 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/stats_node.html b/stats_node.html new file mode 100644 index 0000000..1317b86 --- /dev/null +++ b/stats_node.html @@ -0,0 +1,6177 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index 7be2304..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,108 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var removeLast = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof removeLast, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns an empty string if provided an empty string', function test( t ) { - t.strictEqual( removeLast( '', 1 ), '', 'returns expected value' ); - t.strictEqual( removeLast( '', 2 ), '', 'returns expected value' ); - t.strictEqual( removeLast( '', 3 ), '', 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns the input string if provided zero as the second argument', function test( t ) { - t.strictEqual( removeLast( 'hello world', 0 ), 'hello world', 'returns expected value' ); - t.end(); -}); - -tape( 'the function removes the last Unicode code point of a provided string (ascii)', function test( t ) { - var out; - - out = removeLast( 'hello world', 1 ); - t.strictEqual( out, 'hello worl', 'returns expected value' ); - - out = removeLast( '!!!', 1 ); - t.strictEqual( out, '!!', 'returns expected value' ); - - out = removeLast( 'Hello World', 1 ); - t.strictEqual( out, 'Hello Worl', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function removes the last Unicode code point of a provided string (Unicode)', function test( t ) { - var out; - - out = removeLast( 'अनुच्छेद', 1 ); - t.strictEqual( out, 'अनुच्छे', 'returns expected value' ); - - out = removeLast( '六书/六書', 1 ); - t.strictEqual( out, '六书/六', 'returns expected value' ); - - out = removeLast( '𐒻𐓟', 1 ); - t.strictEqual( out, '𐒻', 'returns expected value' ); - - out = removeLast( '𐒻𐓟', 1 ); - t.strictEqual( out, '𐒻', 'returns expected value' ); - - out = removeLast( '\uDC00', 1 ); - t.strictEqual( out, '', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports removing the last `n` Unicode code points of a provided string', function test( t ) { - var out; - - out = removeLast( 'hello world', 1 ); - t.strictEqual( out, 'hello worl', 'returns expected value' ); - - out = removeLast( 'hello world', 7 ); - t.strictEqual( out, 'hell', 'returns expected value' ); - - out = removeLast( '!!!', 1 ); - t.strictEqual( out, '!!', 'returns expected value' ); - - out = removeLast( '!!!', 2 ); - t.strictEqual( out, '!', 'returns expected value' ); - - out = removeLast( 'अनुच्छेद', 1 ); - t.strictEqual( out, 'अनुच्छे', 'returns expected value' ); - - out = removeLast( '六书/六書', 3 ); - t.strictEqual( out, '六书', 'returns expected value' ); - - out = removeLast( '𐒻𐓟𐓟', 2 ); - t.strictEqual( out, '𐒻', 'returns expected value' ); - - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index a25545e..0000000 --- a/test/test.js +++ /dev/null @@ -1,108 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var removeLast = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof removeLast, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns an empty string if provided an empty string', function test( t ) { - t.strictEqual( removeLast( '', 1 ), '', 'returns expected value' ); - t.strictEqual( removeLast( '', 2 ), '', 'returns expected value' ); - t.strictEqual( removeLast( '', 3 ), '', 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns the input string if provided zero as the second argument', function test( t ) { - t.strictEqual( removeLast( 'hello world', 0 ), 'hello world', 'returns expected value' ); - t.end(); -}); - -tape( 'the function removes the last Unicode code point of a provided string (ascii)', function test( t ) { - var out; - - out = removeLast( 'hello world', 1 ); - t.strictEqual( out, 'hello worl', 'returns expected value' ); - - out = removeLast( '!!!', 1 ); - t.strictEqual( out, '!!', 'returns expected value' ); - - out = removeLast( 'Hello World', 1 ); - t.strictEqual( out, 'Hello Worl', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function removes the last Unicode code point of a provided string (Unicode)', function test( t ) { - var out; - - out = removeLast( 'अनुच्छेद', 1 ); - t.strictEqual( out, 'अनुच्छे', 'returns expected value' ); - - out = removeLast( '六书/六書', 1 ); - t.strictEqual( out, '六书/六', 'returns expected value' ); - - out = removeLast( '𐒻𐓟', 1 ); - t.strictEqual( out, '𐒻', 'returns expected value' ); - - out = removeLast( '𐒻𐓟', 1 ); - t.strictEqual( out, '𐒻', 'returns expected value' ); - - out = removeLast( '\uDC00', 1 ); - t.strictEqual( out, '', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports removing the last `n` Unicode code points of a provided string', function test( t ) { - var out; - - out = removeLast( 'hello world', 1 ); - t.strictEqual( out, 'hello worl', 'returns expected value' ); - - out = removeLast( 'hello world', 7 ); - t.strictEqual( out, 'hell', 'returns expected value' ); - - out = removeLast( '!!!', 1 ); - t.strictEqual( out, '!!', 'returns expected value' ); - - out = removeLast( '!!!', 2 ); - t.strictEqual( out, '!', 'returns expected value' ); - - out = removeLast( 'अनुच्छेद', 1 ); - t.strictEqual( out, 'अनुच्छे', 'returns expected value' ); - - out = removeLast( '六书/六書', 3 ); - t.strictEqual( out, '六书', 'returns expected value' ); - - out = removeLast( '𐒻𐓟𐓟', 2 ); - t.strictEqual( out, '𐒻', 'returns expected value' ); - - t.end(); -}); From 5edcde3ef7450d8a8e99b1be9c858244f797c351 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 1 Nov 2023 00:31:16 +0000 Subject: [PATCH 24/92] Transform error messages --- package.json | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 030b5f4..2f22895 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,9 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": {}, + "dependencies": { + "@stdlib/error-tools-fmtprodmsg": "^0.1.1" + }, "devDependencies": { "@stdlib/assert-is-string": "^0.1.1", "@stdlib/bench": "^0.1.0", @@ -79,4 +81,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 3f6ddbe3701c699ff744c77f6649f9e7a95718d5 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 1 Nov 2023 01:13:07 +0000 Subject: [PATCH 25/92] Remove files --- browser.js | 3 - browser.js.map | 1 - index.js | 3 - index.js.map | 1 - stats_browser.html | 6177 -------------------------------------------- stats_node.html | 6177 -------------------------------------------- 6 files changed, 12362 deletions(-) delete mode 100644 browser.js delete mode 100644 browser.js.map delete mode 100644 index.js delete mode 100644 index.js.map delete mode 100644 stats_browser.html delete mode 100644 stats_node.html diff --git a/browser.js b/browser.js deleted file mode 100644 index d3e0f5b..0000000 --- a/browser.js +++ /dev/null @@ -1,3 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -var e,t;e=this,t=function(){"use strict";var e=/[\uDC00-\uDFFF]/,t=/[\uD800-\uDBFF]/;return function(n,f){var i,o,r,u;if(0===f)return n;for(r=0,u=n.length-1;u>=0;u--){if(i=n[u],r+=1,e.test(i)){if(0===u)break;o=n[u-1],t.test(o)&&(u-=1)}if(r===f)break}return n.substring(0,u)}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).removeLastCodePoint=t(); -//# sourceMappingURL=browser.js.map diff --git a/browser.js.map b/browser.js.map deleted file mode 100644 index 19908eb..0000000 --- a/browser.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"browser.js","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\nvar RE_UTF16_LOW_SURROGATE = /[\\uDC00-\\uDFFF]/; // TODO: replace with stdlib pkg\nvar RE_UTF16_HIGH_SURROGATE = /[\\uD800-\\uDBFF]/; // TODO: replace with stdlib pkg\n\n\n// MAIN //\n\n/**\n* Removes the last `n` Unicode code points of a string.\n*\n* @param {string} str - input string\n* @param {NonNegativeInteger} n - number of Unicode code points to remove\n* @returns {string} output string\n*\n* @example\n* var out = removeLast( 'last man standing', 1 );\n* // returns 'last man standin'\n*\n* @example\n* var out = removeLast( 'presidential election', 1 );\n* // returns 'presidential electio'\n*\n* @example\n* var out = removeLast( 'JavaScript', 1 );\n* // returns 'JavaScrip'\n*\n* @example\n* var out = removeLast( 'Hidden Treasures', 1 );\n* // returns 'Hidden Treasure'\n*/\nfunction removeLast( str, n ) {\n\tvar len;\n\tvar ch1;\n\tvar ch2;\n\tvar cnt;\n\tvar i;\n\tif ( n === 0 ) {\n\t\treturn str;\n\t}\n\tlen = str.length;\n\tcnt = 0;\n\n\t// Process the string one Unicode code unit at a time and count UTF-16 surrogate pairs as a single Unicode code point...\n\tfor ( i = len - 1; i >= 0; i-- ) {\n\t\tch1 = str[ i ];\n\t\tcnt += 1;\n\n\t\t// Check for a low UTF-16 surrogate...\n\t\tif ( RE_UTF16_LOW_SURROGATE.test( ch1 ) ) {\n\t\t\t// Check for an unpaired surrogate at the end of the input string...\n\t\t\tif ( i === 0 ) {\n\t\t\t\t// We found an unpaired surrogate...\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\t// Check whether the high surrogate is paired with a low surrogate...\n\t\t\tch2 = str[ i-1 ];\n\t\t\tif ( RE_UTF16_HIGH_SURROGATE.test( ch2 ) ) {\n\t\t\t\t// We found a surrogate pair:\n\t\t\t\ti -= 1; // bump the index to process the next code unit\n\t\t\t}\n\t\t}\n\t\t// Check whether we've found the desired number of code points...\n\t\tif ( cnt === n ) {\n\t\t\tbreak;\n\t\t}\n\t}\n\treturn str.substring( 0, i );\n}\n\n\n// EXPORTS //\n\nexport default removeLast;\n"],"names":["RE_UTF16_LOW_SURROGATE","RE_UTF16_HIGH_SURROGATE","str","n","ch1","ch2","cnt","i","length","test","substring"],"mappings":";yCAsBA,IAAIA,EAAyB,kBACzBC,EAA0B,yBA4B9B,SAAqBC,EAAKC,GACzB,IACIC,EACAC,EACAC,EACAC,EACJ,GAAW,IAANJ,EACJ,OAAOD,EAMR,IAHAI,EAAM,EAGAC,EAJAL,EAAIM,OAIM,EAAGD,GAAK,EAAGA,IAAM,CAKhC,GAJAH,EAAMF,EAAKK,GACXD,GAAO,EAGFN,EAAuBS,KAAML,GAAQ,CAEzC,GAAW,IAANG,EAEJ,MAGDF,EAAMH,EAAKK,EAAE,GACRN,EAAwBQ,KAAMJ,KAElCE,GAAK,EAEN,CAED,GAAKD,IAAQH,EACZ,KAED,CACD,OAAOD,EAAIQ,UAAW,EAAGH,EAC1B"} \ No newline at end of file diff --git a/index.js b/index.js deleted file mode 100644 index 0185898..0000000 --- a/index.js +++ /dev/null @@ -1,3 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -var e,t;e=this,t=function(){"use strict";var e=/[\uDC00-\uDFFF]/,t=/[\uD800-\uDBFF]/;return function(n,f){var i,o,r,u;if(0===f)return n;for(r=0,u=n.length-1;u>=0;u--){if(i=n[u],r+=1,e.test(i)){if(0===u)break;o=n[u-1],t.test(o)&&(u-=1)}if(r===f)break}return n.substring(0,u)}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).removeLastCodePoint=t(); -//# sourceMappingURL=index.js.map diff --git a/index.js.map b/index.js.map deleted file mode 100644 index d557af8..0000000 --- a/index.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.js","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\nvar RE_UTF16_LOW_SURROGATE = /[\\uDC00-\\uDFFF]/; // TODO: replace with stdlib pkg\nvar RE_UTF16_HIGH_SURROGATE = /[\\uD800-\\uDBFF]/; // TODO: replace with stdlib pkg\n\n\n// MAIN //\n\n/**\n* Removes the last `n` Unicode code points of a string.\n*\n* @param {string} str - input string\n* @param {NonNegativeInteger} n - number of Unicode code points to remove\n* @returns {string} output string\n*\n* @example\n* var out = removeLast( 'last man standing', 1 );\n* // returns 'last man standin'\n*\n* @example\n* var out = removeLast( 'presidential election', 1 );\n* // returns 'presidential electio'\n*\n* @example\n* var out = removeLast( 'JavaScript', 1 );\n* // returns 'JavaScrip'\n*\n* @example\n* var out = removeLast( 'Hidden Treasures', 1 );\n* // returns 'Hidden Treasure'\n*/\nfunction removeLast( str, n ) {\n\tvar len;\n\tvar ch1;\n\tvar ch2;\n\tvar cnt;\n\tvar i;\n\tif ( n === 0 ) {\n\t\treturn str;\n\t}\n\tlen = str.length;\n\tcnt = 0;\n\n\t// Process the string one Unicode code unit at a time and count UTF-16 surrogate pairs as a single Unicode code point...\n\tfor ( i = len - 1; i >= 0; i-- ) {\n\t\tch1 = str[ i ];\n\t\tcnt += 1;\n\n\t\t// Check for a low UTF-16 surrogate...\n\t\tif ( RE_UTF16_LOW_SURROGATE.test( ch1 ) ) {\n\t\t\t// Check for an unpaired surrogate at the end of the input string...\n\t\t\tif ( i === 0 ) {\n\t\t\t\t// We found an unpaired surrogate...\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\t// Check whether the high surrogate is paired with a low surrogate...\n\t\t\tch2 = str[ i-1 ];\n\t\t\tif ( RE_UTF16_HIGH_SURROGATE.test( ch2 ) ) {\n\t\t\t\t// We found a surrogate pair:\n\t\t\t\ti -= 1; // bump the index to process the next code unit\n\t\t\t}\n\t\t}\n\t\t// Check whether we've found the desired number of code points...\n\t\tif ( cnt === n ) {\n\t\t\tbreak;\n\t\t}\n\t}\n\treturn str.substring( 0, i );\n}\n\n\n// EXPORTS //\n\nexport default removeLast;\n"],"names":["RE_UTF16_LOW_SURROGATE","RE_UTF16_HIGH_SURROGATE","str","n","ch1","ch2","cnt","i","length","test","substring"],"mappings":";yCAsBA,IAAIA,EAAyB,kBACzBC,EAA0B,yBA4B9B,SAAqBC,EAAKC,GACzB,IACIC,EACAC,EACAC,EACAC,EACJ,GAAW,IAANJ,EACJ,OAAOD,EAMR,IAHAI,EAAM,EAGAC,EAJAL,EAAIM,OAIM,EAAGD,GAAK,EAAGA,IAAM,CAKhC,GAJAH,EAAMF,EAAKK,GACXD,GAAO,EAGFN,EAAuBS,KAAML,GAAQ,CAEzC,GAAW,IAANG,EAEJ,MAGDF,EAAMH,EAAKK,EAAE,GACRN,EAAwBQ,KAAMJ,KAElCE,GAAK,EAEN,CAED,GAAKD,IAAQH,EACZ,KAED,CACD,OAAOD,EAAIQ,UAAW,EAAGH,EAC1B"} \ No newline at end of file diff --git a/stats_browser.html b/stats_browser.html deleted file mode 100644 index 0fc9923..0000000 --- a/stats_browser.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - diff --git a/stats_node.html b/stats_node.html deleted file mode 100644 index 1317b86..0000000 --- a/stats_node.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 02be9758bfac1469767afbdf6f574ccb4c5494d0 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 1 Nov 2023 01:13:51 +0000 Subject: [PATCH 26/92] Auto-generated commit --- .editorconfig | 186 - .eslintrc.js | 1 - .gitattributes | 49 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 797 --- .github/workflows/publish.yml | 255 - .github/workflows/test.yml | 100 - .github/workflows/test_bundles.yml | 189 - .github/workflows/test_coverage.yml | 128 - .github/workflows/test_install.yml | 86 - .gitignore | 188 - .npmignore | 227 - .npmrc | 28 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 52 +- benchmark/benchmark.js | 56 - branches.md | 53 - browser.js | 3 + browser.js.map | 1 + dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 29 - docs/types/index.d.ts | 53 - docs/types/test.ts | 57 - examples/index.js | 33 - index.js | 3 + index.js.map | 1 + lib/index.js | 43 - lib/main.js | 94 - package.json | 53 +- stats_browser.html | 6177 +++++++++++++++++++++ stats_node.html | 6177 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 108 - 45 files changed, 12399 insertions(+), 3810 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md create mode 100644 browser.js create mode 100644 browser.js.map 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/index.d.ts delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js create mode 100644 index.js create mode 100644 index.js.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats_browser.html create mode 100644 stats_node.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 13e9c39..0000000 --- a/.editorconfig +++ /dev/null @@ -1,186 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index be8be70..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-11-01T00:29:37.319Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 52cd9c4..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/base/remove-last-code-point) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 533eeee..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/base/remove-last-code-point) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 33382c1..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: '29 5 * * 0' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA corresponding to v3.1.3 - uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA corresponding to v3.0.3: - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 265afda..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,797 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA corresponding to v2.0.0 - uses: act10ns/slack@ed1309ab9862e57e9e583e51c7889486b9a00b0f - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n +``` + +If no recognized module system is present, access bundle contents via the global scope: + +```html + ``` #### removeLastCodePoint( str, n ) @@ -89,8 +97,13 @@ out = removeLastCodePoint( 'foo bar', 10 ); -```javascript -var removeLastCodePoint = require( '@stdlib/string-base-remove-last-code-point' ); +```html + + + + + + + ```
diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index d846d34..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,56 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var removeLast = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var values; - var out; - var i; - - values = [ - 'beep boop', - 'foo bar', - 'xyz abc', - '🐶🐮🐷🐰🐸' - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = removeLast( values[ i%values.length ], 1 ); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( !isString( out ) ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 41f4db9..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/base/remove-last-code-point" -%% click B href "https://github.com/stdlib-js/string-base-remove-last-code-point/tree/main" -%% click C href "https://github.com/stdlib-js/string-base-remove-last-code-point/tree/production" -%% click D href "https://github.com/stdlib-js/string-base-remove-last-code-point/tree/esm" -%% click E href "https://github.com/stdlib-js/string-base-remove-last-code-point/tree/deno" -%% click F href "https://github.com/stdlib-js/string-base-remove-last-code-point/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/base/remove-last-code-point -[production-url]: https://github.com/stdlib-js/string-base-remove-last-code-point/tree/production -[deno-url]: https://github.com/stdlib-js/string-base-remove-last-code-point/tree/deno -[umd-url]: https://github.com/stdlib-js/string-base-remove-last-code-point/tree/umd -[esm-url]: https://github.com/stdlib-js/string-base-remove-last-code-point/tree/esm \ No newline at end of file diff --git a/browser.js b/browser.js new file mode 100644 index 0000000..d3e0f5b --- /dev/null +++ b/browser.js @@ -0,0 +1,3 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +var e,t;e=this,t=function(){"use strict";var e=/[\uDC00-\uDFFF]/,t=/[\uD800-\uDBFF]/;return function(n,f){var i,o,r,u;if(0===f)return n;for(r=0,u=n.length-1;u>=0;u--){if(i=n[u],r+=1,e.test(i)){if(0===u)break;o=n[u-1],t.test(o)&&(u-=1)}if(r===f)break}return n.substring(0,u)}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).removeLastCodePoint=t(); +//# sourceMappingURL=browser.js.map diff --git a/browser.js.map b/browser.js.map new file mode 100644 index 0000000..19908eb --- /dev/null +++ b/browser.js.map @@ -0,0 +1 @@ +{"version":3,"file":"browser.js","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\nvar RE_UTF16_LOW_SURROGATE = /[\\uDC00-\\uDFFF]/; // TODO: replace with stdlib pkg\nvar RE_UTF16_HIGH_SURROGATE = /[\\uD800-\\uDBFF]/; // TODO: replace with stdlib pkg\n\n\n// MAIN //\n\n/**\n* Removes the last `n` Unicode code points of a string.\n*\n* @param {string} str - input string\n* @param {NonNegativeInteger} n - number of Unicode code points to remove\n* @returns {string} output string\n*\n* @example\n* var out = removeLast( 'last man standing', 1 );\n* // returns 'last man standin'\n*\n* @example\n* var out = removeLast( 'presidential election', 1 );\n* // returns 'presidential electio'\n*\n* @example\n* var out = removeLast( 'JavaScript', 1 );\n* // returns 'JavaScrip'\n*\n* @example\n* var out = removeLast( 'Hidden Treasures', 1 );\n* // returns 'Hidden Treasure'\n*/\nfunction removeLast( str, n ) {\n\tvar len;\n\tvar ch1;\n\tvar ch2;\n\tvar cnt;\n\tvar i;\n\tif ( n === 0 ) {\n\t\treturn str;\n\t}\n\tlen = str.length;\n\tcnt = 0;\n\n\t// Process the string one Unicode code unit at a time and count UTF-16 surrogate pairs as a single Unicode code point...\n\tfor ( i = len - 1; i >= 0; i-- ) {\n\t\tch1 = str[ i ];\n\t\tcnt += 1;\n\n\t\t// Check for a low UTF-16 surrogate...\n\t\tif ( RE_UTF16_LOW_SURROGATE.test( ch1 ) ) {\n\t\t\t// Check for an unpaired surrogate at the end of the input string...\n\t\t\tif ( i === 0 ) {\n\t\t\t\t// We found an unpaired surrogate...\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\t// Check whether the high surrogate is paired with a low surrogate...\n\t\t\tch2 = str[ i-1 ];\n\t\t\tif ( RE_UTF16_HIGH_SURROGATE.test( ch2 ) ) {\n\t\t\t\t// We found a surrogate pair:\n\t\t\t\ti -= 1; // bump the index to process the next code unit\n\t\t\t}\n\t\t}\n\t\t// Check whether we've found the desired number of code points...\n\t\tif ( cnt === n ) {\n\t\t\tbreak;\n\t\t}\n\t}\n\treturn str.substring( 0, i );\n}\n\n\n// EXPORTS //\n\nexport default removeLast;\n"],"names":["RE_UTF16_LOW_SURROGATE","RE_UTF16_HIGH_SURROGATE","str","n","ch1","ch2","cnt","i","length","test","substring"],"mappings":";yCAsBA,IAAIA,EAAyB,kBACzBC,EAA0B,yBA4B9B,SAAqBC,EAAKC,GACzB,IACIC,EACAC,EACAC,EACAC,EACJ,GAAW,IAANJ,EACJ,OAAOD,EAMR,IAHAI,EAAM,EAGAC,EAJAL,EAAIM,OAIM,EAAGD,GAAK,EAAGA,IAAM,CAKhC,GAJAH,EAAMF,EAAKK,GACXD,GAAO,EAGFN,EAAuBS,KAAML,GAAQ,CAEzC,GAAW,IAANG,EAEJ,MAGDF,EAAMH,EAAKK,EAAE,GACRN,EAAwBQ,KAAMJ,KAElCE,GAAK,EAEN,CAED,GAAKD,IAAQH,EACZ,KAED,CACD,OAAOD,EAAIQ,UAAW,EAAGH,EAC1B"} \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index 8c96fd7..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import removeLast from '../docs/types/index'; -export = removeLast; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index e6b7220..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var s=function(e,t){return function(){return t||e((t={exports:{}}).exports,t),t.exports}};var f=s(function(D,n){ -var F=/[\uDC00-\uDFFF]/,c=/[\uD800-\uDBFF]/;function R(e,t){var i,u,v,a,r;if(t===0)return e;for(i=e.length,a=0,r=i-1;r>=0;r--){if(u=e[r],a+=1,F.test(u)){if(r===0)break;v=e[r-1],c.test(v)&&(r-=1)}if(a===t)break}return e.substring(0,r)}n.exports=R -});var _=f();module.exports=_; -/** @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 72561cf..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\nvar RE_UTF16_LOW_SURROGATE = /[\\uDC00-\\uDFFF]/; // TODO: replace with stdlib pkg\nvar RE_UTF16_HIGH_SURROGATE = /[\\uD800-\\uDBFF]/; // TODO: replace with stdlib pkg\n\n\n// MAIN //\n\n/**\n* Removes the last `n` Unicode code points of a string.\n*\n* @param {string} str - input string\n* @param {NonNegativeInteger} n - number of Unicode code points to remove\n* @returns {string} output string\n*\n* @example\n* var out = removeLast( 'last man standing', 1 );\n* // returns 'last man standin'\n*\n* @example\n* var out = removeLast( 'presidential election', 1 );\n* // returns 'presidential electio'\n*\n* @example\n* var out = removeLast( 'JavaScript', 1 );\n* // returns 'JavaScrip'\n*\n* @example\n* var out = removeLast( 'Hidden Treasures', 1 );\n* // returns 'Hidden Treasure'\n*/\nfunction removeLast( str, n ) {\n\tvar len;\n\tvar ch1;\n\tvar ch2;\n\tvar cnt;\n\tvar i;\n\tif ( n === 0 ) {\n\t\treturn str;\n\t}\n\tlen = str.length;\n\tcnt = 0;\n\n\t// Process the string one Unicode code unit at a time and count UTF-16 surrogate pairs as a single Unicode code point...\n\tfor ( i = len - 1; i >= 0; i-- ) {\n\t\tch1 = str[ i ];\n\t\tcnt += 1;\n\n\t\t// Check for a low UTF-16 surrogate...\n\t\tif ( RE_UTF16_LOW_SURROGATE.test( ch1 ) ) {\n\t\t\t// Check for an unpaired surrogate at the end of the input string...\n\t\t\tif ( i === 0 ) {\n\t\t\t\t// We found an unpaired surrogate...\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\t// Check whether the high surrogate is paired with a low surrogate...\n\t\t\tch2 = str[ i-1 ];\n\t\t\tif ( RE_UTF16_HIGH_SURROGATE.test( ch2 ) ) {\n\t\t\t\t// We found a surrogate pair:\n\t\t\t\ti -= 1; // bump the index to process the next code unit\n\t\t\t}\n\t\t}\n\t\t// Check whether we've found the desired number of code points...\n\t\tif ( cnt === n ) {\n\t\t\tbreak;\n\t\t}\n\t}\n\treturn str.substring( 0, i );\n}\n\n\n// EXPORTS //\n\nmodule.exports = removeLast;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Remove the last `n` Unicode code points of a string.\n*\n* @module @stdlib/string-base-remove-last-code-point\n*\n* @example\n* var removeLast = require( '@stdlib/string-base-remove-last-code-point' );\n*\n* var out = removeLast( 'last man standing', 1 );\n* // returns 'last man standin'\n*\n* out = removeLast( 'Hidden Treasures', 1 );\n* // returns 'Hidden Treasure';\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,EAAyB,kBACzBC,EAA0B,kBA4B9B,SAASC,EAAYC,EAAKC,EAAI,CAC7B,IAAIC,EACAC,EACAC,EACAC,EACAC,EACJ,GAAKL,IAAM,EACV,OAAOD,EAMR,IAJAE,EAAMF,EAAI,OACVK,EAAM,EAGAC,EAAIJ,EAAM,EAAGI,GAAK,EAAGA,IAAM,CAKhC,GAJAH,EAAMH,EAAKM,CAAE,EACbD,GAAO,EAGFR,EAAuB,KAAMM,CAAI,EAAI,CAEzC,GAAKG,IAAM,EAEV,MAGDF,EAAMJ,EAAKM,EAAE,CAAE,EACVR,EAAwB,KAAMM,CAAI,IAEtCE,GAAK,EAEP,CAEA,GAAKD,IAAQJ,EACZ,KAEF,CACA,OAAOD,EAAI,UAAW,EAAGM,CAAE,CAC5B,CAKAV,EAAO,QAAUG,ICxDjB,IAAIQ,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "RE_UTF16_LOW_SURROGATE", "RE_UTF16_HIGH_SURROGATE", "removeLast", "str", "n", "len", "ch1", "ch2", "cnt", "i", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index a08ea55..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,29 +0,0 @@ - -{{alias}}( str, n ) - Removes the last `n` Unicode code points of a string. - - Parameters - ---------- - str: string - Input string. - - n: integer - Number of Unicode code points to remove. - - Returns - ------- - out: string - Output string. - - Examples - -------- - > var out = {{alias}}( 'beep', 1 ) - 'bee' - > out = {{alias}}( 'Boop', 1 ) - 'Boo' - > out = {{alias}}( 'foo bar', 5 ) - 'fo' - - See Also - -------- - diff --git a/docs/types/index.d.ts b/docs/types/index.d.ts deleted file mode 100644 index 8a1c90b..0000000 --- a/docs/types/index.d.ts +++ /dev/null @@ -1,53 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 - -/** -* Removes the last `n` Unicode code points of a string. -* -* @param str - input string -* @param n - number of code points to remove -* @returns output string -* -* @example -* var out = removeLast( 'last man standing', 1 ); -* // returns 'last man standin' -* -* @example -* var out = removeLast( 'presidential election', 1 ); -* // returns 'presidential electio' -* -* @example -* var out = removeLast( 'JavaScript', 1 ); -* // returns 'JavaScrip' -* -* @example -* var out = removeLast( 'Hidden Treasures', 1 ); -* // returns 'Hidden Treasure' -* -* @example -* var out = removeLast( 'foo bar', 5 ); -* // returns 'fo' -*/ -declare function removeLast( str: string, n: number ): string; - - -// EXPORTS // - -export = removeLast; diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index fd426d2..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,57 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 removeLast = require( './index' ); - - -// TESTS // - -// The function returns a string... -{ - removeLast( 'abc', 1 ); // $ExpectType string -} - -// The compiler throws an error if the function is provided a value other than a string... -{ - removeLast( true, 1 ); // $ExpectError - removeLast( false, 1 ); // $ExpectError - removeLast( null, 1 ); // $ExpectError - removeLast( undefined, 1 ); // $ExpectError - removeLast( 5, 1 ); // $ExpectError - removeLast( [], 1 ); // $ExpectError - removeLast( {}, 1 ); // $ExpectError - removeLast( ( x: number ): number => x, 1 ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument that is not a number... -{ - removeLast( 'abc', true ); // $ExpectError - removeLast( 'abc', false ); // $ExpectError - removeLast( 'abc', null ); // $ExpectError - removeLast( 'abc', 'abc' ); // $ExpectError - removeLast( 'abc', [] ); // $ExpectError - removeLast( 'abc', {} ); // $ExpectError - removeLast( 'abc', ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - removeLast(); // $ExpectError - removeLast( 'abc' ); // $ExpectError - removeLast( 'abc', 1, 2 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 085633e..0000000 --- a/examples/index.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var removeLastCodePoint = require( './../lib' ); - -console.log( removeLastCodePoint( 'presidential election', 1 ) ); -// => 'presidential electio' - -console.log( removeLastCodePoint( 'JavaScript', 1 ) ); -// => 'JavaScrip' - -console.log( removeLastCodePoint( 'The Last of the Mohicans', 5 ) ); -// => 'The Last of the Moh' - -console.log( removeLastCodePoint( 'अनुच्छेद', 1 ) ); -// => 'अनुच्छे' diff --git a/index.js b/index.js new file mode 100644 index 0000000..0185898 --- /dev/null +++ b/index.js @@ -0,0 +1,3 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +var e,t;e=this,t=function(){"use strict";var e=/[\uDC00-\uDFFF]/,t=/[\uD800-\uDBFF]/;return function(n,f){var i,o,r,u;if(0===f)return n;for(r=0,u=n.length-1;u>=0;u--){if(i=n[u],r+=1,e.test(i)){if(0===u)break;o=n[u-1],t.test(o)&&(u-=1)}if(r===f)break}return n.substring(0,u)}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).removeLastCodePoint=t(); +//# sourceMappingURL=index.js.map diff --git a/index.js.map b/index.js.map new file mode 100644 index 0000000..d557af8 --- /dev/null +++ b/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\nvar RE_UTF16_LOW_SURROGATE = /[\\uDC00-\\uDFFF]/; // TODO: replace with stdlib pkg\nvar RE_UTF16_HIGH_SURROGATE = /[\\uD800-\\uDBFF]/; // TODO: replace with stdlib pkg\n\n\n// MAIN //\n\n/**\n* Removes the last `n` Unicode code points of a string.\n*\n* @param {string} str - input string\n* @param {NonNegativeInteger} n - number of Unicode code points to remove\n* @returns {string} output string\n*\n* @example\n* var out = removeLast( 'last man standing', 1 );\n* // returns 'last man standin'\n*\n* @example\n* var out = removeLast( 'presidential election', 1 );\n* // returns 'presidential electio'\n*\n* @example\n* var out = removeLast( 'JavaScript', 1 );\n* // returns 'JavaScrip'\n*\n* @example\n* var out = removeLast( 'Hidden Treasures', 1 );\n* // returns 'Hidden Treasure'\n*/\nfunction removeLast( str, n ) {\n\tvar len;\n\tvar ch1;\n\tvar ch2;\n\tvar cnt;\n\tvar i;\n\tif ( n === 0 ) {\n\t\treturn str;\n\t}\n\tlen = str.length;\n\tcnt = 0;\n\n\t// Process the string one Unicode code unit at a time and count UTF-16 surrogate pairs as a single Unicode code point...\n\tfor ( i = len - 1; i >= 0; i-- ) {\n\t\tch1 = str[ i ];\n\t\tcnt += 1;\n\n\t\t// Check for a low UTF-16 surrogate...\n\t\tif ( RE_UTF16_LOW_SURROGATE.test( ch1 ) ) {\n\t\t\t// Check for an unpaired surrogate at the end of the input string...\n\t\t\tif ( i === 0 ) {\n\t\t\t\t// We found an unpaired surrogate...\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\t// Check whether the high surrogate is paired with a low surrogate...\n\t\t\tch2 = str[ i-1 ];\n\t\t\tif ( RE_UTF16_HIGH_SURROGATE.test( ch2 ) ) {\n\t\t\t\t// We found a surrogate pair:\n\t\t\t\ti -= 1; // bump the index to process the next code unit\n\t\t\t}\n\t\t}\n\t\t// Check whether we've found the desired number of code points...\n\t\tif ( cnt === n ) {\n\t\t\tbreak;\n\t\t}\n\t}\n\treturn str.substring( 0, i );\n}\n\n\n// EXPORTS //\n\nexport default removeLast;\n"],"names":["RE_UTF16_LOW_SURROGATE","RE_UTF16_HIGH_SURROGATE","str","n","ch1","ch2","cnt","i","length","test","substring"],"mappings":";yCAsBA,IAAIA,EAAyB,kBACzBC,EAA0B,yBA4B9B,SAAqBC,EAAKC,GACzB,IACIC,EACAC,EACAC,EACAC,EACJ,GAAW,IAANJ,EACJ,OAAOD,EAMR,IAHAI,EAAM,EAGAC,EAJAL,EAAIM,OAIM,EAAGD,GAAK,EAAGA,IAAM,CAKhC,GAJAH,EAAMF,EAAKK,GACXD,GAAO,EAGFN,EAAuBS,KAAML,GAAQ,CAEzC,GAAW,IAANG,EAEJ,MAGDF,EAAMH,EAAKK,EAAE,GACRN,EAAwBQ,KAAMJ,KAElCE,GAAK,EAEN,CAED,GAAKD,IAAQH,EACZ,KAED,CACD,OAAOD,EAAIQ,UAAW,EAAGH,EAC1B"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 9860da0..0000000 --- a/lib/index.js +++ /dev/null @@ -1,43 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Remove the last `n` Unicode code points of a string. -* -* @module @stdlib/string-base-remove-last-code-point -* -* @example -* var removeLast = require( '@stdlib/string-base-remove-last-code-point' ); -* -* var out = removeLast( 'last man standing', 1 ); -* // returns 'last man standin' -* -* out = removeLast( 'Hidden Treasures', 1 ); -* // returns 'Hidden Treasure'; -*/ - -// 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 fc34187..0000000 --- a/lib/main.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// VARIABLES // - -var RE_UTF16_LOW_SURROGATE = /[\uDC00-\uDFFF]/; // TODO: replace with stdlib pkg -var RE_UTF16_HIGH_SURROGATE = /[\uD800-\uDBFF]/; // TODO: replace with stdlib pkg - - -// MAIN // - -/** -* Removes the last `n` Unicode code points of a string. -* -* @param {string} str - input string -* @param {NonNegativeInteger} n - number of Unicode code points to remove -* @returns {string} output string -* -* @example -* var out = removeLast( 'last man standing', 1 ); -* // returns 'last man standin' -* -* @example -* var out = removeLast( 'presidential election', 1 ); -* // returns 'presidential electio' -* -* @example -* var out = removeLast( 'JavaScript', 1 ); -* // returns 'JavaScrip' -* -* @example -* var out = removeLast( 'Hidden Treasures', 1 ); -* // returns 'Hidden Treasure' -*/ -function removeLast( str, n ) { - var len; - var ch1; - var ch2; - var cnt; - var i; - if ( n === 0 ) { - return str; - } - len = str.length; - cnt = 0; - - // Process the string one Unicode code unit at a time and count UTF-16 surrogate pairs as a single Unicode code point... - for ( i = len - 1; i >= 0; i-- ) { - ch1 = str[ i ]; - cnt += 1; - - // Check for a low UTF-16 surrogate... - if ( RE_UTF16_LOW_SURROGATE.test( ch1 ) ) { - // Check for an unpaired surrogate at the end of the input string... - if ( i === 0 ) { - // We found an unpaired surrogate... - break; - } - // Check whether the high surrogate is paired with a low surrogate... - ch2 = str[ i-1 ]; - if ( RE_UTF16_HIGH_SURROGATE.test( ch2 ) ) { - // We found a surrogate pair: - i -= 1; // bump the index to process the next code unit - } - } - // Check whether we've found the desired number of code points... - if ( cnt === n ) { - break; - } - } - return str.substring( 0, i ); -} - - -// EXPORTS // - -module.exports = removeLast; diff --git a/package.json b/package.json index 2f22895..2328e01 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,7 @@ "version": "0.1.1", "description": "Remove the last Unicode code point of a string.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "main": "./index.js", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,31 +12,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/error-tools-fmtprodmsg": "^0.1.1" - }, - "devDependencies": { - "@stdlib/assert-is-string": "^0.1.1", - "@stdlib/bench": "^0.1.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdstring", @@ -81,4 +32,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/stats_browser.html b/stats_browser.html new file mode 100644 index 0000000..cba2c4c --- /dev/null +++ b/stats_browser.html @@ -0,0 +1,6177 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/stats_node.html b/stats_node.html new file mode 100644 index 0000000..30d4349 --- /dev/null +++ b/stats_node.html @@ -0,0 +1,6177 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index a25545e..0000000 --- a/test/test.js +++ /dev/null @@ -1,108 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var removeLast = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof removeLast, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns an empty string if provided an empty string', function test( t ) { - t.strictEqual( removeLast( '', 1 ), '', 'returns expected value' ); - t.strictEqual( removeLast( '', 2 ), '', 'returns expected value' ); - t.strictEqual( removeLast( '', 3 ), '', 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns the input string if provided zero as the second argument', function test( t ) { - t.strictEqual( removeLast( 'hello world', 0 ), 'hello world', 'returns expected value' ); - t.end(); -}); - -tape( 'the function removes the last Unicode code point of a provided string (ascii)', function test( t ) { - var out; - - out = removeLast( 'hello world', 1 ); - t.strictEqual( out, 'hello worl', 'returns expected value' ); - - out = removeLast( '!!!', 1 ); - t.strictEqual( out, '!!', 'returns expected value' ); - - out = removeLast( 'Hello World', 1 ); - t.strictEqual( out, 'Hello Worl', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function removes the last Unicode code point of a provided string (Unicode)', function test( t ) { - var out; - - out = removeLast( 'अनुच्छेद', 1 ); - t.strictEqual( out, 'अनुच्छे', 'returns expected value' ); - - out = removeLast( '六书/六書', 1 ); - t.strictEqual( out, '六书/六', 'returns expected value' ); - - out = removeLast( '𐒻𐓟', 1 ); - t.strictEqual( out, '𐒻', 'returns expected value' ); - - out = removeLast( '𐒻𐓟', 1 ); - t.strictEqual( out, '𐒻', 'returns expected value' ); - - out = removeLast( '\uDC00', 1 ); - t.strictEqual( out, '', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports removing the last `n` Unicode code points of a provided string', function test( t ) { - var out; - - out = removeLast( 'hello world', 1 ); - t.strictEqual( out, 'hello worl', 'returns expected value' ); - - out = removeLast( 'hello world', 7 ); - t.strictEqual( out, 'hell', 'returns expected value' ); - - out = removeLast( '!!!', 1 ); - t.strictEqual( out, '!!', 'returns expected value' ); - - out = removeLast( '!!!', 2 ); - t.strictEqual( out, '!', 'returns expected value' ); - - out = removeLast( 'अनुच्छेद', 1 ); - t.strictEqual( out, 'अनुच्छे', 'returns expected value' ); - - out = removeLast( '六书/六書', 3 ); - t.strictEqual( out, '六书', 'returns expected value' ); - - out = removeLast( '𐒻𐓟𐓟', 2 ); - t.strictEqual( out, '𐒻', 'returns expected value' ); - - t.end(); -}); From 1c616a72a05d996e620c72e839c02a3b010e06c4 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Dec 2023 00:33:27 +0000 Subject: [PATCH 27/92] Transform error messages --- package.json | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 9095da0..f25b3a6 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,9 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": {}, + "dependencies": { + "@stdlib/error-tools-fmtprodmsg": "^0.1.1" + }, "devDependencies": { "@stdlib/assert-is-string": "^0.1.1", "@stdlib/bench": "^0.2.1", @@ -79,4 +81,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From a8b4f1816bbf8a922949c9ae11cf9fe8fd6fd4ac Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Dec 2023 00:57:48 +0000 Subject: [PATCH 28/92] Remove files --- browser.js | 3 - browser.js.map | 1 - index.js | 3 - index.js.map | 1 - stats_browser.html | 6177 -------------------------------------------- stats_node.html | 6177 -------------------------------------------- 6 files changed, 12362 deletions(-) delete mode 100644 browser.js delete mode 100644 browser.js.map delete mode 100644 index.js delete mode 100644 index.js.map delete mode 100644 stats_browser.html delete mode 100644 stats_node.html diff --git a/browser.js b/browser.js deleted file mode 100644 index d3e0f5b..0000000 --- a/browser.js +++ /dev/null @@ -1,3 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -var e,t;e=this,t=function(){"use strict";var e=/[\uDC00-\uDFFF]/,t=/[\uD800-\uDBFF]/;return function(n,f){var i,o,r,u;if(0===f)return n;for(r=0,u=n.length-1;u>=0;u--){if(i=n[u],r+=1,e.test(i)){if(0===u)break;o=n[u-1],t.test(o)&&(u-=1)}if(r===f)break}return n.substring(0,u)}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).removeLastCodePoint=t(); -//# sourceMappingURL=browser.js.map diff --git a/browser.js.map b/browser.js.map deleted file mode 100644 index 19908eb..0000000 --- a/browser.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"browser.js","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\nvar RE_UTF16_LOW_SURROGATE = /[\\uDC00-\\uDFFF]/; // TODO: replace with stdlib pkg\nvar RE_UTF16_HIGH_SURROGATE = /[\\uD800-\\uDBFF]/; // TODO: replace with stdlib pkg\n\n\n// MAIN //\n\n/**\n* Removes the last `n` Unicode code points of a string.\n*\n* @param {string} str - input string\n* @param {NonNegativeInteger} n - number of Unicode code points to remove\n* @returns {string} output string\n*\n* @example\n* var out = removeLast( 'last man standing', 1 );\n* // returns 'last man standin'\n*\n* @example\n* var out = removeLast( 'presidential election', 1 );\n* // returns 'presidential electio'\n*\n* @example\n* var out = removeLast( 'JavaScript', 1 );\n* // returns 'JavaScrip'\n*\n* @example\n* var out = removeLast( 'Hidden Treasures', 1 );\n* // returns 'Hidden Treasure'\n*/\nfunction removeLast( str, n ) {\n\tvar len;\n\tvar ch1;\n\tvar ch2;\n\tvar cnt;\n\tvar i;\n\tif ( n === 0 ) {\n\t\treturn str;\n\t}\n\tlen = str.length;\n\tcnt = 0;\n\n\t// Process the string one Unicode code unit at a time and count UTF-16 surrogate pairs as a single Unicode code point...\n\tfor ( i = len - 1; i >= 0; i-- ) {\n\t\tch1 = str[ i ];\n\t\tcnt += 1;\n\n\t\t// Check for a low UTF-16 surrogate...\n\t\tif ( RE_UTF16_LOW_SURROGATE.test( ch1 ) ) {\n\t\t\t// Check for an unpaired surrogate at the end of the input string...\n\t\t\tif ( i === 0 ) {\n\t\t\t\t// We found an unpaired surrogate...\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\t// Check whether the high surrogate is paired with a low surrogate...\n\t\t\tch2 = str[ i-1 ];\n\t\t\tif ( RE_UTF16_HIGH_SURROGATE.test( ch2 ) ) {\n\t\t\t\t// We found a surrogate pair:\n\t\t\t\ti -= 1; // bump the index to process the next code unit\n\t\t\t}\n\t\t}\n\t\t// Check whether we've found the desired number of code points...\n\t\tif ( cnt === n ) {\n\t\t\tbreak;\n\t\t}\n\t}\n\treturn str.substring( 0, i );\n}\n\n\n// EXPORTS //\n\nexport default removeLast;\n"],"names":["RE_UTF16_LOW_SURROGATE","RE_UTF16_HIGH_SURROGATE","str","n","ch1","ch2","cnt","i","length","test","substring"],"mappings":";yCAsBA,IAAIA,EAAyB,kBACzBC,EAA0B,yBA4B9B,SAAqBC,EAAKC,GACzB,IACIC,EACAC,EACAC,EACAC,EACJ,GAAW,IAANJ,EACJ,OAAOD,EAMR,IAHAI,EAAM,EAGAC,EAJAL,EAAIM,OAIM,EAAGD,GAAK,EAAGA,IAAM,CAKhC,GAJAH,EAAMF,EAAKK,GACXD,GAAO,EAGFN,EAAuBS,KAAML,GAAQ,CAEzC,GAAW,IAANG,EAEJ,MAGDF,EAAMH,EAAKK,EAAE,GACRN,EAAwBQ,KAAMJ,KAElCE,GAAK,EAEN,CAED,GAAKD,IAAQH,EACZ,KAED,CACD,OAAOD,EAAIQ,UAAW,EAAGH,EAC1B"} \ No newline at end of file diff --git a/index.js b/index.js deleted file mode 100644 index 0185898..0000000 --- a/index.js +++ /dev/null @@ -1,3 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -var e,t;e=this,t=function(){"use strict";var e=/[\uDC00-\uDFFF]/,t=/[\uD800-\uDBFF]/;return function(n,f){var i,o,r,u;if(0===f)return n;for(r=0,u=n.length-1;u>=0;u--){if(i=n[u],r+=1,e.test(i)){if(0===u)break;o=n[u-1],t.test(o)&&(u-=1)}if(r===f)break}return n.substring(0,u)}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).removeLastCodePoint=t(); -//# sourceMappingURL=index.js.map diff --git a/index.js.map b/index.js.map deleted file mode 100644 index d557af8..0000000 --- a/index.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.js","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\nvar RE_UTF16_LOW_SURROGATE = /[\\uDC00-\\uDFFF]/; // TODO: replace with stdlib pkg\nvar RE_UTF16_HIGH_SURROGATE = /[\\uD800-\\uDBFF]/; // TODO: replace with stdlib pkg\n\n\n// MAIN //\n\n/**\n* Removes the last `n` Unicode code points of a string.\n*\n* @param {string} str - input string\n* @param {NonNegativeInteger} n - number of Unicode code points to remove\n* @returns {string} output string\n*\n* @example\n* var out = removeLast( 'last man standing', 1 );\n* // returns 'last man standin'\n*\n* @example\n* var out = removeLast( 'presidential election', 1 );\n* // returns 'presidential electio'\n*\n* @example\n* var out = removeLast( 'JavaScript', 1 );\n* // returns 'JavaScrip'\n*\n* @example\n* var out = removeLast( 'Hidden Treasures', 1 );\n* // returns 'Hidden Treasure'\n*/\nfunction removeLast( str, n ) {\n\tvar len;\n\tvar ch1;\n\tvar ch2;\n\tvar cnt;\n\tvar i;\n\tif ( n === 0 ) {\n\t\treturn str;\n\t}\n\tlen = str.length;\n\tcnt = 0;\n\n\t// Process the string one Unicode code unit at a time and count UTF-16 surrogate pairs as a single Unicode code point...\n\tfor ( i = len - 1; i >= 0; i-- ) {\n\t\tch1 = str[ i ];\n\t\tcnt += 1;\n\n\t\t// Check for a low UTF-16 surrogate...\n\t\tif ( RE_UTF16_LOW_SURROGATE.test( ch1 ) ) {\n\t\t\t// Check for an unpaired surrogate at the end of the input string...\n\t\t\tif ( i === 0 ) {\n\t\t\t\t// We found an unpaired surrogate...\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\t// Check whether the high surrogate is paired with a low surrogate...\n\t\t\tch2 = str[ i-1 ];\n\t\t\tif ( RE_UTF16_HIGH_SURROGATE.test( ch2 ) ) {\n\t\t\t\t// We found a surrogate pair:\n\t\t\t\ti -= 1; // bump the index to process the next code unit\n\t\t\t}\n\t\t}\n\t\t// Check whether we've found the desired number of code points...\n\t\tif ( cnt === n ) {\n\t\t\tbreak;\n\t\t}\n\t}\n\treturn str.substring( 0, i );\n}\n\n\n// EXPORTS //\n\nexport default removeLast;\n"],"names":["RE_UTF16_LOW_SURROGATE","RE_UTF16_HIGH_SURROGATE","str","n","ch1","ch2","cnt","i","length","test","substring"],"mappings":";yCAsBA,IAAIA,EAAyB,kBACzBC,EAA0B,yBA4B9B,SAAqBC,EAAKC,GACzB,IACIC,EACAC,EACAC,EACAC,EACJ,GAAW,IAANJ,EACJ,OAAOD,EAMR,IAHAI,EAAM,EAGAC,EAJAL,EAAIM,OAIM,EAAGD,GAAK,EAAGA,IAAM,CAKhC,GAJAH,EAAMF,EAAKK,GACXD,GAAO,EAGFN,EAAuBS,KAAML,GAAQ,CAEzC,GAAW,IAANG,EAEJ,MAGDF,EAAMH,EAAKK,EAAE,GACRN,EAAwBQ,KAAMJ,KAElCE,GAAK,EAEN,CAED,GAAKD,IAAQH,EACZ,KAED,CACD,OAAOD,EAAIQ,UAAW,EAAGH,EAC1B"} \ No newline at end of file diff --git a/stats_browser.html b/stats_browser.html deleted file mode 100644 index cba2c4c..0000000 --- a/stats_browser.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - diff --git a/stats_node.html b/stats_node.html deleted file mode 100644 index 30d4349..0000000 --- a/stats_node.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 80c55e986488d1330c320374202995b390275863 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Dec 2023 00:58:29 +0000 Subject: [PATCH 29/92] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 797 --- .github/workflows/publish.yml | 255 - .github/workflows/test.yml | 100 - .github/workflows/test_bundles.yml | 189 - .github/workflows/test_coverage.yml | 128 - .github/workflows/test_install.yml | 86 - .gitignore | 188 - .npmignore | 227 - .npmrc | 28 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 52 +- benchmark/benchmark.js | 56 - branches.md | 53 - browser.js | 3 + browser.js.map | 1 + dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 29 - docs/types/index.d.ts | 53 - docs/types/test.ts | 57 - examples/index.js | 33 - index.js | 3 + index.js.map | 1 + lib/index.js | 43 - lib/main.js | 94 - package.json | 53 +- stats_browser.html | 6177 +++++++++++++++++++++ stats_node.html | 6177 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 108 - 45 files changed, 12399 insertions(+), 3805 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md create mode 100644 browser.js create mode 100644 browser.js.map 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/index.d.ts delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js create mode 100644 index.js create mode 100644 index.js.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats_browser.html create mode 100644 stats_node.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 74da03e..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-12-01T00:31:52.565Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 52cd9c4..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/base/remove-last-code-point) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 533eeee..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/base/remove-last-code-point) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 33382c1..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: '29 5 * * 0' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA corresponding to v3.1.3 - uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA corresponding to v3.0.3: - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 265afda..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,797 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA corresponding to v2.0.0 - uses: act10ns/slack@ed1309ab9862e57e9e583e51c7889486b9a00b0f - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n +``` + +If no recognized module system is present, access bundle contents via the global scope: + +```html + ``` #### removeLastCodePoint( str, n ) @@ -89,8 +97,13 @@ out = removeLastCodePoint( 'foo bar', 10 ); -```javascript -var removeLastCodePoint = require( '@stdlib/string-base-remove-last-code-point' ); +```html + + + + + + + ```
diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index d846d34..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,56 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var removeLast = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var values; - var out; - var i; - - values = [ - 'beep boop', - 'foo bar', - 'xyz abc', - '🐶🐮🐷🐰🐸' - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = removeLast( values[ i%values.length ], 1 ); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( !isString( out ) ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 41f4db9..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/base/remove-last-code-point" -%% click B href "https://github.com/stdlib-js/string-base-remove-last-code-point/tree/main" -%% click C href "https://github.com/stdlib-js/string-base-remove-last-code-point/tree/production" -%% click D href "https://github.com/stdlib-js/string-base-remove-last-code-point/tree/esm" -%% click E href "https://github.com/stdlib-js/string-base-remove-last-code-point/tree/deno" -%% click F href "https://github.com/stdlib-js/string-base-remove-last-code-point/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/base/remove-last-code-point -[production-url]: https://github.com/stdlib-js/string-base-remove-last-code-point/tree/production -[deno-url]: https://github.com/stdlib-js/string-base-remove-last-code-point/tree/deno -[umd-url]: https://github.com/stdlib-js/string-base-remove-last-code-point/tree/umd -[esm-url]: https://github.com/stdlib-js/string-base-remove-last-code-point/tree/esm \ No newline at end of file diff --git a/browser.js b/browser.js new file mode 100644 index 0000000..d3e0f5b --- /dev/null +++ b/browser.js @@ -0,0 +1,3 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +var e,t;e=this,t=function(){"use strict";var e=/[\uDC00-\uDFFF]/,t=/[\uD800-\uDBFF]/;return function(n,f){var i,o,r,u;if(0===f)return n;for(r=0,u=n.length-1;u>=0;u--){if(i=n[u],r+=1,e.test(i)){if(0===u)break;o=n[u-1],t.test(o)&&(u-=1)}if(r===f)break}return n.substring(0,u)}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).removeLastCodePoint=t(); +//# sourceMappingURL=browser.js.map diff --git a/browser.js.map b/browser.js.map new file mode 100644 index 0000000..19908eb --- /dev/null +++ b/browser.js.map @@ -0,0 +1 @@ +{"version":3,"file":"browser.js","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\nvar RE_UTF16_LOW_SURROGATE = /[\\uDC00-\\uDFFF]/; // TODO: replace with stdlib pkg\nvar RE_UTF16_HIGH_SURROGATE = /[\\uD800-\\uDBFF]/; // TODO: replace with stdlib pkg\n\n\n// MAIN //\n\n/**\n* Removes the last `n` Unicode code points of a string.\n*\n* @param {string} str - input string\n* @param {NonNegativeInteger} n - number of Unicode code points to remove\n* @returns {string} output string\n*\n* @example\n* var out = removeLast( 'last man standing', 1 );\n* // returns 'last man standin'\n*\n* @example\n* var out = removeLast( 'presidential election', 1 );\n* // returns 'presidential electio'\n*\n* @example\n* var out = removeLast( 'JavaScript', 1 );\n* // returns 'JavaScrip'\n*\n* @example\n* var out = removeLast( 'Hidden Treasures', 1 );\n* // returns 'Hidden Treasure'\n*/\nfunction removeLast( str, n ) {\n\tvar len;\n\tvar ch1;\n\tvar ch2;\n\tvar cnt;\n\tvar i;\n\tif ( n === 0 ) {\n\t\treturn str;\n\t}\n\tlen = str.length;\n\tcnt = 0;\n\n\t// Process the string one Unicode code unit at a time and count UTF-16 surrogate pairs as a single Unicode code point...\n\tfor ( i = len - 1; i >= 0; i-- ) {\n\t\tch1 = str[ i ];\n\t\tcnt += 1;\n\n\t\t// Check for a low UTF-16 surrogate...\n\t\tif ( RE_UTF16_LOW_SURROGATE.test( ch1 ) ) {\n\t\t\t// Check for an unpaired surrogate at the end of the input string...\n\t\t\tif ( i === 0 ) {\n\t\t\t\t// We found an unpaired surrogate...\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\t// Check whether the high surrogate is paired with a low surrogate...\n\t\t\tch2 = str[ i-1 ];\n\t\t\tif ( RE_UTF16_HIGH_SURROGATE.test( ch2 ) ) {\n\t\t\t\t// We found a surrogate pair:\n\t\t\t\ti -= 1; // bump the index to process the next code unit\n\t\t\t}\n\t\t}\n\t\t// Check whether we've found the desired number of code points...\n\t\tif ( cnt === n ) {\n\t\t\tbreak;\n\t\t}\n\t}\n\treturn str.substring( 0, i );\n}\n\n\n// EXPORTS //\n\nexport default removeLast;\n"],"names":["RE_UTF16_LOW_SURROGATE","RE_UTF16_HIGH_SURROGATE","str","n","ch1","ch2","cnt","i","length","test","substring"],"mappings":";yCAsBA,IAAIA,EAAyB,kBACzBC,EAA0B,yBA4B9B,SAAqBC,EAAKC,GACzB,IACIC,EACAC,EACAC,EACAC,EACJ,GAAW,IAANJ,EACJ,OAAOD,EAMR,IAHAI,EAAM,EAGAC,EAJAL,EAAIM,OAIM,EAAGD,GAAK,EAAGA,IAAM,CAKhC,GAJAH,EAAMF,EAAKK,GACXD,GAAO,EAGFN,EAAuBS,KAAML,GAAQ,CAEzC,GAAW,IAANG,EAEJ,MAGDF,EAAMH,EAAKK,EAAE,GACRN,EAAwBQ,KAAMJ,KAElCE,GAAK,EAEN,CAED,GAAKD,IAAQH,EACZ,KAED,CACD,OAAOD,EAAIQ,UAAW,EAAGH,EAC1B"} \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index 8c96fd7..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import removeLast from '../docs/types/index'; -export = removeLast; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index e6b7220..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var s=function(e,t){return function(){return t||e((t={exports:{}}).exports,t),t.exports}};var f=s(function(D,n){ -var F=/[\uDC00-\uDFFF]/,c=/[\uD800-\uDBFF]/;function R(e,t){var i,u,v,a,r;if(t===0)return e;for(i=e.length,a=0,r=i-1;r>=0;r--){if(u=e[r],a+=1,F.test(u)){if(r===0)break;v=e[r-1],c.test(v)&&(r-=1)}if(a===t)break}return e.substring(0,r)}n.exports=R -});var _=f();module.exports=_; -/** @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 72561cf..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\nvar RE_UTF16_LOW_SURROGATE = /[\\uDC00-\\uDFFF]/; // TODO: replace with stdlib pkg\nvar RE_UTF16_HIGH_SURROGATE = /[\\uD800-\\uDBFF]/; // TODO: replace with stdlib pkg\n\n\n// MAIN //\n\n/**\n* Removes the last `n` Unicode code points of a string.\n*\n* @param {string} str - input string\n* @param {NonNegativeInteger} n - number of Unicode code points to remove\n* @returns {string} output string\n*\n* @example\n* var out = removeLast( 'last man standing', 1 );\n* // returns 'last man standin'\n*\n* @example\n* var out = removeLast( 'presidential election', 1 );\n* // returns 'presidential electio'\n*\n* @example\n* var out = removeLast( 'JavaScript', 1 );\n* // returns 'JavaScrip'\n*\n* @example\n* var out = removeLast( 'Hidden Treasures', 1 );\n* // returns 'Hidden Treasure'\n*/\nfunction removeLast( str, n ) {\n\tvar len;\n\tvar ch1;\n\tvar ch2;\n\tvar cnt;\n\tvar i;\n\tif ( n === 0 ) {\n\t\treturn str;\n\t}\n\tlen = str.length;\n\tcnt = 0;\n\n\t// Process the string one Unicode code unit at a time and count UTF-16 surrogate pairs as a single Unicode code point...\n\tfor ( i = len - 1; i >= 0; i-- ) {\n\t\tch1 = str[ i ];\n\t\tcnt += 1;\n\n\t\t// Check for a low UTF-16 surrogate...\n\t\tif ( RE_UTF16_LOW_SURROGATE.test( ch1 ) ) {\n\t\t\t// Check for an unpaired surrogate at the end of the input string...\n\t\t\tif ( i === 0 ) {\n\t\t\t\t// We found an unpaired surrogate...\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\t// Check whether the high surrogate is paired with a low surrogate...\n\t\t\tch2 = str[ i-1 ];\n\t\t\tif ( RE_UTF16_HIGH_SURROGATE.test( ch2 ) ) {\n\t\t\t\t// We found a surrogate pair:\n\t\t\t\ti -= 1; // bump the index to process the next code unit\n\t\t\t}\n\t\t}\n\t\t// Check whether we've found the desired number of code points...\n\t\tif ( cnt === n ) {\n\t\t\tbreak;\n\t\t}\n\t}\n\treturn str.substring( 0, i );\n}\n\n\n// EXPORTS //\n\nmodule.exports = removeLast;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Remove the last `n` Unicode code points of a string.\n*\n* @module @stdlib/string-base-remove-last-code-point\n*\n* @example\n* var removeLast = require( '@stdlib/string-base-remove-last-code-point' );\n*\n* var out = removeLast( 'last man standing', 1 );\n* // returns 'last man standin'\n*\n* out = removeLast( 'Hidden Treasures', 1 );\n* // returns 'Hidden Treasure';\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,EAAyB,kBACzBC,EAA0B,kBA4B9B,SAASC,EAAYC,EAAKC,EAAI,CAC7B,IAAIC,EACAC,EACAC,EACAC,EACAC,EACJ,GAAKL,IAAM,EACV,OAAOD,EAMR,IAJAE,EAAMF,EAAI,OACVK,EAAM,EAGAC,EAAIJ,EAAM,EAAGI,GAAK,EAAGA,IAAM,CAKhC,GAJAH,EAAMH,EAAKM,CAAE,EACbD,GAAO,EAGFR,EAAuB,KAAMM,CAAI,EAAI,CAEzC,GAAKG,IAAM,EAEV,MAGDF,EAAMJ,EAAKM,EAAE,CAAE,EACVR,EAAwB,KAAMM,CAAI,IAEtCE,GAAK,EAEP,CAEA,GAAKD,IAAQJ,EACZ,KAEF,CACA,OAAOD,EAAI,UAAW,EAAGM,CAAE,CAC5B,CAKAV,EAAO,QAAUG,ICxDjB,IAAIQ,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "RE_UTF16_LOW_SURROGATE", "RE_UTF16_HIGH_SURROGATE", "removeLast", "str", "n", "len", "ch1", "ch2", "cnt", "i", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index a08ea55..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,29 +0,0 @@ - -{{alias}}( str, n ) - Removes the last `n` Unicode code points of a string. - - Parameters - ---------- - str: string - Input string. - - n: integer - Number of Unicode code points to remove. - - Returns - ------- - out: string - Output string. - - Examples - -------- - > var out = {{alias}}( 'beep', 1 ) - 'bee' - > out = {{alias}}( 'Boop', 1 ) - 'Boo' - > out = {{alias}}( 'foo bar', 5 ) - 'fo' - - See Also - -------- - diff --git a/docs/types/index.d.ts b/docs/types/index.d.ts deleted file mode 100644 index 8a1c90b..0000000 --- a/docs/types/index.d.ts +++ /dev/null @@ -1,53 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 - -/** -* Removes the last `n` Unicode code points of a string. -* -* @param str - input string -* @param n - number of code points to remove -* @returns output string -* -* @example -* var out = removeLast( 'last man standing', 1 ); -* // returns 'last man standin' -* -* @example -* var out = removeLast( 'presidential election', 1 ); -* // returns 'presidential electio' -* -* @example -* var out = removeLast( 'JavaScript', 1 ); -* // returns 'JavaScrip' -* -* @example -* var out = removeLast( 'Hidden Treasures', 1 ); -* // returns 'Hidden Treasure' -* -* @example -* var out = removeLast( 'foo bar', 5 ); -* // returns 'fo' -*/ -declare function removeLast( str: string, n: number ): string; - - -// EXPORTS // - -export = removeLast; diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index fd426d2..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,57 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 removeLast = require( './index' ); - - -// TESTS // - -// The function returns a string... -{ - removeLast( 'abc', 1 ); // $ExpectType string -} - -// The compiler throws an error if the function is provided a value other than a string... -{ - removeLast( true, 1 ); // $ExpectError - removeLast( false, 1 ); // $ExpectError - removeLast( null, 1 ); // $ExpectError - removeLast( undefined, 1 ); // $ExpectError - removeLast( 5, 1 ); // $ExpectError - removeLast( [], 1 ); // $ExpectError - removeLast( {}, 1 ); // $ExpectError - removeLast( ( x: number ): number => x, 1 ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument that is not a number... -{ - removeLast( 'abc', true ); // $ExpectError - removeLast( 'abc', false ); // $ExpectError - removeLast( 'abc', null ); // $ExpectError - removeLast( 'abc', 'abc' ); // $ExpectError - removeLast( 'abc', [] ); // $ExpectError - removeLast( 'abc', {} ); // $ExpectError - removeLast( 'abc', ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - removeLast(); // $ExpectError - removeLast( 'abc' ); // $ExpectError - removeLast( 'abc', 1, 2 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 085633e..0000000 --- a/examples/index.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var removeLastCodePoint = require( './../lib' ); - -console.log( removeLastCodePoint( 'presidential election', 1 ) ); -// => 'presidential electio' - -console.log( removeLastCodePoint( 'JavaScript', 1 ) ); -// => 'JavaScrip' - -console.log( removeLastCodePoint( 'The Last of the Mohicans', 5 ) ); -// => 'The Last of the Moh' - -console.log( removeLastCodePoint( 'अनुच्छेद', 1 ) ); -// => 'अनुच्छे' diff --git a/index.js b/index.js new file mode 100644 index 0000000..0185898 --- /dev/null +++ b/index.js @@ -0,0 +1,3 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +var e,t;e=this,t=function(){"use strict";var e=/[\uDC00-\uDFFF]/,t=/[\uD800-\uDBFF]/;return function(n,f){var i,o,r,u;if(0===f)return n;for(r=0,u=n.length-1;u>=0;u--){if(i=n[u],r+=1,e.test(i)){if(0===u)break;o=n[u-1],t.test(o)&&(u-=1)}if(r===f)break}return n.substring(0,u)}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).removeLastCodePoint=t(); +//# sourceMappingURL=index.js.map diff --git a/index.js.map b/index.js.map new file mode 100644 index 0000000..d557af8 --- /dev/null +++ b/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\nvar RE_UTF16_LOW_SURROGATE = /[\\uDC00-\\uDFFF]/; // TODO: replace with stdlib pkg\nvar RE_UTF16_HIGH_SURROGATE = /[\\uD800-\\uDBFF]/; // TODO: replace with stdlib pkg\n\n\n// MAIN //\n\n/**\n* Removes the last `n` Unicode code points of a string.\n*\n* @param {string} str - input string\n* @param {NonNegativeInteger} n - number of Unicode code points to remove\n* @returns {string} output string\n*\n* @example\n* var out = removeLast( 'last man standing', 1 );\n* // returns 'last man standin'\n*\n* @example\n* var out = removeLast( 'presidential election', 1 );\n* // returns 'presidential electio'\n*\n* @example\n* var out = removeLast( 'JavaScript', 1 );\n* // returns 'JavaScrip'\n*\n* @example\n* var out = removeLast( 'Hidden Treasures', 1 );\n* // returns 'Hidden Treasure'\n*/\nfunction removeLast( str, n ) {\n\tvar len;\n\tvar ch1;\n\tvar ch2;\n\tvar cnt;\n\tvar i;\n\tif ( n === 0 ) {\n\t\treturn str;\n\t}\n\tlen = str.length;\n\tcnt = 0;\n\n\t// Process the string one Unicode code unit at a time and count UTF-16 surrogate pairs as a single Unicode code point...\n\tfor ( i = len - 1; i >= 0; i-- ) {\n\t\tch1 = str[ i ];\n\t\tcnt += 1;\n\n\t\t// Check for a low UTF-16 surrogate...\n\t\tif ( RE_UTF16_LOW_SURROGATE.test( ch1 ) ) {\n\t\t\t// Check for an unpaired surrogate at the end of the input string...\n\t\t\tif ( i === 0 ) {\n\t\t\t\t// We found an unpaired surrogate...\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\t// Check whether the high surrogate is paired with a low surrogate...\n\t\t\tch2 = str[ i-1 ];\n\t\t\tif ( RE_UTF16_HIGH_SURROGATE.test( ch2 ) ) {\n\t\t\t\t// We found a surrogate pair:\n\t\t\t\ti -= 1; // bump the index to process the next code unit\n\t\t\t}\n\t\t}\n\t\t// Check whether we've found the desired number of code points...\n\t\tif ( cnt === n ) {\n\t\t\tbreak;\n\t\t}\n\t}\n\treturn str.substring( 0, i );\n}\n\n\n// EXPORTS //\n\nexport default removeLast;\n"],"names":["RE_UTF16_LOW_SURROGATE","RE_UTF16_HIGH_SURROGATE","str","n","ch1","ch2","cnt","i","length","test","substring"],"mappings":";yCAsBA,IAAIA,EAAyB,kBACzBC,EAA0B,yBA4B9B,SAAqBC,EAAKC,GACzB,IACIC,EACAC,EACAC,EACAC,EACJ,GAAW,IAANJ,EACJ,OAAOD,EAMR,IAHAI,EAAM,EAGAC,EAJAL,EAAIM,OAIM,EAAGD,GAAK,EAAGA,IAAM,CAKhC,GAJAH,EAAMF,EAAKK,GACXD,GAAO,EAGFN,EAAuBS,KAAML,GAAQ,CAEzC,GAAW,IAANG,EAEJ,MAGDF,EAAMH,EAAKK,EAAE,GACRN,EAAwBQ,KAAMJ,KAElCE,GAAK,EAEN,CAED,GAAKD,IAAQH,EACZ,KAED,CACD,OAAOD,EAAIQ,UAAW,EAAGH,EAC1B"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 9860da0..0000000 --- a/lib/index.js +++ /dev/null @@ -1,43 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Remove the last `n` Unicode code points of a string. -* -* @module @stdlib/string-base-remove-last-code-point -* -* @example -* var removeLast = require( '@stdlib/string-base-remove-last-code-point' ); -* -* var out = removeLast( 'last man standing', 1 ); -* // returns 'last man standin' -* -* out = removeLast( 'Hidden Treasures', 1 ); -* // returns 'Hidden Treasure'; -*/ - -// 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 fc34187..0000000 --- a/lib/main.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// VARIABLES // - -var RE_UTF16_LOW_SURROGATE = /[\uDC00-\uDFFF]/; // TODO: replace with stdlib pkg -var RE_UTF16_HIGH_SURROGATE = /[\uD800-\uDBFF]/; // TODO: replace with stdlib pkg - - -// MAIN // - -/** -* Removes the last `n` Unicode code points of a string. -* -* @param {string} str - input string -* @param {NonNegativeInteger} n - number of Unicode code points to remove -* @returns {string} output string -* -* @example -* var out = removeLast( 'last man standing', 1 ); -* // returns 'last man standin' -* -* @example -* var out = removeLast( 'presidential election', 1 ); -* // returns 'presidential electio' -* -* @example -* var out = removeLast( 'JavaScript', 1 ); -* // returns 'JavaScrip' -* -* @example -* var out = removeLast( 'Hidden Treasures', 1 ); -* // returns 'Hidden Treasure' -*/ -function removeLast( str, n ) { - var len; - var ch1; - var ch2; - var cnt; - var i; - if ( n === 0 ) { - return str; - } - len = str.length; - cnt = 0; - - // Process the string one Unicode code unit at a time and count UTF-16 surrogate pairs as a single Unicode code point... - for ( i = len - 1; i >= 0; i-- ) { - ch1 = str[ i ]; - cnt += 1; - - // Check for a low UTF-16 surrogate... - if ( RE_UTF16_LOW_SURROGATE.test( ch1 ) ) { - // Check for an unpaired surrogate at the end of the input string... - if ( i === 0 ) { - // We found an unpaired surrogate... - break; - } - // Check whether the high surrogate is paired with a low surrogate... - ch2 = str[ i-1 ]; - if ( RE_UTF16_HIGH_SURROGATE.test( ch2 ) ) { - // We found a surrogate pair: - i -= 1; // bump the index to process the next code unit - } - } - // Check whether we've found the desired number of code points... - if ( cnt === n ) { - break; - } - } - return str.substring( 0, i ); -} - - -// EXPORTS // - -module.exports = removeLast; diff --git a/package.json b/package.json index f25b3a6..2328e01 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,7 @@ "version": "0.1.1", "description": "Remove the last Unicode code point of a string.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "main": "./index.js", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,31 +12,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/error-tools-fmtprodmsg": "^0.1.1" - }, - "devDependencies": { - "@stdlib/assert-is-string": "^0.1.1", - "@stdlib/bench": "^0.2.1", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdstring", @@ -81,4 +32,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/stats_browser.html b/stats_browser.html new file mode 100644 index 0000000..509cd96 --- /dev/null +++ b/stats_browser.html @@ -0,0 +1,6177 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/stats_node.html b/stats_node.html new file mode 100644 index 0000000..db1311b --- /dev/null +++ b/stats_node.html @@ -0,0 +1,6177 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index a25545e..0000000 --- a/test/test.js +++ /dev/null @@ -1,108 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var removeLast = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof removeLast, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns an empty string if provided an empty string', function test( t ) { - t.strictEqual( removeLast( '', 1 ), '', 'returns expected value' ); - t.strictEqual( removeLast( '', 2 ), '', 'returns expected value' ); - t.strictEqual( removeLast( '', 3 ), '', 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns the input string if provided zero as the second argument', function test( t ) { - t.strictEqual( removeLast( 'hello world', 0 ), 'hello world', 'returns expected value' ); - t.end(); -}); - -tape( 'the function removes the last Unicode code point of a provided string (ascii)', function test( t ) { - var out; - - out = removeLast( 'hello world', 1 ); - t.strictEqual( out, 'hello worl', 'returns expected value' ); - - out = removeLast( '!!!', 1 ); - t.strictEqual( out, '!!', 'returns expected value' ); - - out = removeLast( 'Hello World', 1 ); - t.strictEqual( out, 'Hello Worl', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function removes the last Unicode code point of a provided string (Unicode)', function test( t ) { - var out; - - out = removeLast( 'अनुच्छेद', 1 ); - t.strictEqual( out, 'अनुच्छे', 'returns expected value' ); - - out = removeLast( '六书/六書', 1 ); - t.strictEqual( out, '六书/六', 'returns expected value' ); - - out = removeLast( '𐒻𐓟', 1 ); - t.strictEqual( out, '𐒻', 'returns expected value' ); - - out = removeLast( '𐒻𐓟', 1 ); - t.strictEqual( out, '𐒻', 'returns expected value' ); - - out = removeLast( '\uDC00', 1 ); - t.strictEqual( out, '', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports removing the last `n` Unicode code points of a provided string', function test( t ) { - var out; - - out = removeLast( 'hello world', 1 ); - t.strictEqual( out, 'hello worl', 'returns expected value' ); - - out = removeLast( 'hello world', 7 ); - t.strictEqual( out, 'hell', 'returns expected value' ); - - out = removeLast( '!!!', 1 ); - t.strictEqual( out, '!!', 'returns expected value' ); - - out = removeLast( '!!!', 2 ); - t.strictEqual( out, '!', 'returns expected value' ); - - out = removeLast( 'अनुच्छेद', 1 ); - t.strictEqual( out, 'अनुच्छे', 'returns expected value' ); - - out = removeLast( '六书/六書', 3 ); - t.strictEqual( out, '六书', 'returns expected value' ); - - out = removeLast( '𐒻𐓟𐓟', 2 ); - t.strictEqual( out, '𐒻', 'returns expected value' ); - - t.end(); -}); From bf54adbb1b2c68b2140d9a50b63d6a59859d3476 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Jan 2024 00:33:40 +0000 Subject: [PATCH 30/92] Transform error messages --- package.json | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index a883f85..c5271ba 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,9 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": {}, + "dependencies": { + "@stdlib/error-tools-fmtprodmsg": "^0.1.1" + }, "devDependencies": { "@stdlib/assert-is-string": "^0.1.1", "tape": "git+https://github.com/kgryte/tape.git#fix/globby", @@ -79,4 +81,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From cab3d9263ac00b35e31bcc80eb82d3c04c6a69a8 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Jan 2024 00:38:56 +0000 Subject: [PATCH 31/92] Remove files --- browser.js | 3 - browser.js.map | 1 - index.js | 3 - index.js.map | 1 - stats_browser.html | 6177 -------------------------------------------- stats_node.html | 6177 -------------------------------------------- 6 files changed, 12362 deletions(-) delete mode 100644 browser.js delete mode 100644 browser.js.map delete mode 100644 index.js delete mode 100644 index.js.map delete mode 100644 stats_browser.html delete mode 100644 stats_node.html diff --git a/browser.js b/browser.js deleted file mode 100644 index d3e0f5b..0000000 --- a/browser.js +++ /dev/null @@ -1,3 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -var e,t;e=this,t=function(){"use strict";var e=/[\uDC00-\uDFFF]/,t=/[\uD800-\uDBFF]/;return function(n,f){var i,o,r,u;if(0===f)return n;for(r=0,u=n.length-1;u>=0;u--){if(i=n[u],r+=1,e.test(i)){if(0===u)break;o=n[u-1],t.test(o)&&(u-=1)}if(r===f)break}return n.substring(0,u)}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).removeLastCodePoint=t(); -//# sourceMappingURL=browser.js.map diff --git a/browser.js.map b/browser.js.map deleted file mode 100644 index 19908eb..0000000 --- a/browser.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"browser.js","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\nvar RE_UTF16_LOW_SURROGATE = /[\\uDC00-\\uDFFF]/; // TODO: replace with stdlib pkg\nvar RE_UTF16_HIGH_SURROGATE = /[\\uD800-\\uDBFF]/; // TODO: replace with stdlib pkg\n\n\n// MAIN //\n\n/**\n* Removes the last `n` Unicode code points of a string.\n*\n* @param {string} str - input string\n* @param {NonNegativeInteger} n - number of Unicode code points to remove\n* @returns {string} output string\n*\n* @example\n* var out = removeLast( 'last man standing', 1 );\n* // returns 'last man standin'\n*\n* @example\n* var out = removeLast( 'presidential election', 1 );\n* // returns 'presidential electio'\n*\n* @example\n* var out = removeLast( 'JavaScript', 1 );\n* // returns 'JavaScrip'\n*\n* @example\n* var out = removeLast( 'Hidden Treasures', 1 );\n* // returns 'Hidden Treasure'\n*/\nfunction removeLast( str, n ) {\n\tvar len;\n\tvar ch1;\n\tvar ch2;\n\tvar cnt;\n\tvar i;\n\tif ( n === 0 ) {\n\t\treturn str;\n\t}\n\tlen = str.length;\n\tcnt = 0;\n\n\t// Process the string one Unicode code unit at a time and count UTF-16 surrogate pairs as a single Unicode code point...\n\tfor ( i = len - 1; i >= 0; i-- ) {\n\t\tch1 = str[ i ];\n\t\tcnt += 1;\n\n\t\t// Check for a low UTF-16 surrogate...\n\t\tif ( RE_UTF16_LOW_SURROGATE.test( ch1 ) ) {\n\t\t\t// Check for an unpaired surrogate at the end of the input string...\n\t\t\tif ( i === 0 ) {\n\t\t\t\t// We found an unpaired surrogate...\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\t// Check whether the high surrogate is paired with a low surrogate...\n\t\t\tch2 = str[ i-1 ];\n\t\t\tif ( RE_UTF16_HIGH_SURROGATE.test( ch2 ) ) {\n\t\t\t\t// We found a surrogate pair:\n\t\t\t\ti -= 1; // bump the index to process the next code unit\n\t\t\t}\n\t\t}\n\t\t// Check whether we've found the desired number of code points...\n\t\tif ( cnt === n ) {\n\t\t\tbreak;\n\t\t}\n\t}\n\treturn str.substring( 0, i );\n}\n\n\n// EXPORTS //\n\nexport default removeLast;\n"],"names":["RE_UTF16_LOW_SURROGATE","RE_UTF16_HIGH_SURROGATE","str","n","ch1","ch2","cnt","i","length","test","substring"],"mappings":";yCAsBA,IAAIA,EAAyB,kBACzBC,EAA0B,yBA4B9B,SAAqBC,EAAKC,GACzB,IACIC,EACAC,EACAC,EACAC,EACJ,GAAW,IAANJ,EACJ,OAAOD,EAMR,IAHAI,EAAM,EAGAC,EAJAL,EAAIM,OAIM,EAAGD,GAAK,EAAGA,IAAM,CAKhC,GAJAH,EAAMF,EAAKK,GACXD,GAAO,EAGFN,EAAuBS,KAAML,GAAQ,CAEzC,GAAW,IAANG,EAEJ,MAGDF,EAAMH,EAAKK,EAAE,GACRN,EAAwBQ,KAAMJ,KAElCE,GAAK,EAEN,CAED,GAAKD,IAAQH,EACZ,KAED,CACD,OAAOD,EAAIQ,UAAW,EAAGH,EAC1B"} \ No newline at end of file diff --git a/index.js b/index.js deleted file mode 100644 index 0185898..0000000 --- a/index.js +++ /dev/null @@ -1,3 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -var e,t;e=this,t=function(){"use strict";var e=/[\uDC00-\uDFFF]/,t=/[\uD800-\uDBFF]/;return function(n,f){var i,o,r,u;if(0===f)return n;for(r=0,u=n.length-1;u>=0;u--){if(i=n[u],r+=1,e.test(i)){if(0===u)break;o=n[u-1],t.test(o)&&(u-=1)}if(r===f)break}return n.substring(0,u)}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).removeLastCodePoint=t(); -//# sourceMappingURL=index.js.map diff --git a/index.js.map b/index.js.map deleted file mode 100644 index d557af8..0000000 --- a/index.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.js","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\nvar RE_UTF16_LOW_SURROGATE = /[\\uDC00-\\uDFFF]/; // TODO: replace with stdlib pkg\nvar RE_UTF16_HIGH_SURROGATE = /[\\uD800-\\uDBFF]/; // TODO: replace with stdlib pkg\n\n\n// MAIN //\n\n/**\n* Removes the last `n` Unicode code points of a string.\n*\n* @param {string} str - input string\n* @param {NonNegativeInteger} n - number of Unicode code points to remove\n* @returns {string} output string\n*\n* @example\n* var out = removeLast( 'last man standing', 1 );\n* // returns 'last man standin'\n*\n* @example\n* var out = removeLast( 'presidential election', 1 );\n* // returns 'presidential electio'\n*\n* @example\n* var out = removeLast( 'JavaScript', 1 );\n* // returns 'JavaScrip'\n*\n* @example\n* var out = removeLast( 'Hidden Treasures', 1 );\n* // returns 'Hidden Treasure'\n*/\nfunction removeLast( str, n ) {\n\tvar len;\n\tvar ch1;\n\tvar ch2;\n\tvar cnt;\n\tvar i;\n\tif ( n === 0 ) {\n\t\treturn str;\n\t}\n\tlen = str.length;\n\tcnt = 0;\n\n\t// Process the string one Unicode code unit at a time and count UTF-16 surrogate pairs as a single Unicode code point...\n\tfor ( i = len - 1; i >= 0; i-- ) {\n\t\tch1 = str[ i ];\n\t\tcnt += 1;\n\n\t\t// Check for a low UTF-16 surrogate...\n\t\tif ( RE_UTF16_LOW_SURROGATE.test( ch1 ) ) {\n\t\t\t// Check for an unpaired surrogate at the end of the input string...\n\t\t\tif ( i === 0 ) {\n\t\t\t\t// We found an unpaired surrogate...\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\t// Check whether the high surrogate is paired with a low surrogate...\n\t\t\tch2 = str[ i-1 ];\n\t\t\tif ( RE_UTF16_HIGH_SURROGATE.test( ch2 ) ) {\n\t\t\t\t// We found a surrogate pair:\n\t\t\t\ti -= 1; // bump the index to process the next code unit\n\t\t\t}\n\t\t}\n\t\t// Check whether we've found the desired number of code points...\n\t\tif ( cnt === n ) {\n\t\t\tbreak;\n\t\t}\n\t}\n\treturn str.substring( 0, i );\n}\n\n\n// EXPORTS //\n\nexport default removeLast;\n"],"names":["RE_UTF16_LOW_SURROGATE","RE_UTF16_HIGH_SURROGATE","str","n","ch1","ch2","cnt","i","length","test","substring"],"mappings":";yCAsBA,IAAIA,EAAyB,kBACzBC,EAA0B,yBA4B9B,SAAqBC,EAAKC,GACzB,IACIC,EACAC,EACAC,EACAC,EACJ,GAAW,IAANJ,EACJ,OAAOD,EAMR,IAHAI,EAAM,EAGAC,EAJAL,EAAIM,OAIM,EAAGD,GAAK,EAAGA,IAAM,CAKhC,GAJAH,EAAMF,EAAKK,GACXD,GAAO,EAGFN,EAAuBS,KAAML,GAAQ,CAEzC,GAAW,IAANG,EAEJ,MAGDF,EAAMH,EAAKK,EAAE,GACRN,EAAwBQ,KAAMJ,KAElCE,GAAK,EAEN,CAED,GAAKD,IAAQH,EACZ,KAED,CACD,OAAOD,EAAIQ,UAAW,EAAGH,EAC1B"} \ No newline at end of file diff --git a/stats_browser.html b/stats_browser.html deleted file mode 100644 index 509cd96..0000000 --- a/stats_browser.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - diff --git a/stats_node.html b/stats_node.html deleted file mode 100644 index db1311b..0000000 --- a/stats_node.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 9194575c19b809f188d9e32ab50160f91013f406 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Jan 2024 00:39:21 +0000 Subject: [PATCH 32/92] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 797 --- .github/workflows/publish.yml | 255 - .github/workflows/test.yml | 100 - .github/workflows/test_bundles.yml | 189 - .github/workflows/test_coverage.yml | 128 - .github/workflows/test_install.yml | 86 - .gitignore | 188 - .npmignore | 228 - .npmrc | 28 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 52 +- SECURITY.md | 5 - benchmark/benchmark.js | 56 - branches.md | 53 - browser.js | 3 + browser.js.map | 1 + dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 29 - docs/types/index.d.ts | 53 - docs/types/test.ts | 57 - examples/index.js | 33 - index.js | 3 + index.js.map | 1 + lib/index.js | 43 - lib/main.js | 94 - package.json | 53 +- stats_browser.html | 6177 +++++++++++++++++++++ stats_node.html | 6177 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 108 - 46 files changed, 12399 insertions(+), 3811 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md create mode 100644 browser.js create mode 100644 browser.js.map 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/index.d.ts delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js create mode 100644 index.js create mode 100644 index.js.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats_browser.html create mode 100644 stats_node.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index a0be1b1..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-01-01T00:32:26.073Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 52cd9c4..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/base/remove-last-code-point) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 533eeee..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/base/remove-last-code-point) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 d222294..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: '29 5 * * 0' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA corresponding to v3.1.3 - uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index e1e3539..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,797 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA corresponding to v2.0.0 - uses: act10ns/slack@ed1309ab9862e57e9e583e51c7889486b9a00b0f - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n +``` + +If no recognized module system is present, access bundle contents via the global scope: + +```html + ``` #### removeLastCodePoint( str, n ) @@ -89,8 +97,13 @@ out = removeLastCodePoint( 'foo bar', 10 ); -```javascript -var removeLastCodePoint = require( '@stdlib/string-base-remove-last-code-point' ); +```html + + + + + + + ```
diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index a39bd29..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,56 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var removeLast = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var values; - var out; - var i; - - values = [ - 'beep boop', - 'foo bar', - 'xyz abc', - '🐶🐮🐷🐰🐸' - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = removeLast( values[ i%values.length ], 1 ); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( !isString( out ) ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 41f4db9..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/base/remove-last-code-point" -%% click B href "https://github.com/stdlib-js/string-base-remove-last-code-point/tree/main" -%% click C href "https://github.com/stdlib-js/string-base-remove-last-code-point/tree/production" -%% click D href "https://github.com/stdlib-js/string-base-remove-last-code-point/tree/esm" -%% click E href "https://github.com/stdlib-js/string-base-remove-last-code-point/tree/deno" -%% click F href "https://github.com/stdlib-js/string-base-remove-last-code-point/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/base/remove-last-code-point -[production-url]: https://github.com/stdlib-js/string-base-remove-last-code-point/tree/production -[deno-url]: https://github.com/stdlib-js/string-base-remove-last-code-point/tree/deno -[umd-url]: https://github.com/stdlib-js/string-base-remove-last-code-point/tree/umd -[esm-url]: https://github.com/stdlib-js/string-base-remove-last-code-point/tree/esm \ No newline at end of file diff --git a/browser.js b/browser.js new file mode 100644 index 0000000..f3a511a --- /dev/null +++ b/browser.js @@ -0,0 +1,3 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +var e,t;e=this,t=function(){"use strict";var e=/[\uDC00-\uDFFF]/,t=/[\uD800-\uDBFF]/;return function(n,f){var i,o,r,u;if(0===f)return n;for(r=0,u=n.length-1;u>=0;u--){if(i=n[u],r+=1,e.test(i)){if(0===u)break;o=n[u-1],t.test(o)&&(u-=1)}if(r===f)break}return n.substring(0,u)}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).removeLastCodePoint=t(); +//# sourceMappingURL=browser.js.map diff --git a/browser.js.map b/browser.js.map new file mode 100644 index 0000000..19908eb --- /dev/null +++ b/browser.js.map @@ -0,0 +1 @@ +{"version":3,"file":"browser.js","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\nvar RE_UTF16_LOW_SURROGATE = /[\\uDC00-\\uDFFF]/; // TODO: replace with stdlib pkg\nvar RE_UTF16_HIGH_SURROGATE = /[\\uD800-\\uDBFF]/; // TODO: replace with stdlib pkg\n\n\n// MAIN //\n\n/**\n* Removes the last `n` Unicode code points of a string.\n*\n* @param {string} str - input string\n* @param {NonNegativeInteger} n - number of Unicode code points to remove\n* @returns {string} output string\n*\n* @example\n* var out = removeLast( 'last man standing', 1 );\n* // returns 'last man standin'\n*\n* @example\n* var out = removeLast( 'presidential election', 1 );\n* // returns 'presidential electio'\n*\n* @example\n* var out = removeLast( 'JavaScript', 1 );\n* // returns 'JavaScrip'\n*\n* @example\n* var out = removeLast( 'Hidden Treasures', 1 );\n* // returns 'Hidden Treasure'\n*/\nfunction removeLast( str, n ) {\n\tvar len;\n\tvar ch1;\n\tvar ch2;\n\tvar cnt;\n\tvar i;\n\tif ( n === 0 ) {\n\t\treturn str;\n\t}\n\tlen = str.length;\n\tcnt = 0;\n\n\t// Process the string one Unicode code unit at a time and count UTF-16 surrogate pairs as a single Unicode code point...\n\tfor ( i = len - 1; i >= 0; i-- ) {\n\t\tch1 = str[ i ];\n\t\tcnt += 1;\n\n\t\t// Check for a low UTF-16 surrogate...\n\t\tif ( RE_UTF16_LOW_SURROGATE.test( ch1 ) ) {\n\t\t\t// Check for an unpaired surrogate at the end of the input string...\n\t\t\tif ( i === 0 ) {\n\t\t\t\t// We found an unpaired surrogate...\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\t// Check whether the high surrogate is paired with a low surrogate...\n\t\t\tch2 = str[ i-1 ];\n\t\t\tif ( RE_UTF16_HIGH_SURROGATE.test( ch2 ) ) {\n\t\t\t\t// We found a surrogate pair:\n\t\t\t\ti -= 1; // bump the index to process the next code unit\n\t\t\t}\n\t\t}\n\t\t// Check whether we've found the desired number of code points...\n\t\tif ( cnt === n ) {\n\t\t\tbreak;\n\t\t}\n\t}\n\treturn str.substring( 0, i );\n}\n\n\n// EXPORTS //\n\nexport default removeLast;\n"],"names":["RE_UTF16_LOW_SURROGATE","RE_UTF16_HIGH_SURROGATE","str","n","ch1","ch2","cnt","i","length","test","substring"],"mappings":";yCAsBA,IAAIA,EAAyB,kBACzBC,EAA0B,yBA4B9B,SAAqBC,EAAKC,GACzB,IACIC,EACAC,EACAC,EACAC,EACJ,GAAW,IAANJ,EACJ,OAAOD,EAMR,IAHAI,EAAM,EAGAC,EAJAL,EAAIM,OAIM,EAAGD,GAAK,EAAGA,IAAM,CAKhC,GAJAH,EAAMF,EAAKK,GACXD,GAAO,EAGFN,EAAuBS,KAAML,GAAQ,CAEzC,GAAW,IAANG,EAEJ,MAGDF,EAAMH,EAAKK,EAAE,GACRN,EAAwBQ,KAAMJ,KAElCE,GAAK,EAEN,CAED,GAAKD,IAAQH,EACZ,KAED,CACD,OAAOD,EAAIQ,UAAW,EAAGH,EAC1B"} \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index 8c96fd7..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import removeLast from '../docs/types/index'; -export = removeLast; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index e6b7220..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var s=function(e,t){return function(){return t||e((t={exports:{}}).exports,t),t.exports}};var f=s(function(D,n){ -var F=/[\uDC00-\uDFFF]/,c=/[\uD800-\uDBFF]/;function R(e,t){var i,u,v,a,r;if(t===0)return e;for(i=e.length,a=0,r=i-1;r>=0;r--){if(u=e[r],a+=1,F.test(u)){if(r===0)break;v=e[r-1],c.test(v)&&(r-=1)}if(a===t)break}return e.substring(0,r)}n.exports=R -});var _=f();module.exports=_; -/** @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 72561cf..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\nvar RE_UTF16_LOW_SURROGATE = /[\\uDC00-\\uDFFF]/; // TODO: replace with stdlib pkg\nvar RE_UTF16_HIGH_SURROGATE = /[\\uD800-\\uDBFF]/; // TODO: replace with stdlib pkg\n\n\n// MAIN //\n\n/**\n* Removes the last `n` Unicode code points of a string.\n*\n* @param {string} str - input string\n* @param {NonNegativeInteger} n - number of Unicode code points to remove\n* @returns {string} output string\n*\n* @example\n* var out = removeLast( 'last man standing', 1 );\n* // returns 'last man standin'\n*\n* @example\n* var out = removeLast( 'presidential election', 1 );\n* // returns 'presidential electio'\n*\n* @example\n* var out = removeLast( 'JavaScript', 1 );\n* // returns 'JavaScrip'\n*\n* @example\n* var out = removeLast( 'Hidden Treasures', 1 );\n* // returns 'Hidden Treasure'\n*/\nfunction removeLast( str, n ) {\n\tvar len;\n\tvar ch1;\n\tvar ch2;\n\tvar cnt;\n\tvar i;\n\tif ( n === 0 ) {\n\t\treturn str;\n\t}\n\tlen = str.length;\n\tcnt = 0;\n\n\t// Process the string one Unicode code unit at a time and count UTF-16 surrogate pairs as a single Unicode code point...\n\tfor ( i = len - 1; i >= 0; i-- ) {\n\t\tch1 = str[ i ];\n\t\tcnt += 1;\n\n\t\t// Check for a low UTF-16 surrogate...\n\t\tif ( RE_UTF16_LOW_SURROGATE.test( ch1 ) ) {\n\t\t\t// Check for an unpaired surrogate at the end of the input string...\n\t\t\tif ( i === 0 ) {\n\t\t\t\t// We found an unpaired surrogate...\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\t// Check whether the high surrogate is paired with a low surrogate...\n\t\t\tch2 = str[ i-1 ];\n\t\t\tif ( RE_UTF16_HIGH_SURROGATE.test( ch2 ) ) {\n\t\t\t\t// We found a surrogate pair:\n\t\t\t\ti -= 1; // bump the index to process the next code unit\n\t\t\t}\n\t\t}\n\t\t// Check whether we've found the desired number of code points...\n\t\tif ( cnt === n ) {\n\t\t\tbreak;\n\t\t}\n\t}\n\treturn str.substring( 0, i );\n}\n\n\n// EXPORTS //\n\nmodule.exports = removeLast;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Remove the last `n` Unicode code points of a string.\n*\n* @module @stdlib/string-base-remove-last-code-point\n*\n* @example\n* var removeLast = require( '@stdlib/string-base-remove-last-code-point' );\n*\n* var out = removeLast( 'last man standing', 1 );\n* // returns 'last man standin'\n*\n* out = removeLast( 'Hidden Treasures', 1 );\n* // returns 'Hidden Treasure';\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,EAAyB,kBACzBC,EAA0B,kBA4B9B,SAASC,EAAYC,EAAKC,EAAI,CAC7B,IAAIC,EACAC,EACAC,EACAC,EACAC,EACJ,GAAKL,IAAM,EACV,OAAOD,EAMR,IAJAE,EAAMF,EAAI,OACVK,EAAM,EAGAC,EAAIJ,EAAM,EAAGI,GAAK,EAAGA,IAAM,CAKhC,GAJAH,EAAMH,EAAKM,CAAE,EACbD,GAAO,EAGFR,EAAuB,KAAMM,CAAI,EAAI,CAEzC,GAAKG,IAAM,EAEV,MAGDF,EAAMJ,EAAKM,EAAE,CAAE,EACVR,EAAwB,KAAMM,CAAI,IAEtCE,GAAK,EAEP,CAEA,GAAKD,IAAQJ,EACZ,KAEF,CACA,OAAOD,EAAI,UAAW,EAAGM,CAAE,CAC5B,CAKAV,EAAO,QAAUG,ICxDjB,IAAIQ,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "RE_UTF16_LOW_SURROGATE", "RE_UTF16_HIGH_SURROGATE", "removeLast", "str", "n", "len", "ch1", "ch2", "cnt", "i", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index a08ea55..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,29 +0,0 @@ - -{{alias}}( str, n ) - Removes the last `n` Unicode code points of a string. - - Parameters - ---------- - str: string - Input string. - - n: integer - Number of Unicode code points to remove. - - Returns - ------- - out: string - Output string. - - Examples - -------- - > var out = {{alias}}( 'beep', 1 ) - 'bee' - > out = {{alias}}( 'Boop', 1 ) - 'Boo' - > out = {{alias}}( 'foo bar', 5 ) - 'fo' - - See Also - -------- - diff --git a/docs/types/index.d.ts b/docs/types/index.d.ts deleted file mode 100644 index 8a1c90b..0000000 --- a/docs/types/index.d.ts +++ /dev/null @@ -1,53 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 - -/** -* Removes the last `n` Unicode code points of a string. -* -* @param str - input string -* @param n - number of code points to remove -* @returns output string -* -* @example -* var out = removeLast( 'last man standing', 1 ); -* // returns 'last man standin' -* -* @example -* var out = removeLast( 'presidential election', 1 ); -* // returns 'presidential electio' -* -* @example -* var out = removeLast( 'JavaScript', 1 ); -* // returns 'JavaScrip' -* -* @example -* var out = removeLast( 'Hidden Treasures', 1 ); -* // returns 'Hidden Treasure' -* -* @example -* var out = removeLast( 'foo bar', 5 ); -* // returns 'fo' -*/ -declare function removeLast( str: string, n: number ): string; - - -// EXPORTS // - -export = removeLast; diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index fd426d2..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,57 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 removeLast = require( './index' ); - - -// TESTS // - -// The function returns a string... -{ - removeLast( 'abc', 1 ); // $ExpectType string -} - -// The compiler throws an error if the function is provided a value other than a string... -{ - removeLast( true, 1 ); // $ExpectError - removeLast( false, 1 ); // $ExpectError - removeLast( null, 1 ); // $ExpectError - removeLast( undefined, 1 ); // $ExpectError - removeLast( 5, 1 ); // $ExpectError - removeLast( [], 1 ); // $ExpectError - removeLast( {}, 1 ); // $ExpectError - removeLast( ( x: number ): number => x, 1 ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument that is not a number... -{ - removeLast( 'abc', true ); // $ExpectError - removeLast( 'abc', false ); // $ExpectError - removeLast( 'abc', null ); // $ExpectError - removeLast( 'abc', 'abc' ); // $ExpectError - removeLast( 'abc', [] ); // $ExpectError - removeLast( 'abc', {} ); // $ExpectError - removeLast( 'abc', ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - removeLast(); // $ExpectError - removeLast( 'abc' ); // $ExpectError - removeLast( 'abc', 1, 2 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 085633e..0000000 --- a/examples/index.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var removeLastCodePoint = require( './../lib' ); - -console.log( removeLastCodePoint( 'presidential election', 1 ) ); -// => 'presidential electio' - -console.log( removeLastCodePoint( 'JavaScript', 1 ) ); -// => 'JavaScrip' - -console.log( removeLastCodePoint( 'The Last of the Mohicans', 5 ) ); -// => 'The Last of the Moh' - -console.log( removeLastCodePoint( 'अनुच्छेद', 1 ) ); -// => 'अनुच्छे' diff --git a/index.js b/index.js new file mode 100644 index 0000000..4e500d1 --- /dev/null +++ b/index.js @@ -0,0 +1,3 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +var e,t;e=this,t=function(){"use strict";var e=/[\uDC00-\uDFFF]/,t=/[\uD800-\uDBFF]/;return function(n,f){var i,o,r,u;if(0===f)return n;for(r=0,u=n.length-1;u>=0;u--){if(i=n[u],r+=1,e.test(i)){if(0===u)break;o=n[u-1],t.test(o)&&(u-=1)}if(r===f)break}return n.substring(0,u)}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).removeLastCodePoint=t(); +//# sourceMappingURL=index.js.map diff --git a/index.js.map b/index.js.map new file mode 100644 index 0000000..d557af8 --- /dev/null +++ b/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\nvar RE_UTF16_LOW_SURROGATE = /[\\uDC00-\\uDFFF]/; // TODO: replace with stdlib pkg\nvar RE_UTF16_HIGH_SURROGATE = /[\\uD800-\\uDBFF]/; // TODO: replace with stdlib pkg\n\n\n// MAIN //\n\n/**\n* Removes the last `n` Unicode code points of a string.\n*\n* @param {string} str - input string\n* @param {NonNegativeInteger} n - number of Unicode code points to remove\n* @returns {string} output string\n*\n* @example\n* var out = removeLast( 'last man standing', 1 );\n* // returns 'last man standin'\n*\n* @example\n* var out = removeLast( 'presidential election', 1 );\n* // returns 'presidential electio'\n*\n* @example\n* var out = removeLast( 'JavaScript', 1 );\n* // returns 'JavaScrip'\n*\n* @example\n* var out = removeLast( 'Hidden Treasures', 1 );\n* // returns 'Hidden Treasure'\n*/\nfunction removeLast( str, n ) {\n\tvar len;\n\tvar ch1;\n\tvar ch2;\n\tvar cnt;\n\tvar i;\n\tif ( n === 0 ) {\n\t\treturn str;\n\t}\n\tlen = str.length;\n\tcnt = 0;\n\n\t// Process the string one Unicode code unit at a time and count UTF-16 surrogate pairs as a single Unicode code point...\n\tfor ( i = len - 1; i >= 0; i-- ) {\n\t\tch1 = str[ i ];\n\t\tcnt += 1;\n\n\t\t// Check for a low UTF-16 surrogate...\n\t\tif ( RE_UTF16_LOW_SURROGATE.test( ch1 ) ) {\n\t\t\t// Check for an unpaired surrogate at the end of the input string...\n\t\t\tif ( i === 0 ) {\n\t\t\t\t// We found an unpaired surrogate...\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\t// Check whether the high surrogate is paired with a low surrogate...\n\t\t\tch2 = str[ i-1 ];\n\t\t\tif ( RE_UTF16_HIGH_SURROGATE.test( ch2 ) ) {\n\t\t\t\t// We found a surrogate pair:\n\t\t\t\ti -= 1; // bump the index to process the next code unit\n\t\t\t}\n\t\t}\n\t\t// Check whether we've found the desired number of code points...\n\t\tif ( cnt === n ) {\n\t\t\tbreak;\n\t\t}\n\t}\n\treturn str.substring( 0, i );\n}\n\n\n// EXPORTS //\n\nexport default removeLast;\n"],"names":["RE_UTF16_LOW_SURROGATE","RE_UTF16_HIGH_SURROGATE","str","n","ch1","ch2","cnt","i","length","test","substring"],"mappings":";yCAsBA,IAAIA,EAAyB,kBACzBC,EAA0B,yBA4B9B,SAAqBC,EAAKC,GACzB,IACIC,EACAC,EACAC,EACAC,EACJ,GAAW,IAANJ,EACJ,OAAOD,EAMR,IAHAI,EAAM,EAGAC,EAJAL,EAAIM,OAIM,EAAGD,GAAK,EAAGA,IAAM,CAKhC,GAJAH,EAAMF,EAAKK,GACXD,GAAO,EAGFN,EAAuBS,KAAML,GAAQ,CAEzC,GAAW,IAANG,EAEJ,MAGDF,EAAMH,EAAKK,EAAE,GACRN,EAAwBQ,KAAMJ,KAElCE,GAAK,EAEN,CAED,GAAKD,IAAQH,EACZ,KAED,CACD,OAAOD,EAAIQ,UAAW,EAAGH,EAC1B"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 9860da0..0000000 --- a/lib/index.js +++ /dev/null @@ -1,43 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Remove the last `n` Unicode code points of a string. -* -* @module @stdlib/string-base-remove-last-code-point -* -* @example -* var removeLast = require( '@stdlib/string-base-remove-last-code-point' ); -* -* var out = removeLast( 'last man standing', 1 ); -* // returns 'last man standin' -* -* out = removeLast( 'Hidden Treasures', 1 ); -* // returns 'Hidden Treasure'; -*/ - -// 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 fc34187..0000000 --- a/lib/main.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// VARIABLES // - -var RE_UTF16_LOW_SURROGATE = /[\uDC00-\uDFFF]/; // TODO: replace with stdlib pkg -var RE_UTF16_HIGH_SURROGATE = /[\uD800-\uDBFF]/; // TODO: replace with stdlib pkg - - -// MAIN // - -/** -* Removes the last `n` Unicode code points of a string. -* -* @param {string} str - input string -* @param {NonNegativeInteger} n - number of Unicode code points to remove -* @returns {string} output string -* -* @example -* var out = removeLast( 'last man standing', 1 ); -* // returns 'last man standin' -* -* @example -* var out = removeLast( 'presidential election', 1 ); -* // returns 'presidential electio' -* -* @example -* var out = removeLast( 'JavaScript', 1 ); -* // returns 'JavaScrip' -* -* @example -* var out = removeLast( 'Hidden Treasures', 1 ); -* // returns 'Hidden Treasure' -*/ -function removeLast( str, n ) { - var len; - var ch1; - var ch2; - var cnt; - var i; - if ( n === 0 ) { - return str; - } - len = str.length; - cnt = 0; - - // Process the string one Unicode code unit at a time and count UTF-16 surrogate pairs as a single Unicode code point... - for ( i = len - 1; i >= 0; i-- ) { - ch1 = str[ i ]; - cnt += 1; - - // Check for a low UTF-16 surrogate... - if ( RE_UTF16_LOW_SURROGATE.test( ch1 ) ) { - // Check for an unpaired surrogate at the end of the input string... - if ( i === 0 ) { - // We found an unpaired surrogate... - break; - } - // Check whether the high surrogate is paired with a low surrogate... - ch2 = str[ i-1 ]; - if ( RE_UTF16_HIGH_SURROGATE.test( ch2 ) ) { - // We found a surrogate pair: - i -= 1; // bump the index to process the next code unit - } - } - // Check whether we've found the desired number of code points... - if ( cnt === n ) { - break; - } - } - return str.substring( 0, i ); -} - - -// EXPORTS // - -module.exports = removeLast; diff --git a/package.json b/package.json index c5271ba..2328e01 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,7 @@ "version": "0.1.1", "description": "Remove the last Unicode code point of a string.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "main": "./index.js", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,31 +12,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/error-tools-fmtprodmsg": "^0.1.1" - }, - "devDependencies": { - "@stdlib/assert-is-string": "^0.1.1", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.1.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdstring", @@ -81,4 +32,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/stats_browser.html b/stats_browser.html new file mode 100644 index 0000000..441d43d --- /dev/null +++ b/stats_browser.html @@ -0,0 +1,6177 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/stats_node.html b/stats_node.html new file mode 100644 index 0000000..8a5f437 --- /dev/null +++ b/stats_node.html @@ -0,0 +1,6177 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index a25545e..0000000 --- a/test/test.js +++ /dev/null @@ -1,108 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var removeLast = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof removeLast, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns an empty string if provided an empty string', function test( t ) { - t.strictEqual( removeLast( '', 1 ), '', 'returns expected value' ); - t.strictEqual( removeLast( '', 2 ), '', 'returns expected value' ); - t.strictEqual( removeLast( '', 3 ), '', 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns the input string if provided zero as the second argument', function test( t ) { - t.strictEqual( removeLast( 'hello world', 0 ), 'hello world', 'returns expected value' ); - t.end(); -}); - -tape( 'the function removes the last Unicode code point of a provided string (ascii)', function test( t ) { - var out; - - out = removeLast( 'hello world', 1 ); - t.strictEqual( out, 'hello worl', 'returns expected value' ); - - out = removeLast( '!!!', 1 ); - t.strictEqual( out, '!!', 'returns expected value' ); - - out = removeLast( 'Hello World', 1 ); - t.strictEqual( out, 'Hello Worl', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function removes the last Unicode code point of a provided string (Unicode)', function test( t ) { - var out; - - out = removeLast( 'अनुच्छेद', 1 ); - t.strictEqual( out, 'अनुच्छे', 'returns expected value' ); - - out = removeLast( '六书/六書', 1 ); - t.strictEqual( out, '六书/六', 'returns expected value' ); - - out = removeLast( '𐒻𐓟', 1 ); - t.strictEqual( out, '𐒻', 'returns expected value' ); - - out = removeLast( '𐒻𐓟', 1 ); - t.strictEqual( out, '𐒻', 'returns expected value' ); - - out = removeLast( '\uDC00', 1 ); - t.strictEqual( out, '', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports removing the last `n` Unicode code points of a provided string', function test( t ) { - var out; - - out = removeLast( 'hello world', 1 ); - t.strictEqual( out, 'hello worl', 'returns expected value' ); - - out = removeLast( 'hello world', 7 ); - t.strictEqual( out, 'hell', 'returns expected value' ); - - out = removeLast( '!!!', 1 ); - t.strictEqual( out, '!!', 'returns expected value' ); - - out = removeLast( '!!!', 2 ); - t.strictEqual( out, '!', 'returns expected value' ); - - out = removeLast( 'अनुच्छेद', 1 ); - t.strictEqual( out, 'अनुच्छे', 'returns expected value' ); - - out = removeLast( '六书/六書', 3 ); - t.strictEqual( out, '六书', 'returns expected value' ); - - out = removeLast( '𐒻𐓟𐓟', 2 ); - t.strictEqual( out, '𐒻', 'returns expected value' ); - - t.end(); -}); From 3909c2af868bfb327d9babb3d1eebe1bc2c288de Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Feb 2024 00:30:49 +0000 Subject: [PATCH 33/92] Transform error messages --- package.json | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index a883f85..c5271ba 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,9 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": {}, + "dependencies": { + "@stdlib/error-tools-fmtprodmsg": "^0.1.1" + }, "devDependencies": { "@stdlib/assert-is-string": "^0.1.1", "tape": "git+https://github.com/kgryte/tape.git#fix/globby", @@ -79,4 +81,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 26362efd37f8366df9f3a34386e75994d812d285 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Feb 2024 00:42:30 +0000 Subject: [PATCH 34/92] Remove files --- browser.js | 3 - browser.js.map | 1 - index.js | 3 - index.js.map | 1 - stats_browser.html | 6177 -------------------------------------------- stats_node.html | 6177 -------------------------------------------- 6 files changed, 12362 deletions(-) delete mode 100644 browser.js delete mode 100644 browser.js.map delete mode 100644 index.js delete mode 100644 index.js.map delete mode 100644 stats_browser.html delete mode 100644 stats_node.html diff --git a/browser.js b/browser.js deleted file mode 100644 index f3a511a..0000000 --- a/browser.js +++ /dev/null @@ -1,3 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -var e,t;e=this,t=function(){"use strict";var e=/[\uDC00-\uDFFF]/,t=/[\uD800-\uDBFF]/;return function(n,f){var i,o,r,u;if(0===f)return n;for(r=0,u=n.length-1;u>=0;u--){if(i=n[u],r+=1,e.test(i)){if(0===u)break;o=n[u-1],t.test(o)&&(u-=1)}if(r===f)break}return n.substring(0,u)}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).removeLastCodePoint=t(); -//# sourceMappingURL=browser.js.map diff --git a/browser.js.map b/browser.js.map deleted file mode 100644 index 19908eb..0000000 --- a/browser.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"browser.js","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\nvar RE_UTF16_LOW_SURROGATE = /[\\uDC00-\\uDFFF]/; // TODO: replace with stdlib pkg\nvar RE_UTF16_HIGH_SURROGATE = /[\\uD800-\\uDBFF]/; // TODO: replace with stdlib pkg\n\n\n// MAIN //\n\n/**\n* Removes the last `n` Unicode code points of a string.\n*\n* @param {string} str - input string\n* @param {NonNegativeInteger} n - number of Unicode code points to remove\n* @returns {string} output string\n*\n* @example\n* var out = removeLast( 'last man standing', 1 );\n* // returns 'last man standin'\n*\n* @example\n* var out = removeLast( 'presidential election', 1 );\n* // returns 'presidential electio'\n*\n* @example\n* var out = removeLast( 'JavaScript', 1 );\n* // returns 'JavaScrip'\n*\n* @example\n* var out = removeLast( 'Hidden Treasures', 1 );\n* // returns 'Hidden Treasure'\n*/\nfunction removeLast( str, n ) {\n\tvar len;\n\tvar ch1;\n\tvar ch2;\n\tvar cnt;\n\tvar i;\n\tif ( n === 0 ) {\n\t\treturn str;\n\t}\n\tlen = str.length;\n\tcnt = 0;\n\n\t// Process the string one Unicode code unit at a time and count UTF-16 surrogate pairs as a single Unicode code point...\n\tfor ( i = len - 1; i >= 0; i-- ) {\n\t\tch1 = str[ i ];\n\t\tcnt += 1;\n\n\t\t// Check for a low UTF-16 surrogate...\n\t\tif ( RE_UTF16_LOW_SURROGATE.test( ch1 ) ) {\n\t\t\t// Check for an unpaired surrogate at the end of the input string...\n\t\t\tif ( i === 0 ) {\n\t\t\t\t// We found an unpaired surrogate...\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\t// Check whether the high surrogate is paired with a low surrogate...\n\t\t\tch2 = str[ i-1 ];\n\t\t\tif ( RE_UTF16_HIGH_SURROGATE.test( ch2 ) ) {\n\t\t\t\t// We found a surrogate pair:\n\t\t\t\ti -= 1; // bump the index to process the next code unit\n\t\t\t}\n\t\t}\n\t\t// Check whether we've found the desired number of code points...\n\t\tif ( cnt === n ) {\n\t\t\tbreak;\n\t\t}\n\t}\n\treturn str.substring( 0, i );\n}\n\n\n// EXPORTS //\n\nexport default removeLast;\n"],"names":["RE_UTF16_LOW_SURROGATE","RE_UTF16_HIGH_SURROGATE","str","n","ch1","ch2","cnt","i","length","test","substring"],"mappings":";yCAsBA,IAAIA,EAAyB,kBACzBC,EAA0B,yBA4B9B,SAAqBC,EAAKC,GACzB,IACIC,EACAC,EACAC,EACAC,EACJ,GAAW,IAANJ,EACJ,OAAOD,EAMR,IAHAI,EAAM,EAGAC,EAJAL,EAAIM,OAIM,EAAGD,GAAK,EAAGA,IAAM,CAKhC,GAJAH,EAAMF,EAAKK,GACXD,GAAO,EAGFN,EAAuBS,KAAML,GAAQ,CAEzC,GAAW,IAANG,EAEJ,MAGDF,EAAMH,EAAKK,EAAE,GACRN,EAAwBQ,KAAMJ,KAElCE,GAAK,EAEN,CAED,GAAKD,IAAQH,EACZ,KAED,CACD,OAAOD,EAAIQ,UAAW,EAAGH,EAC1B"} \ No newline at end of file diff --git a/index.js b/index.js deleted file mode 100644 index 4e500d1..0000000 --- a/index.js +++ /dev/null @@ -1,3 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -var e,t;e=this,t=function(){"use strict";var e=/[\uDC00-\uDFFF]/,t=/[\uD800-\uDBFF]/;return function(n,f){var i,o,r,u;if(0===f)return n;for(r=0,u=n.length-1;u>=0;u--){if(i=n[u],r+=1,e.test(i)){if(0===u)break;o=n[u-1],t.test(o)&&(u-=1)}if(r===f)break}return n.substring(0,u)}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).removeLastCodePoint=t(); -//# sourceMappingURL=index.js.map diff --git a/index.js.map b/index.js.map deleted file mode 100644 index d557af8..0000000 --- a/index.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.js","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\nvar RE_UTF16_LOW_SURROGATE = /[\\uDC00-\\uDFFF]/; // TODO: replace with stdlib pkg\nvar RE_UTF16_HIGH_SURROGATE = /[\\uD800-\\uDBFF]/; // TODO: replace with stdlib pkg\n\n\n// MAIN //\n\n/**\n* Removes the last `n` Unicode code points of a string.\n*\n* @param {string} str - input string\n* @param {NonNegativeInteger} n - number of Unicode code points to remove\n* @returns {string} output string\n*\n* @example\n* var out = removeLast( 'last man standing', 1 );\n* // returns 'last man standin'\n*\n* @example\n* var out = removeLast( 'presidential election', 1 );\n* // returns 'presidential electio'\n*\n* @example\n* var out = removeLast( 'JavaScript', 1 );\n* // returns 'JavaScrip'\n*\n* @example\n* var out = removeLast( 'Hidden Treasures', 1 );\n* // returns 'Hidden Treasure'\n*/\nfunction removeLast( str, n ) {\n\tvar len;\n\tvar ch1;\n\tvar ch2;\n\tvar cnt;\n\tvar i;\n\tif ( n === 0 ) {\n\t\treturn str;\n\t}\n\tlen = str.length;\n\tcnt = 0;\n\n\t// Process the string one Unicode code unit at a time and count UTF-16 surrogate pairs as a single Unicode code point...\n\tfor ( i = len - 1; i >= 0; i-- ) {\n\t\tch1 = str[ i ];\n\t\tcnt += 1;\n\n\t\t// Check for a low UTF-16 surrogate...\n\t\tif ( RE_UTF16_LOW_SURROGATE.test( ch1 ) ) {\n\t\t\t// Check for an unpaired surrogate at the end of the input string...\n\t\t\tif ( i === 0 ) {\n\t\t\t\t// We found an unpaired surrogate...\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\t// Check whether the high surrogate is paired with a low surrogate...\n\t\t\tch2 = str[ i-1 ];\n\t\t\tif ( RE_UTF16_HIGH_SURROGATE.test( ch2 ) ) {\n\t\t\t\t// We found a surrogate pair:\n\t\t\t\ti -= 1; // bump the index to process the next code unit\n\t\t\t}\n\t\t}\n\t\t// Check whether we've found the desired number of code points...\n\t\tif ( cnt === n ) {\n\t\t\tbreak;\n\t\t}\n\t}\n\treturn str.substring( 0, i );\n}\n\n\n// EXPORTS //\n\nexport default removeLast;\n"],"names":["RE_UTF16_LOW_SURROGATE","RE_UTF16_HIGH_SURROGATE","str","n","ch1","ch2","cnt","i","length","test","substring"],"mappings":";yCAsBA,IAAIA,EAAyB,kBACzBC,EAA0B,yBA4B9B,SAAqBC,EAAKC,GACzB,IACIC,EACAC,EACAC,EACAC,EACJ,GAAW,IAANJ,EACJ,OAAOD,EAMR,IAHAI,EAAM,EAGAC,EAJAL,EAAIM,OAIM,EAAGD,GAAK,EAAGA,IAAM,CAKhC,GAJAH,EAAMF,EAAKK,GACXD,GAAO,EAGFN,EAAuBS,KAAML,GAAQ,CAEzC,GAAW,IAANG,EAEJ,MAGDF,EAAMH,EAAKK,EAAE,GACRN,EAAwBQ,KAAMJ,KAElCE,GAAK,EAEN,CAED,GAAKD,IAAQH,EACZ,KAED,CACD,OAAOD,EAAIQ,UAAW,EAAGH,EAC1B"} \ No newline at end of file diff --git a/stats_browser.html b/stats_browser.html deleted file mode 100644 index 441d43d..0000000 --- a/stats_browser.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - diff --git a/stats_node.html b/stats_node.html deleted file mode 100644 index 8a5f437..0000000 --- a/stats_node.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 8df939ec00c253c378c128625ba9e154e4f977e5 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Feb 2024 00:42:54 +0000 Subject: [PATCH 35/92] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 797 --- .github/workflows/publish.yml | 255 - .github/workflows/test.yml | 100 - .github/workflows/test_bundles.yml | 189 - .github/workflows/test_coverage.yml | 128 - .github/workflows/test_install.yml | 86 - .gitignore | 188 - .npmignore | 228 - .npmrc | 28 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 52 +- SECURITY.md | 5 - benchmark/benchmark.js | 56 - branches.md | 56 - browser.js | 3 + browser.js.map | 1 + dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 29 - docs/types/index.d.ts | 53 - docs/types/test.ts | 57 - examples/index.js | 33 - index.js | 3 + index.js.map | 1 + lib/index.js | 43 - lib/main.js | 94 - package.json | 53 +- stats_browser.html | 6177 +++++++++++++++++++++ stats_node.html | 6177 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 108 - 46 files changed, 12398 insertions(+), 3815 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md create mode 100644 browser.js create mode 100644 browser.js.map 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/index.d.ts delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js create mode 100644 index.js create mode 100644 index.js.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats_browser.html create mode 100644 stats_node.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index dbf5cd2..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-02-01T00:29:37.074Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 52cd9c4..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/base/remove-last-code-point) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 533eeee..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/base/remove-last-code-point) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 d222294..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: '29 5 * * 0' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA corresponding to v3.1.3 - uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index e1e3539..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,797 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA corresponding to v2.0.0 - uses: act10ns/slack@ed1309ab9862e57e9e583e51c7889486b9a00b0f - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n +``` -```javascript -var removeLastCodePoint = require( '@stdlib/string-base-remove-last-code-point' ); +If no recognized module system is present, access bundle contents via the global scope: + +```html + ``` #### removeLastCodePoint( str, n ) @@ -91,8 +97,13 @@ out = removeLastCodePoint( 'foo bar', 10 ); -```javascript -var removeLastCodePoint = require( '@stdlib/string-base-remove-last-code-point' ); +```html + + + + + + + ```
diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index a39bd29..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,56 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var removeLast = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var values; - var out; - var i; - - values = [ - 'beep boop', - 'foo bar', - 'xyz abc', - '🐶🐮🐷🐰🐸' - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = removeLast( values[ i%values.length ], 1 ); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( !isString( out ) ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index f585c99..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/base/remove-last-code-point" -%% click B href "https://github.com/stdlib-js/string-base-remove-last-code-point/tree/main" -%% click C href "https://github.com/stdlib-js/string-base-remove-last-code-point/tree/production" -%% click D href "https://github.com/stdlib-js/string-base-remove-last-code-point/tree/esm" -%% click E href "https://github.com/stdlib-js/string-base-remove-last-code-point/tree/deno" -%% click F href "https://github.com/stdlib-js/string-base-remove-last-code-point/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/base/remove-last-code-point -[production-url]: https://github.com/stdlib-js/string-base-remove-last-code-point/tree/production -[deno-url]: https://github.com/stdlib-js/string-base-remove-last-code-point/tree/deno -[deno-readme]: https://github.com/stdlib-js/string-base-remove-last-code-point/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/string-base-remove-last-code-point/tree/umd -[umd-readme]: https://github.com/stdlib-js/string-base-remove-last-code-point/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/string-base-remove-last-code-point/tree/esm -[esm-readme]: https://github.com/stdlib-js/string-base-remove-last-code-point/blob/esm/README.md \ No newline at end of file diff --git a/browser.js b/browser.js new file mode 100644 index 0000000..f3a511a --- /dev/null +++ b/browser.js @@ -0,0 +1,3 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +var e,t;e=this,t=function(){"use strict";var e=/[\uDC00-\uDFFF]/,t=/[\uD800-\uDBFF]/;return function(n,f){var i,o,r,u;if(0===f)return n;for(r=0,u=n.length-1;u>=0;u--){if(i=n[u],r+=1,e.test(i)){if(0===u)break;o=n[u-1],t.test(o)&&(u-=1)}if(r===f)break}return n.substring(0,u)}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).removeLastCodePoint=t(); +//# sourceMappingURL=browser.js.map diff --git a/browser.js.map b/browser.js.map new file mode 100644 index 0000000..19908eb --- /dev/null +++ b/browser.js.map @@ -0,0 +1 @@ +{"version":3,"file":"browser.js","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\nvar RE_UTF16_LOW_SURROGATE = /[\\uDC00-\\uDFFF]/; // TODO: replace with stdlib pkg\nvar RE_UTF16_HIGH_SURROGATE = /[\\uD800-\\uDBFF]/; // TODO: replace with stdlib pkg\n\n\n// MAIN //\n\n/**\n* Removes the last `n` Unicode code points of a string.\n*\n* @param {string} str - input string\n* @param {NonNegativeInteger} n - number of Unicode code points to remove\n* @returns {string} output string\n*\n* @example\n* var out = removeLast( 'last man standing', 1 );\n* // returns 'last man standin'\n*\n* @example\n* var out = removeLast( 'presidential election', 1 );\n* // returns 'presidential electio'\n*\n* @example\n* var out = removeLast( 'JavaScript', 1 );\n* // returns 'JavaScrip'\n*\n* @example\n* var out = removeLast( 'Hidden Treasures', 1 );\n* // returns 'Hidden Treasure'\n*/\nfunction removeLast( str, n ) {\n\tvar len;\n\tvar ch1;\n\tvar ch2;\n\tvar cnt;\n\tvar i;\n\tif ( n === 0 ) {\n\t\treturn str;\n\t}\n\tlen = str.length;\n\tcnt = 0;\n\n\t// Process the string one Unicode code unit at a time and count UTF-16 surrogate pairs as a single Unicode code point...\n\tfor ( i = len - 1; i >= 0; i-- ) {\n\t\tch1 = str[ i ];\n\t\tcnt += 1;\n\n\t\t// Check for a low UTF-16 surrogate...\n\t\tif ( RE_UTF16_LOW_SURROGATE.test( ch1 ) ) {\n\t\t\t// Check for an unpaired surrogate at the end of the input string...\n\t\t\tif ( i === 0 ) {\n\t\t\t\t// We found an unpaired surrogate...\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\t// Check whether the high surrogate is paired with a low surrogate...\n\t\t\tch2 = str[ i-1 ];\n\t\t\tif ( RE_UTF16_HIGH_SURROGATE.test( ch2 ) ) {\n\t\t\t\t// We found a surrogate pair:\n\t\t\t\ti -= 1; // bump the index to process the next code unit\n\t\t\t}\n\t\t}\n\t\t// Check whether we've found the desired number of code points...\n\t\tif ( cnt === n ) {\n\t\t\tbreak;\n\t\t}\n\t}\n\treturn str.substring( 0, i );\n}\n\n\n// EXPORTS //\n\nexport default removeLast;\n"],"names":["RE_UTF16_LOW_SURROGATE","RE_UTF16_HIGH_SURROGATE","str","n","ch1","ch2","cnt","i","length","test","substring"],"mappings":";yCAsBA,IAAIA,EAAyB,kBACzBC,EAA0B,yBA4B9B,SAAqBC,EAAKC,GACzB,IACIC,EACAC,EACAC,EACAC,EACJ,GAAW,IAANJ,EACJ,OAAOD,EAMR,IAHAI,EAAM,EAGAC,EAJAL,EAAIM,OAIM,EAAGD,GAAK,EAAGA,IAAM,CAKhC,GAJAH,EAAMF,EAAKK,GACXD,GAAO,EAGFN,EAAuBS,KAAML,GAAQ,CAEzC,GAAW,IAANG,EAEJ,MAGDF,EAAMH,EAAKK,EAAE,GACRN,EAAwBQ,KAAMJ,KAElCE,GAAK,EAEN,CAED,GAAKD,IAAQH,EACZ,KAED,CACD,OAAOD,EAAIQ,UAAW,EAAGH,EAC1B"} \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index 8c96fd7..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import removeLast from '../docs/types/index'; -export = removeLast; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index e6b7220..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var s=function(e,t){return function(){return t||e((t={exports:{}}).exports,t),t.exports}};var f=s(function(D,n){ -var F=/[\uDC00-\uDFFF]/,c=/[\uD800-\uDBFF]/;function R(e,t){var i,u,v,a,r;if(t===0)return e;for(i=e.length,a=0,r=i-1;r>=0;r--){if(u=e[r],a+=1,F.test(u)){if(r===0)break;v=e[r-1],c.test(v)&&(r-=1)}if(a===t)break}return e.substring(0,r)}n.exports=R -});var _=f();module.exports=_; -/** @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 72561cf..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\nvar RE_UTF16_LOW_SURROGATE = /[\\uDC00-\\uDFFF]/; // TODO: replace with stdlib pkg\nvar RE_UTF16_HIGH_SURROGATE = /[\\uD800-\\uDBFF]/; // TODO: replace with stdlib pkg\n\n\n// MAIN //\n\n/**\n* Removes the last `n` Unicode code points of a string.\n*\n* @param {string} str - input string\n* @param {NonNegativeInteger} n - number of Unicode code points to remove\n* @returns {string} output string\n*\n* @example\n* var out = removeLast( 'last man standing', 1 );\n* // returns 'last man standin'\n*\n* @example\n* var out = removeLast( 'presidential election', 1 );\n* // returns 'presidential electio'\n*\n* @example\n* var out = removeLast( 'JavaScript', 1 );\n* // returns 'JavaScrip'\n*\n* @example\n* var out = removeLast( 'Hidden Treasures', 1 );\n* // returns 'Hidden Treasure'\n*/\nfunction removeLast( str, n ) {\n\tvar len;\n\tvar ch1;\n\tvar ch2;\n\tvar cnt;\n\tvar i;\n\tif ( n === 0 ) {\n\t\treturn str;\n\t}\n\tlen = str.length;\n\tcnt = 0;\n\n\t// Process the string one Unicode code unit at a time and count UTF-16 surrogate pairs as a single Unicode code point...\n\tfor ( i = len - 1; i >= 0; i-- ) {\n\t\tch1 = str[ i ];\n\t\tcnt += 1;\n\n\t\t// Check for a low UTF-16 surrogate...\n\t\tif ( RE_UTF16_LOW_SURROGATE.test( ch1 ) ) {\n\t\t\t// Check for an unpaired surrogate at the end of the input string...\n\t\t\tif ( i === 0 ) {\n\t\t\t\t// We found an unpaired surrogate...\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\t// Check whether the high surrogate is paired with a low surrogate...\n\t\t\tch2 = str[ i-1 ];\n\t\t\tif ( RE_UTF16_HIGH_SURROGATE.test( ch2 ) ) {\n\t\t\t\t// We found a surrogate pair:\n\t\t\t\ti -= 1; // bump the index to process the next code unit\n\t\t\t}\n\t\t}\n\t\t// Check whether we've found the desired number of code points...\n\t\tif ( cnt === n ) {\n\t\t\tbreak;\n\t\t}\n\t}\n\treturn str.substring( 0, i );\n}\n\n\n// EXPORTS //\n\nmodule.exports = removeLast;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Remove the last `n` Unicode code points of a string.\n*\n* @module @stdlib/string-base-remove-last-code-point\n*\n* @example\n* var removeLast = require( '@stdlib/string-base-remove-last-code-point' );\n*\n* var out = removeLast( 'last man standing', 1 );\n* // returns 'last man standin'\n*\n* out = removeLast( 'Hidden Treasures', 1 );\n* // returns 'Hidden Treasure';\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,EAAyB,kBACzBC,EAA0B,kBA4B9B,SAASC,EAAYC,EAAKC,EAAI,CAC7B,IAAIC,EACAC,EACAC,EACAC,EACAC,EACJ,GAAKL,IAAM,EACV,OAAOD,EAMR,IAJAE,EAAMF,EAAI,OACVK,EAAM,EAGAC,EAAIJ,EAAM,EAAGI,GAAK,EAAGA,IAAM,CAKhC,GAJAH,EAAMH,EAAKM,CAAE,EACbD,GAAO,EAGFR,EAAuB,KAAMM,CAAI,EAAI,CAEzC,GAAKG,IAAM,EAEV,MAGDF,EAAMJ,EAAKM,EAAE,CAAE,EACVR,EAAwB,KAAMM,CAAI,IAEtCE,GAAK,EAEP,CAEA,GAAKD,IAAQJ,EACZ,KAEF,CACA,OAAOD,EAAI,UAAW,EAAGM,CAAE,CAC5B,CAKAV,EAAO,QAAUG,ICxDjB,IAAIQ,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "RE_UTF16_LOW_SURROGATE", "RE_UTF16_HIGH_SURROGATE", "removeLast", "str", "n", "len", "ch1", "ch2", "cnt", "i", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index a08ea55..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,29 +0,0 @@ - -{{alias}}( str, n ) - Removes the last `n` Unicode code points of a string. - - Parameters - ---------- - str: string - Input string. - - n: integer - Number of Unicode code points to remove. - - Returns - ------- - out: string - Output string. - - Examples - -------- - > var out = {{alias}}( 'beep', 1 ) - 'bee' - > out = {{alias}}( 'Boop', 1 ) - 'Boo' - > out = {{alias}}( 'foo bar', 5 ) - 'fo' - - See Also - -------- - diff --git a/docs/types/index.d.ts b/docs/types/index.d.ts deleted file mode 100644 index 8a1c90b..0000000 --- a/docs/types/index.d.ts +++ /dev/null @@ -1,53 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 - -/** -* Removes the last `n` Unicode code points of a string. -* -* @param str - input string -* @param n - number of code points to remove -* @returns output string -* -* @example -* var out = removeLast( 'last man standing', 1 ); -* // returns 'last man standin' -* -* @example -* var out = removeLast( 'presidential election', 1 ); -* // returns 'presidential electio' -* -* @example -* var out = removeLast( 'JavaScript', 1 ); -* // returns 'JavaScrip' -* -* @example -* var out = removeLast( 'Hidden Treasures', 1 ); -* // returns 'Hidden Treasure' -* -* @example -* var out = removeLast( 'foo bar', 5 ); -* // returns 'fo' -*/ -declare function removeLast( str: string, n: number ): string; - - -// EXPORTS // - -export = removeLast; diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index fd426d2..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,57 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 removeLast = require( './index' ); - - -// TESTS // - -// The function returns a string... -{ - removeLast( 'abc', 1 ); // $ExpectType string -} - -// The compiler throws an error if the function is provided a value other than a string... -{ - removeLast( true, 1 ); // $ExpectError - removeLast( false, 1 ); // $ExpectError - removeLast( null, 1 ); // $ExpectError - removeLast( undefined, 1 ); // $ExpectError - removeLast( 5, 1 ); // $ExpectError - removeLast( [], 1 ); // $ExpectError - removeLast( {}, 1 ); // $ExpectError - removeLast( ( x: number ): number => x, 1 ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument that is not a number... -{ - removeLast( 'abc', true ); // $ExpectError - removeLast( 'abc', false ); // $ExpectError - removeLast( 'abc', null ); // $ExpectError - removeLast( 'abc', 'abc' ); // $ExpectError - removeLast( 'abc', [] ); // $ExpectError - removeLast( 'abc', {} ); // $ExpectError - removeLast( 'abc', ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - removeLast(); // $ExpectError - removeLast( 'abc' ); // $ExpectError - removeLast( 'abc', 1, 2 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 085633e..0000000 --- a/examples/index.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var removeLastCodePoint = require( './../lib' ); - -console.log( removeLastCodePoint( 'presidential election', 1 ) ); -// => 'presidential electio' - -console.log( removeLastCodePoint( 'JavaScript', 1 ) ); -// => 'JavaScrip' - -console.log( removeLastCodePoint( 'The Last of the Mohicans', 5 ) ); -// => 'The Last of the Moh' - -console.log( removeLastCodePoint( 'अनुच्छेद', 1 ) ); -// => 'अनुच्छे' diff --git a/index.js b/index.js new file mode 100644 index 0000000..4e500d1 --- /dev/null +++ b/index.js @@ -0,0 +1,3 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +var e,t;e=this,t=function(){"use strict";var e=/[\uDC00-\uDFFF]/,t=/[\uD800-\uDBFF]/;return function(n,f){var i,o,r,u;if(0===f)return n;for(r=0,u=n.length-1;u>=0;u--){if(i=n[u],r+=1,e.test(i)){if(0===u)break;o=n[u-1],t.test(o)&&(u-=1)}if(r===f)break}return n.substring(0,u)}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).removeLastCodePoint=t(); +//# sourceMappingURL=index.js.map diff --git a/index.js.map b/index.js.map new file mode 100644 index 0000000..d557af8 --- /dev/null +++ b/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\nvar RE_UTF16_LOW_SURROGATE = /[\\uDC00-\\uDFFF]/; // TODO: replace with stdlib pkg\nvar RE_UTF16_HIGH_SURROGATE = /[\\uD800-\\uDBFF]/; // TODO: replace with stdlib pkg\n\n\n// MAIN //\n\n/**\n* Removes the last `n` Unicode code points of a string.\n*\n* @param {string} str - input string\n* @param {NonNegativeInteger} n - number of Unicode code points to remove\n* @returns {string} output string\n*\n* @example\n* var out = removeLast( 'last man standing', 1 );\n* // returns 'last man standin'\n*\n* @example\n* var out = removeLast( 'presidential election', 1 );\n* // returns 'presidential electio'\n*\n* @example\n* var out = removeLast( 'JavaScript', 1 );\n* // returns 'JavaScrip'\n*\n* @example\n* var out = removeLast( 'Hidden Treasures', 1 );\n* // returns 'Hidden Treasure'\n*/\nfunction removeLast( str, n ) {\n\tvar len;\n\tvar ch1;\n\tvar ch2;\n\tvar cnt;\n\tvar i;\n\tif ( n === 0 ) {\n\t\treturn str;\n\t}\n\tlen = str.length;\n\tcnt = 0;\n\n\t// Process the string one Unicode code unit at a time and count UTF-16 surrogate pairs as a single Unicode code point...\n\tfor ( i = len - 1; i >= 0; i-- ) {\n\t\tch1 = str[ i ];\n\t\tcnt += 1;\n\n\t\t// Check for a low UTF-16 surrogate...\n\t\tif ( RE_UTF16_LOW_SURROGATE.test( ch1 ) ) {\n\t\t\t// Check for an unpaired surrogate at the end of the input string...\n\t\t\tif ( i === 0 ) {\n\t\t\t\t// We found an unpaired surrogate...\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\t// Check whether the high surrogate is paired with a low surrogate...\n\t\t\tch2 = str[ i-1 ];\n\t\t\tif ( RE_UTF16_HIGH_SURROGATE.test( ch2 ) ) {\n\t\t\t\t// We found a surrogate pair:\n\t\t\t\ti -= 1; // bump the index to process the next code unit\n\t\t\t}\n\t\t}\n\t\t// Check whether we've found the desired number of code points...\n\t\tif ( cnt === n ) {\n\t\t\tbreak;\n\t\t}\n\t}\n\treturn str.substring( 0, i );\n}\n\n\n// EXPORTS //\n\nexport default removeLast;\n"],"names":["RE_UTF16_LOW_SURROGATE","RE_UTF16_HIGH_SURROGATE","str","n","ch1","ch2","cnt","i","length","test","substring"],"mappings":";yCAsBA,IAAIA,EAAyB,kBACzBC,EAA0B,yBA4B9B,SAAqBC,EAAKC,GACzB,IACIC,EACAC,EACAC,EACAC,EACJ,GAAW,IAANJ,EACJ,OAAOD,EAMR,IAHAI,EAAM,EAGAC,EAJAL,EAAIM,OAIM,EAAGD,GAAK,EAAGA,IAAM,CAKhC,GAJAH,EAAMF,EAAKK,GACXD,GAAO,EAGFN,EAAuBS,KAAML,GAAQ,CAEzC,GAAW,IAANG,EAEJ,MAGDF,EAAMH,EAAKK,EAAE,GACRN,EAAwBQ,KAAMJ,KAElCE,GAAK,EAEN,CAED,GAAKD,IAAQH,EACZ,KAED,CACD,OAAOD,EAAIQ,UAAW,EAAGH,EAC1B"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 9860da0..0000000 --- a/lib/index.js +++ /dev/null @@ -1,43 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Remove the last `n` Unicode code points of a string. -* -* @module @stdlib/string-base-remove-last-code-point -* -* @example -* var removeLast = require( '@stdlib/string-base-remove-last-code-point' ); -* -* var out = removeLast( 'last man standing', 1 ); -* // returns 'last man standin' -* -* out = removeLast( 'Hidden Treasures', 1 ); -* // returns 'Hidden Treasure'; -*/ - -// 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 fc34187..0000000 --- a/lib/main.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// VARIABLES // - -var RE_UTF16_LOW_SURROGATE = /[\uDC00-\uDFFF]/; // TODO: replace with stdlib pkg -var RE_UTF16_HIGH_SURROGATE = /[\uD800-\uDBFF]/; // TODO: replace with stdlib pkg - - -// MAIN // - -/** -* Removes the last `n` Unicode code points of a string. -* -* @param {string} str - input string -* @param {NonNegativeInteger} n - number of Unicode code points to remove -* @returns {string} output string -* -* @example -* var out = removeLast( 'last man standing', 1 ); -* // returns 'last man standin' -* -* @example -* var out = removeLast( 'presidential election', 1 ); -* // returns 'presidential electio' -* -* @example -* var out = removeLast( 'JavaScript', 1 ); -* // returns 'JavaScrip' -* -* @example -* var out = removeLast( 'Hidden Treasures', 1 ); -* // returns 'Hidden Treasure' -*/ -function removeLast( str, n ) { - var len; - var ch1; - var ch2; - var cnt; - var i; - if ( n === 0 ) { - return str; - } - len = str.length; - cnt = 0; - - // Process the string one Unicode code unit at a time and count UTF-16 surrogate pairs as a single Unicode code point... - for ( i = len - 1; i >= 0; i-- ) { - ch1 = str[ i ]; - cnt += 1; - - // Check for a low UTF-16 surrogate... - if ( RE_UTF16_LOW_SURROGATE.test( ch1 ) ) { - // Check for an unpaired surrogate at the end of the input string... - if ( i === 0 ) { - // We found an unpaired surrogate... - break; - } - // Check whether the high surrogate is paired with a low surrogate... - ch2 = str[ i-1 ]; - if ( RE_UTF16_HIGH_SURROGATE.test( ch2 ) ) { - // We found a surrogate pair: - i -= 1; // bump the index to process the next code unit - } - } - // Check whether we've found the desired number of code points... - if ( cnt === n ) { - break; - } - } - return str.substring( 0, i ); -} - - -// EXPORTS // - -module.exports = removeLast; diff --git a/package.json b/package.json index c5271ba..2328e01 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,7 @@ "version": "0.1.1", "description": "Remove the last Unicode code point of a string.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "main": "./index.js", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,31 +12,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/error-tools-fmtprodmsg": "^0.1.1" - }, - "devDependencies": { - "@stdlib/assert-is-string": "^0.1.1", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.1.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdstring", @@ -81,4 +32,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/stats_browser.html b/stats_browser.html new file mode 100644 index 0000000..ff23ee4 --- /dev/null +++ b/stats_browser.html @@ -0,0 +1,6177 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/stats_node.html b/stats_node.html new file mode 100644 index 0000000..e90c8c0 --- /dev/null +++ b/stats_node.html @@ -0,0 +1,6177 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index a25545e..0000000 --- a/test/test.js +++ /dev/null @@ -1,108 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var removeLast = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof removeLast, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns an empty string if provided an empty string', function test( t ) { - t.strictEqual( removeLast( '', 1 ), '', 'returns expected value' ); - t.strictEqual( removeLast( '', 2 ), '', 'returns expected value' ); - t.strictEqual( removeLast( '', 3 ), '', 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns the input string if provided zero as the second argument', function test( t ) { - t.strictEqual( removeLast( 'hello world', 0 ), 'hello world', 'returns expected value' ); - t.end(); -}); - -tape( 'the function removes the last Unicode code point of a provided string (ascii)', function test( t ) { - var out; - - out = removeLast( 'hello world', 1 ); - t.strictEqual( out, 'hello worl', 'returns expected value' ); - - out = removeLast( '!!!', 1 ); - t.strictEqual( out, '!!', 'returns expected value' ); - - out = removeLast( 'Hello World', 1 ); - t.strictEqual( out, 'Hello Worl', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function removes the last Unicode code point of a provided string (Unicode)', function test( t ) { - var out; - - out = removeLast( 'अनुच्छेद', 1 ); - t.strictEqual( out, 'अनुच्छे', 'returns expected value' ); - - out = removeLast( '六书/六書', 1 ); - t.strictEqual( out, '六书/六', 'returns expected value' ); - - out = removeLast( '𐒻𐓟', 1 ); - t.strictEqual( out, '𐒻', 'returns expected value' ); - - out = removeLast( '𐒻𐓟', 1 ); - t.strictEqual( out, '𐒻', 'returns expected value' ); - - out = removeLast( '\uDC00', 1 ); - t.strictEqual( out, '', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports removing the last `n` Unicode code points of a provided string', function test( t ) { - var out; - - out = removeLast( 'hello world', 1 ); - t.strictEqual( out, 'hello worl', 'returns expected value' ); - - out = removeLast( 'hello world', 7 ); - t.strictEqual( out, 'hell', 'returns expected value' ); - - out = removeLast( '!!!', 1 ); - t.strictEqual( out, '!!', 'returns expected value' ); - - out = removeLast( '!!!', 2 ); - t.strictEqual( out, '!', 'returns expected value' ); - - out = removeLast( 'अनुच्छेद', 1 ); - t.strictEqual( out, 'अनुच्छे', 'returns expected value' ); - - out = removeLast( '六书/六書', 3 ); - t.strictEqual( out, '六书', 'returns expected value' ); - - out = removeLast( '𐒻𐓟𐓟', 2 ); - t.strictEqual( out, '𐒻', 'returns expected value' ); - - t.end(); -}); From a102c20f7d1ed698eba7acfe35b9914667784ef0 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 14 Feb 2024 03:23:32 +0000 Subject: [PATCH 36/92] Transform error messages --- package.json | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 491db11..5512b62 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,9 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": {}, + "dependencies": { + "@stdlib/error-tools-fmtprodmsg": "^0.1.1" + }, "devDependencies": { "@stdlib/assert-is-string": "^0.1.1", "tape": "git+https://github.com/kgryte/tape.git#fix/globby", @@ -79,4 +81,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 6aace2db5d269d59dfa70ac693f65fb3ac15a9cd Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 14 Feb 2024 03:33:31 +0000 Subject: [PATCH 37/92] Remove files --- browser.js | 3 - browser.js.map | 1 - index.js | 3 - index.js.map | 1 - stats_browser.html | 6177 -------------------------------------------- stats_node.html | 6177 -------------------------------------------- 6 files changed, 12362 deletions(-) delete mode 100644 browser.js delete mode 100644 browser.js.map delete mode 100644 index.js delete mode 100644 index.js.map delete mode 100644 stats_browser.html delete mode 100644 stats_node.html diff --git a/browser.js b/browser.js deleted file mode 100644 index f3a511a..0000000 --- a/browser.js +++ /dev/null @@ -1,3 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -var e,t;e=this,t=function(){"use strict";var e=/[\uDC00-\uDFFF]/,t=/[\uD800-\uDBFF]/;return function(n,f){var i,o,r,u;if(0===f)return n;for(r=0,u=n.length-1;u>=0;u--){if(i=n[u],r+=1,e.test(i)){if(0===u)break;o=n[u-1],t.test(o)&&(u-=1)}if(r===f)break}return n.substring(0,u)}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).removeLastCodePoint=t(); -//# sourceMappingURL=browser.js.map diff --git a/browser.js.map b/browser.js.map deleted file mode 100644 index 19908eb..0000000 --- a/browser.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"browser.js","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\nvar RE_UTF16_LOW_SURROGATE = /[\\uDC00-\\uDFFF]/; // TODO: replace with stdlib pkg\nvar RE_UTF16_HIGH_SURROGATE = /[\\uD800-\\uDBFF]/; // TODO: replace with stdlib pkg\n\n\n// MAIN //\n\n/**\n* Removes the last `n` Unicode code points of a string.\n*\n* @param {string} str - input string\n* @param {NonNegativeInteger} n - number of Unicode code points to remove\n* @returns {string} output string\n*\n* @example\n* var out = removeLast( 'last man standing', 1 );\n* // returns 'last man standin'\n*\n* @example\n* var out = removeLast( 'presidential election', 1 );\n* // returns 'presidential electio'\n*\n* @example\n* var out = removeLast( 'JavaScript', 1 );\n* // returns 'JavaScrip'\n*\n* @example\n* var out = removeLast( 'Hidden Treasures', 1 );\n* // returns 'Hidden Treasure'\n*/\nfunction removeLast( str, n ) {\n\tvar len;\n\tvar ch1;\n\tvar ch2;\n\tvar cnt;\n\tvar i;\n\tif ( n === 0 ) {\n\t\treturn str;\n\t}\n\tlen = str.length;\n\tcnt = 0;\n\n\t// Process the string one Unicode code unit at a time and count UTF-16 surrogate pairs as a single Unicode code point...\n\tfor ( i = len - 1; i >= 0; i-- ) {\n\t\tch1 = str[ i ];\n\t\tcnt += 1;\n\n\t\t// Check for a low UTF-16 surrogate...\n\t\tif ( RE_UTF16_LOW_SURROGATE.test( ch1 ) ) {\n\t\t\t// Check for an unpaired surrogate at the end of the input string...\n\t\t\tif ( i === 0 ) {\n\t\t\t\t// We found an unpaired surrogate...\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\t// Check whether the high surrogate is paired with a low surrogate...\n\t\t\tch2 = str[ i-1 ];\n\t\t\tif ( RE_UTF16_HIGH_SURROGATE.test( ch2 ) ) {\n\t\t\t\t// We found a surrogate pair:\n\t\t\t\ti -= 1; // bump the index to process the next code unit\n\t\t\t}\n\t\t}\n\t\t// Check whether we've found the desired number of code points...\n\t\tif ( cnt === n ) {\n\t\t\tbreak;\n\t\t}\n\t}\n\treturn str.substring( 0, i );\n}\n\n\n// EXPORTS //\n\nexport default removeLast;\n"],"names":["RE_UTF16_LOW_SURROGATE","RE_UTF16_HIGH_SURROGATE","str","n","ch1","ch2","cnt","i","length","test","substring"],"mappings":";yCAsBA,IAAIA,EAAyB,kBACzBC,EAA0B,yBA4B9B,SAAqBC,EAAKC,GACzB,IACIC,EACAC,EACAC,EACAC,EACJ,GAAW,IAANJ,EACJ,OAAOD,EAMR,IAHAI,EAAM,EAGAC,EAJAL,EAAIM,OAIM,EAAGD,GAAK,EAAGA,IAAM,CAKhC,GAJAH,EAAMF,EAAKK,GACXD,GAAO,EAGFN,EAAuBS,KAAML,GAAQ,CAEzC,GAAW,IAANG,EAEJ,MAGDF,EAAMH,EAAKK,EAAE,GACRN,EAAwBQ,KAAMJ,KAElCE,GAAK,EAEN,CAED,GAAKD,IAAQH,EACZ,KAED,CACD,OAAOD,EAAIQ,UAAW,EAAGH,EAC1B"} \ No newline at end of file diff --git a/index.js b/index.js deleted file mode 100644 index 4e500d1..0000000 --- a/index.js +++ /dev/null @@ -1,3 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -var e,t;e=this,t=function(){"use strict";var e=/[\uDC00-\uDFFF]/,t=/[\uD800-\uDBFF]/;return function(n,f){var i,o,r,u;if(0===f)return n;for(r=0,u=n.length-1;u>=0;u--){if(i=n[u],r+=1,e.test(i)){if(0===u)break;o=n[u-1],t.test(o)&&(u-=1)}if(r===f)break}return n.substring(0,u)}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).removeLastCodePoint=t(); -//# sourceMappingURL=index.js.map diff --git a/index.js.map b/index.js.map deleted file mode 100644 index d557af8..0000000 --- a/index.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.js","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\nvar RE_UTF16_LOW_SURROGATE = /[\\uDC00-\\uDFFF]/; // TODO: replace with stdlib pkg\nvar RE_UTF16_HIGH_SURROGATE = /[\\uD800-\\uDBFF]/; // TODO: replace with stdlib pkg\n\n\n// MAIN //\n\n/**\n* Removes the last `n` Unicode code points of a string.\n*\n* @param {string} str - input string\n* @param {NonNegativeInteger} n - number of Unicode code points to remove\n* @returns {string} output string\n*\n* @example\n* var out = removeLast( 'last man standing', 1 );\n* // returns 'last man standin'\n*\n* @example\n* var out = removeLast( 'presidential election', 1 );\n* // returns 'presidential electio'\n*\n* @example\n* var out = removeLast( 'JavaScript', 1 );\n* // returns 'JavaScrip'\n*\n* @example\n* var out = removeLast( 'Hidden Treasures', 1 );\n* // returns 'Hidden Treasure'\n*/\nfunction removeLast( str, n ) {\n\tvar len;\n\tvar ch1;\n\tvar ch2;\n\tvar cnt;\n\tvar i;\n\tif ( n === 0 ) {\n\t\treturn str;\n\t}\n\tlen = str.length;\n\tcnt = 0;\n\n\t// Process the string one Unicode code unit at a time and count UTF-16 surrogate pairs as a single Unicode code point...\n\tfor ( i = len - 1; i >= 0; i-- ) {\n\t\tch1 = str[ i ];\n\t\tcnt += 1;\n\n\t\t// Check for a low UTF-16 surrogate...\n\t\tif ( RE_UTF16_LOW_SURROGATE.test( ch1 ) ) {\n\t\t\t// Check for an unpaired surrogate at the end of the input string...\n\t\t\tif ( i === 0 ) {\n\t\t\t\t// We found an unpaired surrogate...\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\t// Check whether the high surrogate is paired with a low surrogate...\n\t\t\tch2 = str[ i-1 ];\n\t\t\tif ( RE_UTF16_HIGH_SURROGATE.test( ch2 ) ) {\n\t\t\t\t// We found a surrogate pair:\n\t\t\t\ti -= 1; // bump the index to process the next code unit\n\t\t\t}\n\t\t}\n\t\t// Check whether we've found the desired number of code points...\n\t\tif ( cnt === n ) {\n\t\t\tbreak;\n\t\t}\n\t}\n\treturn str.substring( 0, i );\n}\n\n\n// EXPORTS //\n\nexport default removeLast;\n"],"names":["RE_UTF16_LOW_SURROGATE","RE_UTF16_HIGH_SURROGATE","str","n","ch1","ch2","cnt","i","length","test","substring"],"mappings":";yCAsBA,IAAIA,EAAyB,kBACzBC,EAA0B,yBA4B9B,SAAqBC,EAAKC,GACzB,IACIC,EACAC,EACAC,EACAC,EACJ,GAAW,IAANJ,EACJ,OAAOD,EAMR,IAHAI,EAAM,EAGAC,EAJAL,EAAIM,OAIM,EAAGD,GAAK,EAAGA,IAAM,CAKhC,GAJAH,EAAMF,EAAKK,GACXD,GAAO,EAGFN,EAAuBS,KAAML,GAAQ,CAEzC,GAAW,IAANG,EAEJ,MAGDF,EAAMH,EAAKK,EAAE,GACRN,EAAwBQ,KAAMJ,KAElCE,GAAK,EAEN,CAED,GAAKD,IAAQH,EACZ,KAED,CACD,OAAOD,EAAIQ,UAAW,EAAGH,EAC1B"} \ No newline at end of file diff --git a/stats_browser.html b/stats_browser.html deleted file mode 100644 index ff23ee4..0000000 --- a/stats_browser.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - diff --git a/stats_node.html b/stats_node.html deleted file mode 100644 index e90c8c0..0000000 --- a/stats_node.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 2ca9fc0b61af2afda3325913811a95fb3b402d37 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 14 Feb 2024 03:33:46 +0000 Subject: [PATCH 38/92] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 797 --- .github/workflows/publish.yml | 255 - .github/workflows/test.yml | 100 - .github/workflows/test_bundles.yml | 189 - .github/workflows/test_coverage.yml | 132 - .github/workflows/test_install.yml | 86 - .gitignore | 188 - .npmignore | 228 - .npmrc | 28 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 52 +- SECURITY.md | 5 - benchmark/benchmark.js | 56 - branches.md | 56 - browser.js | 3 + browser.js.map | 1 + dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 29 - docs/types/index.d.ts | 53 - docs/types/test.ts | 57 - examples/index.js | 33 - index.js | 3 + index.js.map | 1 + lib/index.js | 43 - lib/main.js | 94 - package.json | 53 +- stats_browser.html | 6177 +++++++++++++++++++++ stats_node.html | 6177 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 108 - 45 files changed, 12398 insertions(+), 3818 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md create mode 100644 browser.js create mode 100644 browser.js.map 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/index.d.ts delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js create mode 100644 index.js create mode 100644 index.js.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats_browser.html create mode 100644 stats_node.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 52cd9c4..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/base/remove-last-code-point) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 533eeee..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/base/remove-last-code-point) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 374456b..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: '29 5 * * 0' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA corresponding to v3.1.3 - uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 9106b5d..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,797 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA corresponding to v2.0.0 - uses: act10ns/slack@ed1309ab9862e57e9e583e51c7889486b9a00b0f - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n +``` -```javascript -var removeLastCodePoint = require( '@stdlib/string-base-remove-last-code-point' ); +If no recognized module system is present, access bundle contents via the global scope: + +```html + ``` #### removeLastCodePoint( str, n ) @@ -91,8 +97,13 @@ out = removeLastCodePoint( 'foo bar', 10 ); -```javascript -var removeLastCodePoint = require( '@stdlib/string-base-remove-last-code-point' ); +```html + + + + + + + ```
diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index a39bd29..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,56 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var removeLast = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var values; - var out; - var i; - - values = [ - 'beep boop', - 'foo bar', - 'xyz abc', - '🐶🐮🐷🐰🐸' - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = removeLast( values[ i%values.length ], 1 ); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( !isString( out ) ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index f585c99..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/base/remove-last-code-point" -%% click B href "https://github.com/stdlib-js/string-base-remove-last-code-point/tree/main" -%% click C href "https://github.com/stdlib-js/string-base-remove-last-code-point/tree/production" -%% click D href "https://github.com/stdlib-js/string-base-remove-last-code-point/tree/esm" -%% click E href "https://github.com/stdlib-js/string-base-remove-last-code-point/tree/deno" -%% click F href "https://github.com/stdlib-js/string-base-remove-last-code-point/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/base/remove-last-code-point -[production-url]: https://github.com/stdlib-js/string-base-remove-last-code-point/tree/production -[deno-url]: https://github.com/stdlib-js/string-base-remove-last-code-point/tree/deno -[deno-readme]: https://github.com/stdlib-js/string-base-remove-last-code-point/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/string-base-remove-last-code-point/tree/umd -[umd-readme]: https://github.com/stdlib-js/string-base-remove-last-code-point/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/string-base-remove-last-code-point/tree/esm -[esm-readme]: https://github.com/stdlib-js/string-base-remove-last-code-point/blob/esm/README.md \ No newline at end of file diff --git a/browser.js b/browser.js new file mode 100644 index 0000000..f3a511a --- /dev/null +++ b/browser.js @@ -0,0 +1,3 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +var e,t;e=this,t=function(){"use strict";var e=/[\uDC00-\uDFFF]/,t=/[\uD800-\uDBFF]/;return function(n,f){var i,o,r,u;if(0===f)return n;for(r=0,u=n.length-1;u>=0;u--){if(i=n[u],r+=1,e.test(i)){if(0===u)break;o=n[u-1],t.test(o)&&(u-=1)}if(r===f)break}return n.substring(0,u)}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).removeLastCodePoint=t(); +//# sourceMappingURL=browser.js.map diff --git a/browser.js.map b/browser.js.map new file mode 100644 index 0000000..19908eb --- /dev/null +++ b/browser.js.map @@ -0,0 +1 @@ +{"version":3,"file":"browser.js","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\nvar RE_UTF16_LOW_SURROGATE = /[\\uDC00-\\uDFFF]/; // TODO: replace with stdlib pkg\nvar RE_UTF16_HIGH_SURROGATE = /[\\uD800-\\uDBFF]/; // TODO: replace with stdlib pkg\n\n\n// MAIN //\n\n/**\n* Removes the last `n` Unicode code points of a string.\n*\n* @param {string} str - input string\n* @param {NonNegativeInteger} n - number of Unicode code points to remove\n* @returns {string} output string\n*\n* @example\n* var out = removeLast( 'last man standing', 1 );\n* // returns 'last man standin'\n*\n* @example\n* var out = removeLast( 'presidential election', 1 );\n* // returns 'presidential electio'\n*\n* @example\n* var out = removeLast( 'JavaScript', 1 );\n* // returns 'JavaScrip'\n*\n* @example\n* var out = removeLast( 'Hidden Treasures', 1 );\n* // returns 'Hidden Treasure'\n*/\nfunction removeLast( str, n ) {\n\tvar len;\n\tvar ch1;\n\tvar ch2;\n\tvar cnt;\n\tvar i;\n\tif ( n === 0 ) {\n\t\treturn str;\n\t}\n\tlen = str.length;\n\tcnt = 0;\n\n\t// Process the string one Unicode code unit at a time and count UTF-16 surrogate pairs as a single Unicode code point...\n\tfor ( i = len - 1; i >= 0; i-- ) {\n\t\tch1 = str[ i ];\n\t\tcnt += 1;\n\n\t\t// Check for a low UTF-16 surrogate...\n\t\tif ( RE_UTF16_LOW_SURROGATE.test( ch1 ) ) {\n\t\t\t// Check for an unpaired surrogate at the end of the input string...\n\t\t\tif ( i === 0 ) {\n\t\t\t\t// We found an unpaired surrogate...\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\t// Check whether the high surrogate is paired with a low surrogate...\n\t\t\tch2 = str[ i-1 ];\n\t\t\tif ( RE_UTF16_HIGH_SURROGATE.test( ch2 ) ) {\n\t\t\t\t// We found a surrogate pair:\n\t\t\t\ti -= 1; // bump the index to process the next code unit\n\t\t\t}\n\t\t}\n\t\t// Check whether we've found the desired number of code points...\n\t\tif ( cnt === n ) {\n\t\t\tbreak;\n\t\t}\n\t}\n\treturn str.substring( 0, i );\n}\n\n\n// EXPORTS //\n\nexport default removeLast;\n"],"names":["RE_UTF16_LOW_SURROGATE","RE_UTF16_HIGH_SURROGATE","str","n","ch1","ch2","cnt","i","length","test","substring"],"mappings":";yCAsBA,IAAIA,EAAyB,kBACzBC,EAA0B,yBA4B9B,SAAqBC,EAAKC,GACzB,IACIC,EACAC,EACAC,EACAC,EACJ,GAAW,IAANJ,EACJ,OAAOD,EAMR,IAHAI,EAAM,EAGAC,EAJAL,EAAIM,OAIM,EAAGD,GAAK,EAAGA,IAAM,CAKhC,GAJAH,EAAMF,EAAKK,GACXD,GAAO,EAGFN,EAAuBS,KAAML,GAAQ,CAEzC,GAAW,IAANG,EAEJ,MAGDF,EAAMH,EAAKK,EAAE,GACRN,EAAwBQ,KAAMJ,KAElCE,GAAK,EAEN,CAED,GAAKD,IAAQH,EACZ,KAED,CACD,OAAOD,EAAIQ,UAAW,EAAGH,EAC1B"} \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index 8c96fd7..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import removeLast from '../docs/types/index'; -export = removeLast; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index e6b7220..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var s=function(e,t){return function(){return t||e((t={exports:{}}).exports,t),t.exports}};var f=s(function(D,n){ -var F=/[\uDC00-\uDFFF]/,c=/[\uD800-\uDBFF]/;function R(e,t){var i,u,v,a,r;if(t===0)return e;for(i=e.length,a=0,r=i-1;r>=0;r--){if(u=e[r],a+=1,F.test(u)){if(r===0)break;v=e[r-1],c.test(v)&&(r-=1)}if(a===t)break}return e.substring(0,r)}n.exports=R -});var _=f();module.exports=_; -/** @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 72561cf..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\nvar RE_UTF16_LOW_SURROGATE = /[\\uDC00-\\uDFFF]/; // TODO: replace with stdlib pkg\nvar RE_UTF16_HIGH_SURROGATE = /[\\uD800-\\uDBFF]/; // TODO: replace with stdlib pkg\n\n\n// MAIN //\n\n/**\n* Removes the last `n` Unicode code points of a string.\n*\n* @param {string} str - input string\n* @param {NonNegativeInteger} n - number of Unicode code points to remove\n* @returns {string} output string\n*\n* @example\n* var out = removeLast( 'last man standing', 1 );\n* // returns 'last man standin'\n*\n* @example\n* var out = removeLast( 'presidential election', 1 );\n* // returns 'presidential electio'\n*\n* @example\n* var out = removeLast( 'JavaScript', 1 );\n* // returns 'JavaScrip'\n*\n* @example\n* var out = removeLast( 'Hidden Treasures', 1 );\n* // returns 'Hidden Treasure'\n*/\nfunction removeLast( str, n ) {\n\tvar len;\n\tvar ch1;\n\tvar ch2;\n\tvar cnt;\n\tvar i;\n\tif ( n === 0 ) {\n\t\treturn str;\n\t}\n\tlen = str.length;\n\tcnt = 0;\n\n\t// Process the string one Unicode code unit at a time and count UTF-16 surrogate pairs as a single Unicode code point...\n\tfor ( i = len - 1; i >= 0; i-- ) {\n\t\tch1 = str[ i ];\n\t\tcnt += 1;\n\n\t\t// Check for a low UTF-16 surrogate...\n\t\tif ( RE_UTF16_LOW_SURROGATE.test( ch1 ) ) {\n\t\t\t// Check for an unpaired surrogate at the end of the input string...\n\t\t\tif ( i === 0 ) {\n\t\t\t\t// We found an unpaired surrogate...\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\t// Check whether the high surrogate is paired with a low surrogate...\n\t\t\tch2 = str[ i-1 ];\n\t\t\tif ( RE_UTF16_HIGH_SURROGATE.test( ch2 ) ) {\n\t\t\t\t// We found a surrogate pair:\n\t\t\t\ti -= 1; // bump the index to process the next code unit\n\t\t\t}\n\t\t}\n\t\t// Check whether we've found the desired number of code points...\n\t\tif ( cnt === n ) {\n\t\t\tbreak;\n\t\t}\n\t}\n\treturn str.substring( 0, i );\n}\n\n\n// EXPORTS //\n\nmodule.exports = removeLast;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Remove the last `n` Unicode code points of a string.\n*\n* @module @stdlib/string-base-remove-last-code-point\n*\n* @example\n* var removeLast = require( '@stdlib/string-base-remove-last-code-point' );\n*\n* var out = removeLast( 'last man standing', 1 );\n* // returns 'last man standin'\n*\n* out = removeLast( 'Hidden Treasures', 1 );\n* // returns 'Hidden Treasure';\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,EAAyB,kBACzBC,EAA0B,kBA4B9B,SAASC,EAAYC,EAAKC,EAAI,CAC7B,IAAIC,EACAC,EACAC,EACAC,EACAC,EACJ,GAAKL,IAAM,EACV,OAAOD,EAMR,IAJAE,EAAMF,EAAI,OACVK,EAAM,EAGAC,EAAIJ,EAAM,EAAGI,GAAK,EAAGA,IAAM,CAKhC,GAJAH,EAAMH,EAAKM,CAAE,EACbD,GAAO,EAGFR,EAAuB,KAAMM,CAAI,EAAI,CAEzC,GAAKG,IAAM,EAEV,MAGDF,EAAMJ,EAAKM,EAAE,CAAE,EACVR,EAAwB,KAAMM,CAAI,IAEtCE,GAAK,EAEP,CAEA,GAAKD,IAAQJ,EACZ,KAEF,CACA,OAAOD,EAAI,UAAW,EAAGM,CAAE,CAC5B,CAKAV,EAAO,QAAUG,ICxDjB,IAAIQ,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "RE_UTF16_LOW_SURROGATE", "RE_UTF16_HIGH_SURROGATE", "removeLast", "str", "n", "len", "ch1", "ch2", "cnt", "i", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index a08ea55..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,29 +0,0 @@ - -{{alias}}( str, n ) - Removes the last `n` Unicode code points of a string. - - Parameters - ---------- - str: string - Input string. - - n: integer - Number of Unicode code points to remove. - - Returns - ------- - out: string - Output string. - - Examples - -------- - > var out = {{alias}}( 'beep', 1 ) - 'bee' - > out = {{alias}}( 'Boop', 1 ) - 'Boo' - > out = {{alias}}( 'foo bar', 5 ) - 'fo' - - See Also - -------- - diff --git a/docs/types/index.d.ts b/docs/types/index.d.ts deleted file mode 100644 index 8a1c90b..0000000 --- a/docs/types/index.d.ts +++ /dev/null @@ -1,53 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 - -/** -* Removes the last `n` Unicode code points of a string. -* -* @param str - input string -* @param n - number of code points to remove -* @returns output string -* -* @example -* var out = removeLast( 'last man standing', 1 ); -* // returns 'last man standin' -* -* @example -* var out = removeLast( 'presidential election', 1 ); -* // returns 'presidential electio' -* -* @example -* var out = removeLast( 'JavaScript', 1 ); -* // returns 'JavaScrip' -* -* @example -* var out = removeLast( 'Hidden Treasures', 1 ); -* // returns 'Hidden Treasure' -* -* @example -* var out = removeLast( 'foo bar', 5 ); -* // returns 'fo' -*/ -declare function removeLast( str: string, n: number ): string; - - -// EXPORTS // - -export = removeLast; diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index fd426d2..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,57 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 removeLast = require( './index' ); - - -// TESTS // - -// The function returns a string... -{ - removeLast( 'abc', 1 ); // $ExpectType string -} - -// The compiler throws an error if the function is provided a value other than a string... -{ - removeLast( true, 1 ); // $ExpectError - removeLast( false, 1 ); // $ExpectError - removeLast( null, 1 ); // $ExpectError - removeLast( undefined, 1 ); // $ExpectError - removeLast( 5, 1 ); // $ExpectError - removeLast( [], 1 ); // $ExpectError - removeLast( {}, 1 ); // $ExpectError - removeLast( ( x: number ): number => x, 1 ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument that is not a number... -{ - removeLast( 'abc', true ); // $ExpectError - removeLast( 'abc', false ); // $ExpectError - removeLast( 'abc', null ); // $ExpectError - removeLast( 'abc', 'abc' ); // $ExpectError - removeLast( 'abc', [] ); // $ExpectError - removeLast( 'abc', {} ); // $ExpectError - removeLast( 'abc', ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - removeLast(); // $ExpectError - removeLast( 'abc' ); // $ExpectError - removeLast( 'abc', 1, 2 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 085633e..0000000 --- a/examples/index.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var removeLastCodePoint = require( './../lib' ); - -console.log( removeLastCodePoint( 'presidential election', 1 ) ); -// => 'presidential electio' - -console.log( removeLastCodePoint( 'JavaScript', 1 ) ); -// => 'JavaScrip' - -console.log( removeLastCodePoint( 'The Last of the Mohicans', 5 ) ); -// => 'The Last of the Moh' - -console.log( removeLastCodePoint( 'अनुच्छेद', 1 ) ); -// => 'अनुच्छे' diff --git a/index.js b/index.js new file mode 100644 index 0000000..4e500d1 --- /dev/null +++ b/index.js @@ -0,0 +1,3 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +var e,t;e=this,t=function(){"use strict";var e=/[\uDC00-\uDFFF]/,t=/[\uD800-\uDBFF]/;return function(n,f){var i,o,r,u;if(0===f)return n;for(r=0,u=n.length-1;u>=0;u--){if(i=n[u],r+=1,e.test(i)){if(0===u)break;o=n[u-1],t.test(o)&&(u-=1)}if(r===f)break}return n.substring(0,u)}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).removeLastCodePoint=t(); +//# sourceMappingURL=index.js.map diff --git a/index.js.map b/index.js.map new file mode 100644 index 0000000..d557af8 --- /dev/null +++ b/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\nvar RE_UTF16_LOW_SURROGATE = /[\\uDC00-\\uDFFF]/; // TODO: replace with stdlib pkg\nvar RE_UTF16_HIGH_SURROGATE = /[\\uD800-\\uDBFF]/; // TODO: replace with stdlib pkg\n\n\n// MAIN //\n\n/**\n* Removes the last `n` Unicode code points of a string.\n*\n* @param {string} str - input string\n* @param {NonNegativeInteger} n - number of Unicode code points to remove\n* @returns {string} output string\n*\n* @example\n* var out = removeLast( 'last man standing', 1 );\n* // returns 'last man standin'\n*\n* @example\n* var out = removeLast( 'presidential election', 1 );\n* // returns 'presidential electio'\n*\n* @example\n* var out = removeLast( 'JavaScript', 1 );\n* // returns 'JavaScrip'\n*\n* @example\n* var out = removeLast( 'Hidden Treasures', 1 );\n* // returns 'Hidden Treasure'\n*/\nfunction removeLast( str, n ) {\n\tvar len;\n\tvar ch1;\n\tvar ch2;\n\tvar cnt;\n\tvar i;\n\tif ( n === 0 ) {\n\t\treturn str;\n\t}\n\tlen = str.length;\n\tcnt = 0;\n\n\t// Process the string one Unicode code unit at a time and count UTF-16 surrogate pairs as a single Unicode code point...\n\tfor ( i = len - 1; i >= 0; i-- ) {\n\t\tch1 = str[ i ];\n\t\tcnt += 1;\n\n\t\t// Check for a low UTF-16 surrogate...\n\t\tif ( RE_UTF16_LOW_SURROGATE.test( ch1 ) ) {\n\t\t\t// Check for an unpaired surrogate at the end of the input string...\n\t\t\tif ( i === 0 ) {\n\t\t\t\t// We found an unpaired surrogate...\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\t// Check whether the high surrogate is paired with a low surrogate...\n\t\t\tch2 = str[ i-1 ];\n\t\t\tif ( RE_UTF16_HIGH_SURROGATE.test( ch2 ) ) {\n\t\t\t\t// We found a surrogate pair:\n\t\t\t\ti -= 1; // bump the index to process the next code unit\n\t\t\t}\n\t\t}\n\t\t// Check whether we've found the desired number of code points...\n\t\tif ( cnt === n ) {\n\t\t\tbreak;\n\t\t}\n\t}\n\treturn str.substring( 0, i );\n}\n\n\n// EXPORTS //\n\nexport default removeLast;\n"],"names":["RE_UTF16_LOW_SURROGATE","RE_UTF16_HIGH_SURROGATE","str","n","ch1","ch2","cnt","i","length","test","substring"],"mappings":";yCAsBA,IAAIA,EAAyB,kBACzBC,EAA0B,yBA4B9B,SAAqBC,EAAKC,GACzB,IACIC,EACAC,EACAC,EACAC,EACJ,GAAW,IAANJ,EACJ,OAAOD,EAMR,IAHAI,EAAM,EAGAC,EAJAL,EAAIM,OAIM,EAAGD,GAAK,EAAGA,IAAM,CAKhC,GAJAH,EAAMF,EAAKK,GACXD,GAAO,EAGFN,EAAuBS,KAAML,GAAQ,CAEzC,GAAW,IAANG,EAEJ,MAGDF,EAAMH,EAAKK,EAAE,GACRN,EAAwBQ,KAAMJ,KAElCE,GAAK,EAEN,CAED,GAAKD,IAAQH,EACZ,KAED,CACD,OAAOD,EAAIQ,UAAW,EAAGH,EAC1B"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 9860da0..0000000 --- a/lib/index.js +++ /dev/null @@ -1,43 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Remove the last `n` Unicode code points of a string. -* -* @module @stdlib/string-base-remove-last-code-point -* -* @example -* var removeLast = require( '@stdlib/string-base-remove-last-code-point' ); -* -* var out = removeLast( 'last man standing', 1 ); -* // returns 'last man standin' -* -* out = removeLast( 'Hidden Treasures', 1 ); -* // returns 'Hidden Treasure'; -*/ - -// 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 fc34187..0000000 --- a/lib/main.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// VARIABLES // - -var RE_UTF16_LOW_SURROGATE = /[\uDC00-\uDFFF]/; // TODO: replace with stdlib pkg -var RE_UTF16_HIGH_SURROGATE = /[\uD800-\uDBFF]/; // TODO: replace with stdlib pkg - - -// MAIN // - -/** -* Removes the last `n` Unicode code points of a string. -* -* @param {string} str - input string -* @param {NonNegativeInteger} n - number of Unicode code points to remove -* @returns {string} output string -* -* @example -* var out = removeLast( 'last man standing', 1 ); -* // returns 'last man standin' -* -* @example -* var out = removeLast( 'presidential election', 1 ); -* // returns 'presidential electio' -* -* @example -* var out = removeLast( 'JavaScript', 1 ); -* // returns 'JavaScrip' -* -* @example -* var out = removeLast( 'Hidden Treasures', 1 ); -* // returns 'Hidden Treasure' -*/ -function removeLast( str, n ) { - var len; - var ch1; - var ch2; - var cnt; - var i; - if ( n === 0 ) { - return str; - } - len = str.length; - cnt = 0; - - // Process the string one Unicode code unit at a time and count UTF-16 surrogate pairs as a single Unicode code point... - for ( i = len - 1; i >= 0; i-- ) { - ch1 = str[ i ]; - cnt += 1; - - // Check for a low UTF-16 surrogate... - if ( RE_UTF16_LOW_SURROGATE.test( ch1 ) ) { - // Check for an unpaired surrogate at the end of the input string... - if ( i === 0 ) { - // We found an unpaired surrogate... - break; - } - // Check whether the high surrogate is paired with a low surrogate... - ch2 = str[ i-1 ]; - if ( RE_UTF16_HIGH_SURROGATE.test( ch2 ) ) { - // We found a surrogate pair: - i -= 1; // bump the index to process the next code unit - } - } - // Check whether we've found the desired number of code points... - if ( cnt === n ) { - break; - } - } - return str.substring( 0, i ); -} - - -// EXPORTS // - -module.exports = removeLast; diff --git a/package.json b/package.json index 5512b62..10be74f 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,7 @@ "version": "0.2.0", "description": "Remove the last Unicode code point of a string.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "main": "./index.js", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,31 +12,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/error-tools-fmtprodmsg": "^0.1.1" - }, - "devDependencies": { - "@stdlib/assert-is-string": "^0.1.1", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.1.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdstring", @@ -81,4 +32,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/stats_browser.html b/stats_browser.html new file mode 100644 index 0000000..b14280a --- /dev/null +++ b/stats_browser.html @@ -0,0 +1,6177 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/stats_node.html b/stats_node.html new file mode 100644 index 0000000..cdbb5e1 --- /dev/null +++ b/stats_node.html @@ -0,0 +1,6177 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index a25545e..0000000 --- a/test/test.js +++ /dev/null @@ -1,108 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var removeLast = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof removeLast, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns an empty string if provided an empty string', function test( t ) { - t.strictEqual( removeLast( '', 1 ), '', 'returns expected value' ); - t.strictEqual( removeLast( '', 2 ), '', 'returns expected value' ); - t.strictEqual( removeLast( '', 3 ), '', 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns the input string if provided zero as the second argument', function test( t ) { - t.strictEqual( removeLast( 'hello world', 0 ), 'hello world', 'returns expected value' ); - t.end(); -}); - -tape( 'the function removes the last Unicode code point of a provided string (ascii)', function test( t ) { - var out; - - out = removeLast( 'hello world', 1 ); - t.strictEqual( out, 'hello worl', 'returns expected value' ); - - out = removeLast( '!!!', 1 ); - t.strictEqual( out, '!!', 'returns expected value' ); - - out = removeLast( 'Hello World', 1 ); - t.strictEqual( out, 'Hello Worl', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function removes the last Unicode code point of a provided string (Unicode)', function test( t ) { - var out; - - out = removeLast( 'अनुच्छेद', 1 ); - t.strictEqual( out, 'अनुच्छे', 'returns expected value' ); - - out = removeLast( '六书/六書', 1 ); - t.strictEqual( out, '六书/六', 'returns expected value' ); - - out = removeLast( '𐒻𐓟', 1 ); - t.strictEqual( out, '𐒻', 'returns expected value' ); - - out = removeLast( '𐒻𐓟', 1 ); - t.strictEqual( out, '𐒻', 'returns expected value' ); - - out = removeLast( '\uDC00', 1 ); - t.strictEqual( out, '', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports removing the last `n` Unicode code points of a provided string', function test( t ) { - var out; - - out = removeLast( 'hello world', 1 ); - t.strictEqual( out, 'hello worl', 'returns expected value' ); - - out = removeLast( 'hello world', 7 ); - t.strictEqual( out, 'hell', 'returns expected value' ); - - out = removeLast( '!!!', 1 ); - t.strictEqual( out, '!!', 'returns expected value' ); - - out = removeLast( '!!!', 2 ); - t.strictEqual( out, '!', 'returns expected value' ); - - out = removeLast( 'अनुच्छेद', 1 ); - t.strictEqual( out, 'अनुच्छे', 'returns expected value' ); - - out = removeLast( '六书/六書', 3 ); - t.strictEqual( out, '六书', 'returns expected value' ); - - out = removeLast( '𐒻𐓟𐓟', 2 ); - t.strictEqual( out, '𐒻', 'returns expected value' ); - - t.end(); -}); From f67c0785e50d0b4b937fdedec09d592dbedfe1c3 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 14 Feb 2024 03:40:14 +0000 Subject: [PATCH 39/92] Update README.md for UMD bundle v0.2.0 --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index c662d2a..407e6d6 100644 --- a/README.md +++ b/README.md @@ -44,7 +44,7 @@ limitations under the License. To use in Observable, ```javascript -removeLastCodePoint = require( 'https://cdn.jsdelivr.net/gh/stdlib-js/string-base-remove-last-code-point@umd/browser.js' ) +removeLastCodePoint = require( 'https://cdn.jsdelivr.net/gh/stdlib-js/string-base-remove-last-code-point@v0.2.0-umd/browser.js' ) ``` To vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build: @@ -56,7 +56,7 @@ var removeLastCodePoint = require( 'path/to/vendor/umd/string-base-remove-last-c To include the bundle in a webpage, ```html - + ``` If no recognized module system is present, access bundle contents via the global scope: @@ -101,7 +101,7 @@ out = removeLastCodePoint( 'foo bar', 10 ); - + + ``` If no recognized module system is present, access bundle contents via the global scope: @@ -101,7 +106,7 @@ out = removeLastCodePoint( 'foo bar', 10 ); - + - - - - diff --git a/stats_node.html b/stats_node.html deleted file mode 100644 index cdbb5e1..0000000 --- a/stats_node.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 515c41de188f48033c4ee124c395df1f9b1655e0 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 21 Feb 2024 15:20:57 +0000 Subject: [PATCH 43/92] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 797 ---- .github/workflows/publish.yml | 249 -- .github/workflows/test.yml | 100 - .github/workflows/test_bundles.yml | 189 - .github/workflows/test_coverage.yml | 132 - .github/workflows/test_install.yml | 86 - .gitignore | 188 - .npmignore | 228 - .npmrc | 28 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 52 +- SECURITY.md | 5 - benchmark/benchmark.js | 56 - branches.md | 56 - browser.js | 3 + browser.js.map | 1 + dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 29 - docs/types/index.d.ts | 53 - docs/types/test.ts | 57 - examples/index.js | 33 - index.js | 3 + index.js.map | 1 + lib/index.js | 43 - lib/main.js | 94 - package.json | 53 +- stats_browser.html | 4842 +++++++++++++++++++++ stats_node.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 108 - 45 files changed, 9728 insertions(+), 3812 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md create mode 100644 browser.js create mode 100644 browser.js.map 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/index.d.ts delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js create mode 100644 index.js create mode 100644 index.js.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats_browser.html create mode 100644 stats_node.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 52cd9c4..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/base/remove-last-code-point) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 533eeee..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/base/remove-last-code-point) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 2a724f2..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: '29 5 * * 0' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 9106b5d..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,797 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA corresponding to v2.0.0 - uses: act10ns/slack@ed1309ab9862e57e9e583e51c7889486b9a00b0f - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n +``` -```javascript -var removeLastCodePoint = require( '@stdlib/string-base-remove-last-code-point' ); +If no recognized module system is present, access bundle contents via the global scope: + +```html + ``` #### removeLastCodePoint( str, n ) @@ -91,8 +97,13 @@ out = removeLastCodePoint( 'foo bar', 10 ); -```javascript -var removeLastCodePoint = require( '@stdlib/string-base-remove-last-code-point' ); +```html + + + + + + + ```
diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index a39bd29..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,56 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var removeLast = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var values; - var out; - var i; - - values = [ - 'beep boop', - 'foo bar', - 'xyz abc', - '🐶🐮🐷🐰🐸' - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = removeLast( values[ i%values.length ], 1 ); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( !isString( out ) ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index f585c99..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/base/remove-last-code-point" -%% click B href "https://github.com/stdlib-js/string-base-remove-last-code-point/tree/main" -%% click C href "https://github.com/stdlib-js/string-base-remove-last-code-point/tree/production" -%% click D href "https://github.com/stdlib-js/string-base-remove-last-code-point/tree/esm" -%% click E href "https://github.com/stdlib-js/string-base-remove-last-code-point/tree/deno" -%% click F href "https://github.com/stdlib-js/string-base-remove-last-code-point/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/base/remove-last-code-point -[production-url]: https://github.com/stdlib-js/string-base-remove-last-code-point/tree/production -[deno-url]: https://github.com/stdlib-js/string-base-remove-last-code-point/tree/deno -[deno-readme]: https://github.com/stdlib-js/string-base-remove-last-code-point/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/string-base-remove-last-code-point/tree/umd -[umd-readme]: https://github.com/stdlib-js/string-base-remove-last-code-point/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/string-base-remove-last-code-point/tree/esm -[esm-readme]: https://github.com/stdlib-js/string-base-remove-last-code-point/blob/esm/README.md \ No newline at end of file diff --git a/browser.js b/browser.js new file mode 100644 index 0000000..f3a511a --- /dev/null +++ b/browser.js @@ -0,0 +1,3 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +var e,t;e=this,t=function(){"use strict";var e=/[\uDC00-\uDFFF]/,t=/[\uD800-\uDBFF]/;return function(n,f){var i,o,r,u;if(0===f)return n;for(r=0,u=n.length-1;u>=0;u--){if(i=n[u],r+=1,e.test(i)){if(0===u)break;o=n[u-1],t.test(o)&&(u-=1)}if(r===f)break}return n.substring(0,u)}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).removeLastCodePoint=t(); +//# sourceMappingURL=browser.js.map diff --git a/browser.js.map b/browser.js.map new file mode 100644 index 0000000..19908eb --- /dev/null +++ b/browser.js.map @@ -0,0 +1 @@ +{"version":3,"file":"browser.js","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\nvar RE_UTF16_LOW_SURROGATE = /[\\uDC00-\\uDFFF]/; // TODO: replace with stdlib pkg\nvar RE_UTF16_HIGH_SURROGATE = /[\\uD800-\\uDBFF]/; // TODO: replace with stdlib pkg\n\n\n// MAIN //\n\n/**\n* Removes the last `n` Unicode code points of a string.\n*\n* @param {string} str - input string\n* @param {NonNegativeInteger} n - number of Unicode code points to remove\n* @returns {string} output string\n*\n* @example\n* var out = removeLast( 'last man standing', 1 );\n* // returns 'last man standin'\n*\n* @example\n* var out = removeLast( 'presidential election', 1 );\n* // returns 'presidential electio'\n*\n* @example\n* var out = removeLast( 'JavaScript', 1 );\n* // returns 'JavaScrip'\n*\n* @example\n* var out = removeLast( 'Hidden Treasures', 1 );\n* // returns 'Hidden Treasure'\n*/\nfunction removeLast( str, n ) {\n\tvar len;\n\tvar ch1;\n\tvar ch2;\n\tvar cnt;\n\tvar i;\n\tif ( n === 0 ) {\n\t\treturn str;\n\t}\n\tlen = str.length;\n\tcnt = 0;\n\n\t// Process the string one Unicode code unit at a time and count UTF-16 surrogate pairs as a single Unicode code point...\n\tfor ( i = len - 1; i >= 0; i-- ) {\n\t\tch1 = str[ i ];\n\t\tcnt += 1;\n\n\t\t// Check for a low UTF-16 surrogate...\n\t\tif ( RE_UTF16_LOW_SURROGATE.test( ch1 ) ) {\n\t\t\t// Check for an unpaired surrogate at the end of the input string...\n\t\t\tif ( i === 0 ) {\n\t\t\t\t// We found an unpaired surrogate...\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\t// Check whether the high surrogate is paired with a low surrogate...\n\t\t\tch2 = str[ i-1 ];\n\t\t\tif ( RE_UTF16_HIGH_SURROGATE.test( ch2 ) ) {\n\t\t\t\t// We found a surrogate pair:\n\t\t\t\ti -= 1; // bump the index to process the next code unit\n\t\t\t}\n\t\t}\n\t\t// Check whether we've found the desired number of code points...\n\t\tif ( cnt === n ) {\n\t\t\tbreak;\n\t\t}\n\t}\n\treturn str.substring( 0, i );\n}\n\n\n// EXPORTS //\n\nexport default removeLast;\n"],"names":["RE_UTF16_LOW_SURROGATE","RE_UTF16_HIGH_SURROGATE","str","n","ch1","ch2","cnt","i","length","test","substring"],"mappings":";yCAsBA,IAAIA,EAAyB,kBACzBC,EAA0B,yBA4B9B,SAAqBC,EAAKC,GACzB,IACIC,EACAC,EACAC,EACAC,EACJ,GAAW,IAANJ,EACJ,OAAOD,EAMR,IAHAI,EAAM,EAGAC,EAJAL,EAAIM,OAIM,EAAGD,GAAK,EAAGA,IAAM,CAKhC,GAJAH,EAAMF,EAAKK,GACXD,GAAO,EAGFN,EAAuBS,KAAML,GAAQ,CAEzC,GAAW,IAANG,EAEJ,MAGDF,EAAMH,EAAKK,EAAE,GACRN,EAAwBQ,KAAMJ,KAElCE,GAAK,EAEN,CAED,GAAKD,IAAQH,EACZ,KAED,CACD,OAAOD,EAAIQ,UAAW,EAAGH,EAC1B"} \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index 8c96fd7..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import removeLast from '../docs/types/index'; -export = removeLast; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index e6b7220..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var s=function(e,t){return function(){return t||e((t={exports:{}}).exports,t),t.exports}};var f=s(function(D,n){ -var F=/[\uDC00-\uDFFF]/,c=/[\uD800-\uDBFF]/;function R(e,t){var i,u,v,a,r;if(t===0)return e;for(i=e.length,a=0,r=i-1;r>=0;r--){if(u=e[r],a+=1,F.test(u)){if(r===0)break;v=e[r-1],c.test(v)&&(r-=1)}if(a===t)break}return e.substring(0,r)}n.exports=R -});var _=f();module.exports=_; -/** @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 72561cf..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\nvar RE_UTF16_LOW_SURROGATE = /[\\uDC00-\\uDFFF]/; // TODO: replace with stdlib pkg\nvar RE_UTF16_HIGH_SURROGATE = /[\\uD800-\\uDBFF]/; // TODO: replace with stdlib pkg\n\n\n// MAIN //\n\n/**\n* Removes the last `n` Unicode code points of a string.\n*\n* @param {string} str - input string\n* @param {NonNegativeInteger} n - number of Unicode code points to remove\n* @returns {string} output string\n*\n* @example\n* var out = removeLast( 'last man standing', 1 );\n* // returns 'last man standin'\n*\n* @example\n* var out = removeLast( 'presidential election', 1 );\n* // returns 'presidential electio'\n*\n* @example\n* var out = removeLast( 'JavaScript', 1 );\n* // returns 'JavaScrip'\n*\n* @example\n* var out = removeLast( 'Hidden Treasures', 1 );\n* // returns 'Hidden Treasure'\n*/\nfunction removeLast( str, n ) {\n\tvar len;\n\tvar ch1;\n\tvar ch2;\n\tvar cnt;\n\tvar i;\n\tif ( n === 0 ) {\n\t\treturn str;\n\t}\n\tlen = str.length;\n\tcnt = 0;\n\n\t// Process the string one Unicode code unit at a time and count UTF-16 surrogate pairs as a single Unicode code point...\n\tfor ( i = len - 1; i >= 0; i-- ) {\n\t\tch1 = str[ i ];\n\t\tcnt += 1;\n\n\t\t// Check for a low UTF-16 surrogate...\n\t\tif ( RE_UTF16_LOW_SURROGATE.test( ch1 ) ) {\n\t\t\t// Check for an unpaired surrogate at the end of the input string...\n\t\t\tif ( i === 0 ) {\n\t\t\t\t// We found an unpaired surrogate...\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\t// Check whether the high surrogate is paired with a low surrogate...\n\t\t\tch2 = str[ i-1 ];\n\t\t\tif ( RE_UTF16_HIGH_SURROGATE.test( ch2 ) ) {\n\t\t\t\t// We found a surrogate pair:\n\t\t\t\ti -= 1; // bump the index to process the next code unit\n\t\t\t}\n\t\t}\n\t\t// Check whether we've found the desired number of code points...\n\t\tif ( cnt === n ) {\n\t\t\tbreak;\n\t\t}\n\t}\n\treturn str.substring( 0, i );\n}\n\n\n// EXPORTS //\n\nmodule.exports = removeLast;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Remove the last `n` Unicode code points of a string.\n*\n* @module @stdlib/string-base-remove-last-code-point\n*\n* @example\n* var removeLast = require( '@stdlib/string-base-remove-last-code-point' );\n*\n* var out = removeLast( 'last man standing', 1 );\n* // returns 'last man standin'\n*\n* out = removeLast( 'Hidden Treasures', 1 );\n* // returns 'Hidden Treasure';\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,EAAyB,kBACzBC,EAA0B,kBA4B9B,SAASC,EAAYC,EAAKC,EAAI,CAC7B,IAAIC,EACAC,EACAC,EACAC,EACAC,EACJ,GAAKL,IAAM,EACV,OAAOD,EAMR,IAJAE,EAAMF,EAAI,OACVK,EAAM,EAGAC,EAAIJ,EAAM,EAAGI,GAAK,EAAGA,IAAM,CAKhC,GAJAH,EAAMH,EAAKM,CAAE,EACbD,GAAO,EAGFR,EAAuB,KAAMM,CAAI,EAAI,CAEzC,GAAKG,IAAM,EAEV,MAGDF,EAAMJ,EAAKM,EAAE,CAAE,EACVR,EAAwB,KAAMM,CAAI,IAEtCE,GAAK,EAEP,CAEA,GAAKD,IAAQJ,EACZ,KAEF,CACA,OAAOD,EAAI,UAAW,EAAGM,CAAE,CAC5B,CAKAV,EAAO,QAAUG,ICxDjB,IAAIQ,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "RE_UTF16_LOW_SURROGATE", "RE_UTF16_HIGH_SURROGATE", "removeLast", "str", "n", "len", "ch1", "ch2", "cnt", "i", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index a08ea55..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,29 +0,0 @@ - -{{alias}}( str, n ) - Removes the last `n` Unicode code points of a string. - - Parameters - ---------- - str: string - Input string. - - n: integer - Number of Unicode code points to remove. - - Returns - ------- - out: string - Output string. - - Examples - -------- - > var out = {{alias}}( 'beep', 1 ) - 'bee' - > out = {{alias}}( 'Boop', 1 ) - 'Boo' - > out = {{alias}}( 'foo bar', 5 ) - 'fo' - - See Also - -------- - diff --git a/docs/types/index.d.ts b/docs/types/index.d.ts deleted file mode 100644 index 8a1c90b..0000000 --- a/docs/types/index.d.ts +++ /dev/null @@ -1,53 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 - -/** -* Removes the last `n` Unicode code points of a string. -* -* @param str - input string -* @param n - number of code points to remove -* @returns output string -* -* @example -* var out = removeLast( 'last man standing', 1 ); -* // returns 'last man standin' -* -* @example -* var out = removeLast( 'presidential election', 1 ); -* // returns 'presidential electio' -* -* @example -* var out = removeLast( 'JavaScript', 1 ); -* // returns 'JavaScrip' -* -* @example -* var out = removeLast( 'Hidden Treasures', 1 ); -* // returns 'Hidden Treasure' -* -* @example -* var out = removeLast( 'foo bar', 5 ); -* // returns 'fo' -*/ -declare function removeLast( str: string, n: number ): string; - - -// EXPORTS // - -export = removeLast; diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index fd426d2..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,57 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 removeLast = require( './index' ); - - -// TESTS // - -// The function returns a string... -{ - removeLast( 'abc', 1 ); // $ExpectType string -} - -// The compiler throws an error if the function is provided a value other than a string... -{ - removeLast( true, 1 ); // $ExpectError - removeLast( false, 1 ); // $ExpectError - removeLast( null, 1 ); // $ExpectError - removeLast( undefined, 1 ); // $ExpectError - removeLast( 5, 1 ); // $ExpectError - removeLast( [], 1 ); // $ExpectError - removeLast( {}, 1 ); // $ExpectError - removeLast( ( x: number ): number => x, 1 ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument that is not a number... -{ - removeLast( 'abc', true ); // $ExpectError - removeLast( 'abc', false ); // $ExpectError - removeLast( 'abc', null ); // $ExpectError - removeLast( 'abc', 'abc' ); // $ExpectError - removeLast( 'abc', [] ); // $ExpectError - removeLast( 'abc', {} ); // $ExpectError - removeLast( 'abc', ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - removeLast(); // $ExpectError - removeLast( 'abc' ); // $ExpectError - removeLast( 'abc', 1, 2 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 085633e..0000000 --- a/examples/index.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var removeLastCodePoint = require( './../lib' ); - -console.log( removeLastCodePoint( 'presidential election', 1 ) ); -// => 'presidential electio' - -console.log( removeLastCodePoint( 'JavaScript', 1 ) ); -// => 'JavaScrip' - -console.log( removeLastCodePoint( 'The Last of the Mohicans', 5 ) ); -// => 'The Last of the Moh' - -console.log( removeLastCodePoint( 'अनुच्छेद', 1 ) ); -// => 'अनुच्छे' diff --git a/index.js b/index.js new file mode 100644 index 0000000..4e500d1 --- /dev/null +++ b/index.js @@ -0,0 +1,3 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +var e,t;e=this,t=function(){"use strict";var e=/[\uDC00-\uDFFF]/,t=/[\uD800-\uDBFF]/;return function(n,f){var i,o,r,u;if(0===f)return n;for(r=0,u=n.length-1;u>=0;u--){if(i=n[u],r+=1,e.test(i)){if(0===u)break;o=n[u-1],t.test(o)&&(u-=1)}if(r===f)break}return n.substring(0,u)}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).removeLastCodePoint=t(); +//# sourceMappingURL=index.js.map diff --git a/index.js.map b/index.js.map new file mode 100644 index 0000000..d557af8 --- /dev/null +++ b/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\nvar RE_UTF16_LOW_SURROGATE = /[\\uDC00-\\uDFFF]/; // TODO: replace with stdlib pkg\nvar RE_UTF16_HIGH_SURROGATE = /[\\uD800-\\uDBFF]/; // TODO: replace with stdlib pkg\n\n\n// MAIN //\n\n/**\n* Removes the last `n` Unicode code points of a string.\n*\n* @param {string} str - input string\n* @param {NonNegativeInteger} n - number of Unicode code points to remove\n* @returns {string} output string\n*\n* @example\n* var out = removeLast( 'last man standing', 1 );\n* // returns 'last man standin'\n*\n* @example\n* var out = removeLast( 'presidential election', 1 );\n* // returns 'presidential electio'\n*\n* @example\n* var out = removeLast( 'JavaScript', 1 );\n* // returns 'JavaScrip'\n*\n* @example\n* var out = removeLast( 'Hidden Treasures', 1 );\n* // returns 'Hidden Treasure'\n*/\nfunction removeLast( str, n ) {\n\tvar len;\n\tvar ch1;\n\tvar ch2;\n\tvar cnt;\n\tvar i;\n\tif ( n === 0 ) {\n\t\treturn str;\n\t}\n\tlen = str.length;\n\tcnt = 0;\n\n\t// Process the string one Unicode code unit at a time and count UTF-16 surrogate pairs as a single Unicode code point...\n\tfor ( i = len - 1; i >= 0; i-- ) {\n\t\tch1 = str[ i ];\n\t\tcnt += 1;\n\n\t\t// Check for a low UTF-16 surrogate...\n\t\tif ( RE_UTF16_LOW_SURROGATE.test( ch1 ) ) {\n\t\t\t// Check for an unpaired surrogate at the end of the input string...\n\t\t\tif ( i === 0 ) {\n\t\t\t\t// We found an unpaired surrogate...\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\t// Check whether the high surrogate is paired with a low surrogate...\n\t\t\tch2 = str[ i-1 ];\n\t\t\tif ( RE_UTF16_HIGH_SURROGATE.test( ch2 ) ) {\n\t\t\t\t// We found a surrogate pair:\n\t\t\t\ti -= 1; // bump the index to process the next code unit\n\t\t\t}\n\t\t}\n\t\t// Check whether we've found the desired number of code points...\n\t\tif ( cnt === n ) {\n\t\t\tbreak;\n\t\t}\n\t}\n\treturn str.substring( 0, i );\n}\n\n\n// EXPORTS //\n\nexport default removeLast;\n"],"names":["RE_UTF16_LOW_SURROGATE","RE_UTF16_HIGH_SURROGATE","str","n","ch1","ch2","cnt","i","length","test","substring"],"mappings":";yCAsBA,IAAIA,EAAyB,kBACzBC,EAA0B,yBA4B9B,SAAqBC,EAAKC,GACzB,IACIC,EACAC,EACAC,EACAC,EACJ,GAAW,IAANJ,EACJ,OAAOD,EAMR,IAHAI,EAAM,EAGAC,EAJAL,EAAIM,OAIM,EAAGD,GAAK,EAAGA,IAAM,CAKhC,GAJAH,EAAMF,EAAKK,GACXD,GAAO,EAGFN,EAAuBS,KAAML,GAAQ,CAEzC,GAAW,IAANG,EAEJ,MAGDF,EAAMH,EAAKK,EAAE,GACRN,EAAwBQ,KAAMJ,KAElCE,GAAK,EAEN,CAED,GAAKD,IAAQH,EACZ,KAED,CACD,OAAOD,EAAIQ,UAAW,EAAGH,EAC1B"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 9860da0..0000000 --- a/lib/index.js +++ /dev/null @@ -1,43 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Remove the last `n` Unicode code points of a string. -* -* @module @stdlib/string-base-remove-last-code-point -* -* @example -* var removeLast = require( '@stdlib/string-base-remove-last-code-point' ); -* -* var out = removeLast( 'last man standing', 1 ); -* // returns 'last man standin' -* -* out = removeLast( 'Hidden Treasures', 1 ); -* // returns 'Hidden Treasure'; -*/ - -// 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 fc34187..0000000 --- a/lib/main.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// VARIABLES // - -var RE_UTF16_LOW_SURROGATE = /[\uDC00-\uDFFF]/; // TODO: replace with stdlib pkg -var RE_UTF16_HIGH_SURROGATE = /[\uD800-\uDBFF]/; // TODO: replace with stdlib pkg - - -// MAIN // - -/** -* Removes the last `n` Unicode code points of a string. -* -* @param {string} str - input string -* @param {NonNegativeInteger} n - number of Unicode code points to remove -* @returns {string} output string -* -* @example -* var out = removeLast( 'last man standing', 1 ); -* // returns 'last man standin' -* -* @example -* var out = removeLast( 'presidential election', 1 ); -* // returns 'presidential electio' -* -* @example -* var out = removeLast( 'JavaScript', 1 ); -* // returns 'JavaScrip' -* -* @example -* var out = removeLast( 'Hidden Treasures', 1 ); -* // returns 'Hidden Treasure' -*/ -function removeLast( str, n ) { - var len; - var ch1; - var ch2; - var cnt; - var i; - if ( n === 0 ) { - return str; - } - len = str.length; - cnt = 0; - - // Process the string one Unicode code unit at a time and count UTF-16 surrogate pairs as a single Unicode code point... - for ( i = len - 1; i >= 0; i-- ) { - ch1 = str[ i ]; - cnt += 1; - - // Check for a low UTF-16 surrogate... - if ( RE_UTF16_LOW_SURROGATE.test( ch1 ) ) { - // Check for an unpaired surrogate at the end of the input string... - if ( i === 0 ) { - // We found an unpaired surrogate... - break; - } - // Check whether the high surrogate is paired with a low surrogate... - ch2 = str[ i-1 ]; - if ( RE_UTF16_HIGH_SURROGATE.test( ch2 ) ) { - // We found a surrogate pair: - i -= 1; // bump the index to process the next code unit - } - } - // Check whether we've found the desired number of code points... - if ( cnt === n ) { - break; - } - } - return str.substring( 0, i ); -} - - -// EXPORTS // - -module.exports = removeLast; diff --git a/package.json b/package.json index d86b261..f3c9a46 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,7 @@ "version": "0.2.1", "description": "Remove the last Unicode code point of a string.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "main": "./index.js", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,31 +12,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/error-tools-fmtprodmsg": "^0.2.0" - }, - "devDependencies": { - "@stdlib/assert-is-string": "^0.2.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.0" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdstring", @@ -81,4 +32,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/stats_browser.html b/stats_browser.html new file mode 100644 index 0000000..2c17dcc --- /dev/null +++ b/stats_browser.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/stats_node.html b/stats_node.html new file mode 100644 index 0000000..1e086d4 --- /dev/null +++ b/stats_node.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index a25545e..0000000 --- a/test/test.js +++ /dev/null @@ -1,108 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var removeLast = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof removeLast, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns an empty string if provided an empty string', function test( t ) { - t.strictEqual( removeLast( '', 1 ), '', 'returns expected value' ); - t.strictEqual( removeLast( '', 2 ), '', 'returns expected value' ); - t.strictEqual( removeLast( '', 3 ), '', 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns the input string if provided zero as the second argument', function test( t ) { - t.strictEqual( removeLast( 'hello world', 0 ), 'hello world', 'returns expected value' ); - t.end(); -}); - -tape( 'the function removes the last Unicode code point of a provided string (ascii)', function test( t ) { - var out; - - out = removeLast( 'hello world', 1 ); - t.strictEqual( out, 'hello worl', 'returns expected value' ); - - out = removeLast( '!!!', 1 ); - t.strictEqual( out, '!!', 'returns expected value' ); - - out = removeLast( 'Hello World', 1 ); - t.strictEqual( out, 'Hello Worl', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function removes the last Unicode code point of a provided string (Unicode)', function test( t ) { - var out; - - out = removeLast( 'अनुच्छेद', 1 ); - t.strictEqual( out, 'अनुच्छे', 'returns expected value' ); - - out = removeLast( '六书/六書', 1 ); - t.strictEqual( out, '六书/六', 'returns expected value' ); - - out = removeLast( '𐒻𐓟', 1 ); - t.strictEqual( out, '𐒻', 'returns expected value' ); - - out = removeLast( '𐒻𐓟', 1 ); - t.strictEqual( out, '𐒻', 'returns expected value' ); - - out = removeLast( '\uDC00', 1 ); - t.strictEqual( out, '', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports removing the last `n` Unicode code points of a provided string', function test( t ) { - var out; - - out = removeLast( 'hello world', 1 ); - t.strictEqual( out, 'hello worl', 'returns expected value' ); - - out = removeLast( 'hello world', 7 ); - t.strictEqual( out, 'hell', 'returns expected value' ); - - out = removeLast( '!!!', 1 ); - t.strictEqual( out, '!!', 'returns expected value' ); - - out = removeLast( '!!!', 2 ); - t.strictEqual( out, '!', 'returns expected value' ); - - out = removeLast( 'अनुच्छेद', 1 ); - t.strictEqual( out, 'अनुच्छे', 'returns expected value' ); - - out = removeLast( '六书/六書', 3 ); - t.strictEqual( out, '六书', 'returns expected value' ); - - out = removeLast( '𐒻𐓟𐓟', 2 ); - t.strictEqual( out, '𐒻', 'returns expected value' ); - - t.end(); -}); From 7ac0ee7ea21d7debe0416f55d3e0ac0d489a31ac Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 21 Feb 2024 15:22:16 +0000 Subject: [PATCH 44/92] Update README.md for UMD bundle v0.2.1 --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 62b5ed7..b837b76 100644 --- a/README.md +++ b/README.md @@ -44,7 +44,7 @@ limitations under the License. To use in Observable, ```javascript -removeLastCodePoint = require( 'https://cdn.jsdelivr.net/gh/stdlib-js/string-base-remove-last-code-point@umd/browser.js' ) +removeLastCodePoint = require( 'https://cdn.jsdelivr.net/gh/stdlib-js/string-base-remove-last-code-point@v0.2.1-umd/browser.js' ) ``` To vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build: @@ -56,7 +56,7 @@ var removeLastCodePoint = require( 'path/to/vendor/umd/string-base-remove-last-c To include the bundle in a webpage, ```html - + ``` If no recognized module system is present, access bundle contents via the global scope: @@ -101,7 +101,7 @@ out = removeLastCodePoint( 'foo bar', 10 ); - + + ``` If no recognized module system is present, access bundle contents via the global scope: @@ -101,7 +106,7 @@ out = removeLastCodePoint( 'foo bar', 10 ); - + - - - - diff --git a/stats_node.html b/stats_node.html deleted file mode 100644 index 1e086d4..0000000 --- a/stats_node.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 63cfac59d90f5c046c1000ef3e34a434e5878a84 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Mar 2024 00:34:07 +0000 Subject: [PATCH 48/92] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 797 ---- .github/workflows/publish.yml | 249 -- .github/workflows/test.yml | 100 - .github/workflows/test_bundles.yml | 189 - .github/workflows/test_coverage.yml | 132 - .github/workflows/test_install.yml | 86 - .gitignore | 188 - .npmignore | 229 - .npmrc | 28 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 52 +- SECURITY.md | 5 - benchmark/benchmark.js | 56 - branches.md | 56 - browser.js | 3 + browser.js.map | 1 + dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 29 - docs/types/index.d.ts | 53 - docs/types/test.ts | 57 - examples/index.js | 33 - index.js | 3 + index.js.map | 1 + lib/index.js | 43 - lib/main.js | 94 - package.json | 53 +- stats_browser.html | 4842 +++++++++++++++++++++ stats_node.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 108 - 46 files changed, 9728 insertions(+), 3814 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md create mode 100644 browser.js create mode 100644 browser.js.map 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/index.d.ts delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js create mode 100644 index.js create mode 100644 index.js.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats_browser.html create mode 100644 stats_node.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 8dbfe00..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-03-01T00:31:33.860Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 52cd9c4..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/base/remove-last-code-point) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 533eeee..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/base/remove-last-code-point) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 2a724f2..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: '29 5 * * 0' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 9106b5d..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,797 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA corresponding to v2.0.0 - uses: act10ns/slack@ed1309ab9862e57e9e583e51c7889486b9a00b0f - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n +``` -```javascript -var removeLastCodePoint = require( '@stdlib/string-base-remove-last-code-point' ); +If no recognized module system is present, access bundle contents via the global scope: + +```html + ``` #### removeLastCodePoint( str, n ) @@ -91,8 +97,13 @@ out = removeLastCodePoint( 'foo bar', 10 ); -```javascript -var removeLastCodePoint = require( '@stdlib/string-base-remove-last-code-point' ); +```html + + + + + + + ```
diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index a39bd29..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,56 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var removeLast = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var values; - var out; - var i; - - values = [ - 'beep boop', - 'foo bar', - 'xyz abc', - '🐶🐮🐷🐰🐸' - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = removeLast( values[ i%values.length ], 1 ); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( !isString( out ) ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index f585c99..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/base/remove-last-code-point" -%% click B href "https://github.com/stdlib-js/string-base-remove-last-code-point/tree/main" -%% click C href "https://github.com/stdlib-js/string-base-remove-last-code-point/tree/production" -%% click D href "https://github.com/stdlib-js/string-base-remove-last-code-point/tree/esm" -%% click E href "https://github.com/stdlib-js/string-base-remove-last-code-point/tree/deno" -%% click F href "https://github.com/stdlib-js/string-base-remove-last-code-point/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/base/remove-last-code-point -[production-url]: https://github.com/stdlib-js/string-base-remove-last-code-point/tree/production -[deno-url]: https://github.com/stdlib-js/string-base-remove-last-code-point/tree/deno -[deno-readme]: https://github.com/stdlib-js/string-base-remove-last-code-point/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/string-base-remove-last-code-point/tree/umd -[umd-readme]: https://github.com/stdlib-js/string-base-remove-last-code-point/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/string-base-remove-last-code-point/tree/esm -[esm-readme]: https://github.com/stdlib-js/string-base-remove-last-code-point/blob/esm/README.md \ No newline at end of file diff --git a/browser.js b/browser.js new file mode 100644 index 0000000..f3a511a --- /dev/null +++ b/browser.js @@ -0,0 +1,3 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +var e,t;e=this,t=function(){"use strict";var e=/[\uDC00-\uDFFF]/,t=/[\uD800-\uDBFF]/;return function(n,f){var i,o,r,u;if(0===f)return n;for(r=0,u=n.length-1;u>=0;u--){if(i=n[u],r+=1,e.test(i)){if(0===u)break;o=n[u-1],t.test(o)&&(u-=1)}if(r===f)break}return n.substring(0,u)}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).removeLastCodePoint=t(); +//# sourceMappingURL=browser.js.map diff --git a/browser.js.map b/browser.js.map new file mode 100644 index 0000000..19908eb --- /dev/null +++ b/browser.js.map @@ -0,0 +1 @@ +{"version":3,"file":"browser.js","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\nvar RE_UTF16_LOW_SURROGATE = /[\\uDC00-\\uDFFF]/; // TODO: replace with stdlib pkg\nvar RE_UTF16_HIGH_SURROGATE = /[\\uD800-\\uDBFF]/; // TODO: replace with stdlib pkg\n\n\n// MAIN //\n\n/**\n* Removes the last `n` Unicode code points of a string.\n*\n* @param {string} str - input string\n* @param {NonNegativeInteger} n - number of Unicode code points to remove\n* @returns {string} output string\n*\n* @example\n* var out = removeLast( 'last man standing', 1 );\n* // returns 'last man standin'\n*\n* @example\n* var out = removeLast( 'presidential election', 1 );\n* // returns 'presidential electio'\n*\n* @example\n* var out = removeLast( 'JavaScript', 1 );\n* // returns 'JavaScrip'\n*\n* @example\n* var out = removeLast( 'Hidden Treasures', 1 );\n* // returns 'Hidden Treasure'\n*/\nfunction removeLast( str, n ) {\n\tvar len;\n\tvar ch1;\n\tvar ch2;\n\tvar cnt;\n\tvar i;\n\tif ( n === 0 ) {\n\t\treturn str;\n\t}\n\tlen = str.length;\n\tcnt = 0;\n\n\t// Process the string one Unicode code unit at a time and count UTF-16 surrogate pairs as a single Unicode code point...\n\tfor ( i = len - 1; i >= 0; i-- ) {\n\t\tch1 = str[ i ];\n\t\tcnt += 1;\n\n\t\t// Check for a low UTF-16 surrogate...\n\t\tif ( RE_UTF16_LOW_SURROGATE.test( ch1 ) ) {\n\t\t\t// Check for an unpaired surrogate at the end of the input string...\n\t\t\tif ( i === 0 ) {\n\t\t\t\t// We found an unpaired surrogate...\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\t// Check whether the high surrogate is paired with a low surrogate...\n\t\t\tch2 = str[ i-1 ];\n\t\t\tif ( RE_UTF16_HIGH_SURROGATE.test( ch2 ) ) {\n\t\t\t\t// We found a surrogate pair:\n\t\t\t\ti -= 1; // bump the index to process the next code unit\n\t\t\t}\n\t\t}\n\t\t// Check whether we've found the desired number of code points...\n\t\tif ( cnt === n ) {\n\t\t\tbreak;\n\t\t}\n\t}\n\treturn str.substring( 0, i );\n}\n\n\n// EXPORTS //\n\nexport default removeLast;\n"],"names":["RE_UTF16_LOW_SURROGATE","RE_UTF16_HIGH_SURROGATE","str","n","ch1","ch2","cnt","i","length","test","substring"],"mappings":";yCAsBA,IAAIA,EAAyB,kBACzBC,EAA0B,yBA4B9B,SAAqBC,EAAKC,GACzB,IACIC,EACAC,EACAC,EACAC,EACJ,GAAW,IAANJ,EACJ,OAAOD,EAMR,IAHAI,EAAM,EAGAC,EAJAL,EAAIM,OAIM,EAAGD,GAAK,EAAGA,IAAM,CAKhC,GAJAH,EAAMF,EAAKK,GACXD,GAAO,EAGFN,EAAuBS,KAAML,GAAQ,CAEzC,GAAW,IAANG,EAEJ,MAGDF,EAAMH,EAAKK,EAAE,GACRN,EAAwBQ,KAAMJ,KAElCE,GAAK,EAEN,CAED,GAAKD,IAAQH,EACZ,KAED,CACD,OAAOD,EAAIQ,UAAW,EAAGH,EAC1B"} \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index 8c96fd7..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import removeLast from '../docs/types/index'; -export = removeLast; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index e6b7220..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var s=function(e,t){return function(){return t||e((t={exports:{}}).exports,t),t.exports}};var f=s(function(D,n){ -var F=/[\uDC00-\uDFFF]/,c=/[\uD800-\uDBFF]/;function R(e,t){var i,u,v,a,r;if(t===0)return e;for(i=e.length,a=0,r=i-1;r>=0;r--){if(u=e[r],a+=1,F.test(u)){if(r===0)break;v=e[r-1],c.test(v)&&(r-=1)}if(a===t)break}return e.substring(0,r)}n.exports=R -});var _=f();module.exports=_; -/** @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 72561cf..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\nvar RE_UTF16_LOW_SURROGATE = /[\\uDC00-\\uDFFF]/; // TODO: replace with stdlib pkg\nvar RE_UTF16_HIGH_SURROGATE = /[\\uD800-\\uDBFF]/; // TODO: replace with stdlib pkg\n\n\n// MAIN //\n\n/**\n* Removes the last `n` Unicode code points of a string.\n*\n* @param {string} str - input string\n* @param {NonNegativeInteger} n - number of Unicode code points to remove\n* @returns {string} output string\n*\n* @example\n* var out = removeLast( 'last man standing', 1 );\n* // returns 'last man standin'\n*\n* @example\n* var out = removeLast( 'presidential election', 1 );\n* // returns 'presidential electio'\n*\n* @example\n* var out = removeLast( 'JavaScript', 1 );\n* // returns 'JavaScrip'\n*\n* @example\n* var out = removeLast( 'Hidden Treasures', 1 );\n* // returns 'Hidden Treasure'\n*/\nfunction removeLast( str, n ) {\n\tvar len;\n\tvar ch1;\n\tvar ch2;\n\tvar cnt;\n\tvar i;\n\tif ( n === 0 ) {\n\t\treturn str;\n\t}\n\tlen = str.length;\n\tcnt = 0;\n\n\t// Process the string one Unicode code unit at a time and count UTF-16 surrogate pairs as a single Unicode code point...\n\tfor ( i = len - 1; i >= 0; i-- ) {\n\t\tch1 = str[ i ];\n\t\tcnt += 1;\n\n\t\t// Check for a low UTF-16 surrogate...\n\t\tif ( RE_UTF16_LOW_SURROGATE.test( ch1 ) ) {\n\t\t\t// Check for an unpaired surrogate at the end of the input string...\n\t\t\tif ( i === 0 ) {\n\t\t\t\t// We found an unpaired surrogate...\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\t// Check whether the high surrogate is paired with a low surrogate...\n\t\t\tch2 = str[ i-1 ];\n\t\t\tif ( RE_UTF16_HIGH_SURROGATE.test( ch2 ) ) {\n\t\t\t\t// We found a surrogate pair:\n\t\t\t\ti -= 1; // bump the index to process the next code unit\n\t\t\t}\n\t\t}\n\t\t// Check whether we've found the desired number of code points...\n\t\tif ( cnt === n ) {\n\t\t\tbreak;\n\t\t}\n\t}\n\treturn str.substring( 0, i );\n}\n\n\n// EXPORTS //\n\nmodule.exports = removeLast;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Remove the last `n` Unicode code points of a string.\n*\n* @module @stdlib/string-base-remove-last-code-point\n*\n* @example\n* var removeLast = require( '@stdlib/string-base-remove-last-code-point' );\n*\n* var out = removeLast( 'last man standing', 1 );\n* // returns 'last man standin'\n*\n* out = removeLast( 'Hidden Treasures', 1 );\n* // returns 'Hidden Treasure';\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,EAAyB,kBACzBC,EAA0B,kBA4B9B,SAASC,EAAYC,EAAKC,EAAI,CAC7B,IAAIC,EACAC,EACAC,EACAC,EACAC,EACJ,GAAKL,IAAM,EACV,OAAOD,EAMR,IAJAE,EAAMF,EAAI,OACVK,EAAM,EAGAC,EAAIJ,EAAM,EAAGI,GAAK,EAAGA,IAAM,CAKhC,GAJAH,EAAMH,EAAKM,CAAE,EACbD,GAAO,EAGFR,EAAuB,KAAMM,CAAI,EAAI,CAEzC,GAAKG,IAAM,EAEV,MAGDF,EAAMJ,EAAKM,EAAE,CAAE,EACVR,EAAwB,KAAMM,CAAI,IAEtCE,GAAK,EAEP,CAEA,GAAKD,IAAQJ,EACZ,KAEF,CACA,OAAOD,EAAI,UAAW,EAAGM,CAAE,CAC5B,CAKAV,EAAO,QAAUG,ICxDjB,IAAIQ,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "RE_UTF16_LOW_SURROGATE", "RE_UTF16_HIGH_SURROGATE", "removeLast", "str", "n", "len", "ch1", "ch2", "cnt", "i", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index a08ea55..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,29 +0,0 @@ - -{{alias}}( str, n ) - Removes the last `n` Unicode code points of a string. - - Parameters - ---------- - str: string - Input string. - - n: integer - Number of Unicode code points to remove. - - Returns - ------- - out: string - Output string. - - Examples - -------- - > var out = {{alias}}( 'beep', 1 ) - 'bee' - > out = {{alias}}( 'Boop', 1 ) - 'Boo' - > out = {{alias}}( 'foo bar', 5 ) - 'fo' - - See Also - -------- - diff --git a/docs/types/index.d.ts b/docs/types/index.d.ts deleted file mode 100644 index 8a1c90b..0000000 --- a/docs/types/index.d.ts +++ /dev/null @@ -1,53 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 - -/** -* Removes the last `n` Unicode code points of a string. -* -* @param str - input string -* @param n - number of code points to remove -* @returns output string -* -* @example -* var out = removeLast( 'last man standing', 1 ); -* // returns 'last man standin' -* -* @example -* var out = removeLast( 'presidential election', 1 ); -* // returns 'presidential electio' -* -* @example -* var out = removeLast( 'JavaScript', 1 ); -* // returns 'JavaScrip' -* -* @example -* var out = removeLast( 'Hidden Treasures', 1 ); -* // returns 'Hidden Treasure' -* -* @example -* var out = removeLast( 'foo bar', 5 ); -* // returns 'fo' -*/ -declare function removeLast( str: string, n: number ): string; - - -// EXPORTS // - -export = removeLast; diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index fd426d2..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,57 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 removeLast = require( './index' ); - - -// TESTS // - -// The function returns a string... -{ - removeLast( 'abc', 1 ); // $ExpectType string -} - -// The compiler throws an error if the function is provided a value other than a string... -{ - removeLast( true, 1 ); // $ExpectError - removeLast( false, 1 ); // $ExpectError - removeLast( null, 1 ); // $ExpectError - removeLast( undefined, 1 ); // $ExpectError - removeLast( 5, 1 ); // $ExpectError - removeLast( [], 1 ); // $ExpectError - removeLast( {}, 1 ); // $ExpectError - removeLast( ( x: number ): number => x, 1 ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument that is not a number... -{ - removeLast( 'abc', true ); // $ExpectError - removeLast( 'abc', false ); // $ExpectError - removeLast( 'abc', null ); // $ExpectError - removeLast( 'abc', 'abc' ); // $ExpectError - removeLast( 'abc', [] ); // $ExpectError - removeLast( 'abc', {} ); // $ExpectError - removeLast( 'abc', ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - removeLast(); // $ExpectError - removeLast( 'abc' ); // $ExpectError - removeLast( 'abc', 1, 2 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 085633e..0000000 --- a/examples/index.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var removeLastCodePoint = require( './../lib' ); - -console.log( removeLastCodePoint( 'presidential election', 1 ) ); -// => 'presidential electio' - -console.log( removeLastCodePoint( 'JavaScript', 1 ) ); -// => 'JavaScrip' - -console.log( removeLastCodePoint( 'The Last of the Mohicans', 5 ) ); -// => 'The Last of the Moh' - -console.log( removeLastCodePoint( 'अनुच्छेद', 1 ) ); -// => 'अनुच्छे' diff --git a/index.js b/index.js new file mode 100644 index 0000000..4e500d1 --- /dev/null +++ b/index.js @@ -0,0 +1,3 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +var e,t;e=this,t=function(){"use strict";var e=/[\uDC00-\uDFFF]/,t=/[\uD800-\uDBFF]/;return function(n,f){var i,o,r,u;if(0===f)return n;for(r=0,u=n.length-1;u>=0;u--){if(i=n[u],r+=1,e.test(i)){if(0===u)break;o=n[u-1],t.test(o)&&(u-=1)}if(r===f)break}return n.substring(0,u)}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).removeLastCodePoint=t(); +//# sourceMappingURL=index.js.map diff --git a/index.js.map b/index.js.map new file mode 100644 index 0000000..d557af8 --- /dev/null +++ b/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\nvar RE_UTF16_LOW_SURROGATE = /[\\uDC00-\\uDFFF]/; // TODO: replace with stdlib pkg\nvar RE_UTF16_HIGH_SURROGATE = /[\\uD800-\\uDBFF]/; // TODO: replace with stdlib pkg\n\n\n// MAIN //\n\n/**\n* Removes the last `n` Unicode code points of a string.\n*\n* @param {string} str - input string\n* @param {NonNegativeInteger} n - number of Unicode code points to remove\n* @returns {string} output string\n*\n* @example\n* var out = removeLast( 'last man standing', 1 );\n* // returns 'last man standin'\n*\n* @example\n* var out = removeLast( 'presidential election', 1 );\n* // returns 'presidential electio'\n*\n* @example\n* var out = removeLast( 'JavaScript', 1 );\n* // returns 'JavaScrip'\n*\n* @example\n* var out = removeLast( 'Hidden Treasures', 1 );\n* // returns 'Hidden Treasure'\n*/\nfunction removeLast( str, n ) {\n\tvar len;\n\tvar ch1;\n\tvar ch2;\n\tvar cnt;\n\tvar i;\n\tif ( n === 0 ) {\n\t\treturn str;\n\t}\n\tlen = str.length;\n\tcnt = 0;\n\n\t// Process the string one Unicode code unit at a time and count UTF-16 surrogate pairs as a single Unicode code point...\n\tfor ( i = len - 1; i >= 0; i-- ) {\n\t\tch1 = str[ i ];\n\t\tcnt += 1;\n\n\t\t// Check for a low UTF-16 surrogate...\n\t\tif ( RE_UTF16_LOW_SURROGATE.test( ch1 ) ) {\n\t\t\t// Check for an unpaired surrogate at the end of the input string...\n\t\t\tif ( i === 0 ) {\n\t\t\t\t// We found an unpaired surrogate...\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\t// Check whether the high surrogate is paired with a low surrogate...\n\t\t\tch2 = str[ i-1 ];\n\t\t\tif ( RE_UTF16_HIGH_SURROGATE.test( ch2 ) ) {\n\t\t\t\t// We found a surrogate pair:\n\t\t\t\ti -= 1; // bump the index to process the next code unit\n\t\t\t}\n\t\t}\n\t\t// Check whether we've found the desired number of code points...\n\t\tif ( cnt === n ) {\n\t\t\tbreak;\n\t\t}\n\t}\n\treturn str.substring( 0, i );\n}\n\n\n// EXPORTS //\n\nexport default removeLast;\n"],"names":["RE_UTF16_LOW_SURROGATE","RE_UTF16_HIGH_SURROGATE","str","n","ch1","ch2","cnt","i","length","test","substring"],"mappings":";yCAsBA,IAAIA,EAAyB,kBACzBC,EAA0B,yBA4B9B,SAAqBC,EAAKC,GACzB,IACIC,EACAC,EACAC,EACAC,EACJ,GAAW,IAANJ,EACJ,OAAOD,EAMR,IAHAI,EAAM,EAGAC,EAJAL,EAAIM,OAIM,EAAGD,GAAK,EAAGA,IAAM,CAKhC,GAJAH,EAAMF,EAAKK,GACXD,GAAO,EAGFN,EAAuBS,KAAML,GAAQ,CAEzC,GAAW,IAANG,EAEJ,MAGDF,EAAMH,EAAKK,EAAE,GACRN,EAAwBQ,KAAMJ,KAElCE,GAAK,EAEN,CAED,GAAKD,IAAQH,EACZ,KAED,CACD,OAAOD,EAAIQ,UAAW,EAAGH,EAC1B"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 9860da0..0000000 --- a/lib/index.js +++ /dev/null @@ -1,43 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Remove the last `n` Unicode code points of a string. -* -* @module @stdlib/string-base-remove-last-code-point -* -* @example -* var removeLast = require( '@stdlib/string-base-remove-last-code-point' ); -* -* var out = removeLast( 'last man standing', 1 ); -* // returns 'last man standin' -* -* out = removeLast( 'Hidden Treasures', 1 ); -* // returns 'Hidden Treasure'; -*/ - -// 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 fc34187..0000000 --- a/lib/main.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// VARIABLES // - -var RE_UTF16_LOW_SURROGATE = /[\uDC00-\uDFFF]/; // TODO: replace with stdlib pkg -var RE_UTF16_HIGH_SURROGATE = /[\uD800-\uDBFF]/; // TODO: replace with stdlib pkg - - -// MAIN // - -/** -* Removes the last `n` Unicode code points of a string. -* -* @param {string} str - input string -* @param {NonNegativeInteger} n - number of Unicode code points to remove -* @returns {string} output string -* -* @example -* var out = removeLast( 'last man standing', 1 ); -* // returns 'last man standin' -* -* @example -* var out = removeLast( 'presidential election', 1 ); -* // returns 'presidential electio' -* -* @example -* var out = removeLast( 'JavaScript', 1 ); -* // returns 'JavaScrip' -* -* @example -* var out = removeLast( 'Hidden Treasures', 1 ); -* // returns 'Hidden Treasure' -*/ -function removeLast( str, n ) { - var len; - var ch1; - var ch2; - var cnt; - var i; - if ( n === 0 ) { - return str; - } - len = str.length; - cnt = 0; - - // Process the string one Unicode code unit at a time and count UTF-16 surrogate pairs as a single Unicode code point... - for ( i = len - 1; i >= 0; i-- ) { - ch1 = str[ i ]; - cnt += 1; - - // Check for a low UTF-16 surrogate... - if ( RE_UTF16_LOW_SURROGATE.test( ch1 ) ) { - // Check for an unpaired surrogate at the end of the input string... - if ( i === 0 ) { - // We found an unpaired surrogate... - break; - } - // Check whether the high surrogate is paired with a low surrogate... - ch2 = str[ i-1 ]; - if ( RE_UTF16_HIGH_SURROGATE.test( ch2 ) ) { - // We found a surrogate pair: - i -= 1; // bump the index to process the next code unit - } - } - // Check whether we've found the desired number of code points... - if ( cnt === n ) { - break; - } - } - return str.substring( 0, i ); -} - - -// EXPORTS // - -module.exports = removeLast; diff --git a/package.json b/package.json index 7d6f49d..f3c9a46 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,7 @@ "version": "0.2.1", "description": "Remove the last Unicode code point of a string.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "main": "./index.js", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,31 +12,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/error-tools-fmtprodmsg": "^0.2.1" - }, - "devDependencies": { - "@stdlib/assert-is-string": "^0.2.1", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.1" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdstring", @@ -81,4 +32,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/stats_browser.html b/stats_browser.html new file mode 100644 index 0000000..2c17dcc --- /dev/null +++ b/stats_browser.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/stats_node.html b/stats_node.html new file mode 100644 index 0000000..1e086d4 --- /dev/null +++ b/stats_node.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index a25545e..0000000 --- a/test/test.js +++ /dev/null @@ -1,108 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var removeLast = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof removeLast, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns an empty string if provided an empty string', function test( t ) { - t.strictEqual( removeLast( '', 1 ), '', 'returns expected value' ); - t.strictEqual( removeLast( '', 2 ), '', 'returns expected value' ); - t.strictEqual( removeLast( '', 3 ), '', 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns the input string if provided zero as the second argument', function test( t ) { - t.strictEqual( removeLast( 'hello world', 0 ), 'hello world', 'returns expected value' ); - t.end(); -}); - -tape( 'the function removes the last Unicode code point of a provided string (ascii)', function test( t ) { - var out; - - out = removeLast( 'hello world', 1 ); - t.strictEqual( out, 'hello worl', 'returns expected value' ); - - out = removeLast( '!!!', 1 ); - t.strictEqual( out, '!!', 'returns expected value' ); - - out = removeLast( 'Hello World', 1 ); - t.strictEqual( out, 'Hello Worl', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function removes the last Unicode code point of a provided string (Unicode)', function test( t ) { - var out; - - out = removeLast( 'अनुच्छेद', 1 ); - t.strictEqual( out, 'अनुच्छे', 'returns expected value' ); - - out = removeLast( '六书/六書', 1 ); - t.strictEqual( out, '六书/六', 'returns expected value' ); - - out = removeLast( '𐒻𐓟', 1 ); - t.strictEqual( out, '𐒻', 'returns expected value' ); - - out = removeLast( '𐒻𐓟', 1 ); - t.strictEqual( out, '𐒻', 'returns expected value' ); - - out = removeLast( '\uDC00', 1 ); - t.strictEqual( out, '', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports removing the last `n` Unicode code points of a provided string', function test( t ) { - var out; - - out = removeLast( 'hello world', 1 ); - t.strictEqual( out, 'hello worl', 'returns expected value' ); - - out = removeLast( 'hello world', 7 ); - t.strictEqual( out, 'hell', 'returns expected value' ); - - out = removeLast( '!!!', 1 ); - t.strictEqual( out, '!!', 'returns expected value' ); - - out = removeLast( '!!!', 2 ); - t.strictEqual( out, '!', 'returns expected value' ); - - out = removeLast( 'अनुच्छेद', 1 ); - t.strictEqual( out, 'अनुच्छे', 'returns expected value' ); - - out = removeLast( '六书/六書', 3 ); - t.strictEqual( out, '六书', 'returns expected value' ); - - out = removeLast( '𐒻𐓟𐓟', 2 ); - t.strictEqual( out, '𐒻', 'returns expected value' ); - - t.end(); -}); From a6df7d94b171d7d9b04579ad49f6d16214e6e665 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Apr 2024 00:32:27 +0000 Subject: [PATCH 49/92] Transform error messages --- package.json | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 2bbf191..7d6f49d 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,9 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": {}, + "dependencies": { + "@stdlib/error-tools-fmtprodmsg": "^0.2.1" + }, "devDependencies": { "@stdlib/assert-is-string": "^0.2.1", "tape": "git+https://github.com/kgryte/tape.git#fix/globby", @@ -79,4 +81,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From d75710bfec7b2e65ee525833cb78973e1d067751 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Apr 2024 00:40:04 +0000 Subject: [PATCH 50/92] Remove files --- browser.js | 3 - browser.js.map | 1 - index.js | 3 - index.js.map | 1 - stats_browser.html | 4842 -------------------------------------------- stats_node.html | 4842 -------------------------------------------- 6 files changed, 9692 deletions(-) delete mode 100644 browser.js delete mode 100644 browser.js.map delete mode 100644 index.js delete mode 100644 index.js.map delete mode 100644 stats_browser.html delete mode 100644 stats_node.html diff --git a/browser.js b/browser.js deleted file mode 100644 index f3a511a..0000000 --- a/browser.js +++ /dev/null @@ -1,3 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -var e,t;e=this,t=function(){"use strict";var e=/[\uDC00-\uDFFF]/,t=/[\uD800-\uDBFF]/;return function(n,f){var i,o,r,u;if(0===f)return n;for(r=0,u=n.length-1;u>=0;u--){if(i=n[u],r+=1,e.test(i)){if(0===u)break;o=n[u-1],t.test(o)&&(u-=1)}if(r===f)break}return n.substring(0,u)}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).removeLastCodePoint=t(); -//# sourceMappingURL=browser.js.map diff --git a/browser.js.map b/browser.js.map deleted file mode 100644 index 19908eb..0000000 --- a/browser.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"browser.js","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\nvar RE_UTF16_LOW_SURROGATE = /[\\uDC00-\\uDFFF]/; // TODO: replace with stdlib pkg\nvar RE_UTF16_HIGH_SURROGATE = /[\\uD800-\\uDBFF]/; // TODO: replace with stdlib pkg\n\n\n// MAIN //\n\n/**\n* Removes the last `n` Unicode code points of a string.\n*\n* @param {string} str - input string\n* @param {NonNegativeInteger} n - number of Unicode code points to remove\n* @returns {string} output string\n*\n* @example\n* var out = removeLast( 'last man standing', 1 );\n* // returns 'last man standin'\n*\n* @example\n* var out = removeLast( 'presidential election', 1 );\n* // returns 'presidential electio'\n*\n* @example\n* var out = removeLast( 'JavaScript', 1 );\n* // returns 'JavaScrip'\n*\n* @example\n* var out = removeLast( 'Hidden Treasures', 1 );\n* // returns 'Hidden Treasure'\n*/\nfunction removeLast( str, n ) {\n\tvar len;\n\tvar ch1;\n\tvar ch2;\n\tvar cnt;\n\tvar i;\n\tif ( n === 0 ) {\n\t\treturn str;\n\t}\n\tlen = str.length;\n\tcnt = 0;\n\n\t// Process the string one Unicode code unit at a time and count UTF-16 surrogate pairs as a single Unicode code point...\n\tfor ( i = len - 1; i >= 0; i-- ) {\n\t\tch1 = str[ i ];\n\t\tcnt += 1;\n\n\t\t// Check for a low UTF-16 surrogate...\n\t\tif ( RE_UTF16_LOW_SURROGATE.test( ch1 ) ) {\n\t\t\t// Check for an unpaired surrogate at the end of the input string...\n\t\t\tif ( i === 0 ) {\n\t\t\t\t// We found an unpaired surrogate...\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\t// Check whether the high surrogate is paired with a low surrogate...\n\t\t\tch2 = str[ i-1 ];\n\t\t\tif ( RE_UTF16_HIGH_SURROGATE.test( ch2 ) ) {\n\t\t\t\t// We found a surrogate pair:\n\t\t\t\ti -= 1; // bump the index to process the next code unit\n\t\t\t}\n\t\t}\n\t\t// Check whether we've found the desired number of code points...\n\t\tif ( cnt === n ) {\n\t\t\tbreak;\n\t\t}\n\t}\n\treturn str.substring( 0, i );\n}\n\n\n// EXPORTS //\n\nexport default removeLast;\n"],"names":["RE_UTF16_LOW_SURROGATE","RE_UTF16_HIGH_SURROGATE","str","n","ch1","ch2","cnt","i","length","test","substring"],"mappings":";yCAsBA,IAAIA,EAAyB,kBACzBC,EAA0B,yBA4B9B,SAAqBC,EAAKC,GACzB,IACIC,EACAC,EACAC,EACAC,EACJ,GAAW,IAANJ,EACJ,OAAOD,EAMR,IAHAI,EAAM,EAGAC,EAJAL,EAAIM,OAIM,EAAGD,GAAK,EAAGA,IAAM,CAKhC,GAJAH,EAAMF,EAAKK,GACXD,GAAO,EAGFN,EAAuBS,KAAML,GAAQ,CAEzC,GAAW,IAANG,EAEJ,MAGDF,EAAMH,EAAKK,EAAE,GACRN,EAAwBQ,KAAMJ,KAElCE,GAAK,EAEN,CAED,GAAKD,IAAQH,EACZ,KAED,CACD,OAAOD,EAAIQ,UAAW,EAAGH,EAC1B"} \ No newline at end of file diff --git a/index.js b/index.js deleted file mode 100644 index 4e500d1..0000000 --- a/index.js +++ /dev/null @@ -1,3 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -var e,t;e=this,t=function(){"use strict";var e=/[\uDC00-\uDFFF]/,t=/[\uD800-\uDBFF]/;return function(n,f){var i,o,r,u;if(0===f)return n;for(r=0,u=n.length-1;u>=0;u--){if(i=n[u],r+=1,e.test(i)){if(0===u)break;o=n[u-1],t.test(o)&&(u-=1)}if(r===f)break}return n.substring(0,u)}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).removeLastCodePoint=t(); -//# sourceMappingURL=index.js.map diff --git a/index.js.map b/index.js.map deleted file mode 100644 index d557af8..0000000 --- a/index.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.js","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\nvar RE_UTF16_LOW_SURROGATE = /[\\uDC00-\\uDFFF]/; // TODO: replace with stdlib pkg\nvar RE_UTF16_HIGH_SURROGATE = /[\\uD800-\\uDBFF]/; // TODO: replace with stdlib pkg\n\n\n// MAIN //\n\n/**\n* Removes the last `n` Unicode code points of a string.\n*\n* @param {string} str - input string\n* @param {NonNegativeInteger} n - number of Unicode code points to remove\n* @returns {string} output string\n*\n* @example\n* var out = removeLast( 'last man standing', 1 );\n* // returns 'last man standin'\n*\n* @example\n* var out = removeLast( 'presidential election', 1 );\n* // returns 'presidential electio'\n*\n* @example\n* var out = removeLast( 'JavaScript', 1 );\n* // returns 'JavaScrip'\n*\n* @example\n* var out = removeLast( 'Hidden Treasures', 1 );\n* // returns 'Hidden Treasure'\n*/\nfunction removeLast( str, n ) {\n\tvar len;\n\tvar ch1;\n\tvar ch2;\n\tvar cnt;\n\tvar i;\n\tif ( n === 0 ) {\n\t\treturn str;\n\t}\n\tlen = str.length;\n\tcnt = 0;\n\n\t// Process the string one Unicode code unit at a time and count UTF-16 surrogate pairs as a single Unicode code point...\n\tfor ( i = len - 1; i >= 0; i-- ) {\n\t\tch1 = str[ i ];\n\t\tcnt += 1;\n\n\t\t// Check for a low UTF-16 surrogate...\n\t\tif ( RE_UTF16_LOW_SURROGATE.test( ch1 ) ) {\n\t\t\t// Check for an unpaired surrogate at the end of the input string...\n\t\t\tif ( i === 0 ) {\n\t\t\t\t// We found an unpaired surrogate...\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\t// Check whether the high surrogate is paired with a low surrogate...\n\t\t\tch2 = str[ i-1 ];\n\t\t\tif ( RE_UTF16_HIGH_SURROGATE.test( ch2 ) ) {\n\t\t\t\t// We found a surrogate pair:\n\t\t\t\ti -= 1; // bump the index to process the next code unit\n\t\t\t}\n\t\t}\n\t\t// Check whether we've found the desired number of code points...\n\t\tif ( cnt === n ) {\n\t\t\tbreak;\n\t\t}\n\t}\n\treturn str.substring( 0, i );\n}\n\n\n// EXPORTS //\n\nexport default removeLast;\n"],"names":["RE_UTF16_LOW_SURROGATE","RE_UTF16_HIGH_SURROGATE","str","n","ch1","ch2","cnt","i","length","test","substring"],"mappings":";yCAsBA,IAAIA,EAAyB,kBACzBC,EAA0B,yBA4B9B,SAAqBC,EAAKC,GACzB,IACIC,EACAC,EACAC,EACAC,EACJ,GAAW,IAANJ,EACJ,OAAOD,EAMR,IAHAI,EAAM,EAGAC,EAJAL,EAAIM,OAIM,EAAGD,GAAK,EAAGA,IAAM,CAKhC,GAJAH,EAAMF,EAAKK,GACXD,GAAO,EAGFN,EAAuBS,KAAML,GAAQ,CAEzC,GAAW,IAANG,EAEJ,MAGDF,EAAMH,EAAKK,EAAE,GACRN,EAAwBQ,KAAMJ,KAElCE,GAAK,EAEN,CAED,GAAKD,IAAQH,EACZ,KAED,CACD,OAAOD,EAAIQ,UAAW,EAAGH,EAC1B"} \ No newline at end of file diff --git a/stats_browser.html b/stats_browser.html deleted file mode 100644 index 2c17dcc..0000000 --- a/stats_browser.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - diff --git a/stats_node.html b/stats_node.html deleted file mode 100644 index 1e086d4..0000000 --- a/stats_node.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From ca2d82a0649d85683f2f1a2d1c93a021e4e502d9 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Apr 2024 00:40:28 +0000 Subject: [PATCH 51/92] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 797 ---- .github/workflows/publish.yml | 249 -- .github/workflows/test.yml | 100 - .github/workflows/test_bundles.yml | 189 - .github/workflows/test_coverage.yml | 132 - .github/workflows/test_install.yml | 86 - .gitignore | 188 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 52 +- SECURITY.md | 5 - benchmark/benchmark.js | 56 - branches.md | 56 - browser.js | 3 + browser.js.map | 1 + dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 29 - docs/types/index.d.ts | 53 - docs/types/test.ts | 57 - examples/index.js | 33 - index.js | 3 + index.js.map | 1 + lib/index.js | 43 - lib/main.js | 94 - package.json | 53 +- stats_browser.html | 4842 +++++++++++++++++++++ stats_node.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 108 - 46 files changed, 9728 insertions(+), 3817 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md create mode 100644 browser.js create mode 100644 browser.js.map 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/index.d.ts delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js create mode 100644 index.js create mode 100644 index.js.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats_browser.html create mode 100644 stats_node.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 2b2a0a2..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-04-01T00:31:41.977Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 52cd9c4..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/base/remove-last-code-point) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 533eeee..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/base/remove-last-code-point) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 2a724f2..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: '29 5 * * 0' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index ec90164..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,797 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n +``` -```javascript -var removeLastCodePoint = require( '@stdlib/string-base-remove-last-code-point' ); +If no recognized module system is present, access bundle contents via the global scope: + +```html + ``` #### removeLastCodePoint( str, n ) @@ -91,8 +97,13 @@ out = removeLastCodePoint( 'foo bar', 10 ); -```javascript -var removeLastCodePoint = require( '@stdlib/string-base-remove-last-code-point' ); +```html + + + + + + + ```
diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index a39bd29..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,56 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var removeLast = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var values; - var out; - var i; - - values = [ - 'beep boop', - 'foo bar', - 'xyz abc', - '🐶🐮🐷🐰🐸' - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = removeLast( values[ i%values.length ], 1 ); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( !isString( out ) ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index f585c99..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/base/remove-last-code-point" -%% click B href "https://github.com/stdlib-js/string-base-remove-last-code-point/tree/main" -%% click C href "https://github.com/stdlib-js/string-base-remove-last-code-point/tree/production" -%% click D href "https://github.com/stdlib-js/string-base-remove-last-code-point/tree/esm" -%% click E href "https://github.com/stdlib-js/string-base-remove-last-code-point/tree/deno" -%% click F href "https://github.com/stdlib-js/string-base-remove-last-code-point/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/base/remove-last-code-point -[production-url]: https://github.com/stdlib-js/string-base-remove-last-code-point/tree/production -[deno-url]: https://github.com/stdlib-js/string-base-remove-last-code-point/tree/deno -[deno-readme]: https://github.com/stdlib-js/string-base-remove-last-code-point/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/string-base-remove-last-code-point/tree/umd -[umd-readme]: https://github.com/stdlib-js/string-base-remove-last-code-point/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/string-base-remove-last-code-point/tree/esm -[esm-readme]: https://github.com/stdlib-js/string-base-remove-last-code-point/blob/esm/README.md \ No newline at end of file diff --git a/browser.js b/browser.js new file mode 100644 index 0000000..f3a511a --- /dev/null +++ b/browser.js @@ -0,0 +1,3 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +var e,t;e=this,t=function(){"use strict";var e=/[\uDC00-\uDFFF]/,t=/[\uD800-\uDBFF]/;return function(n,f){var i,o,r,u;if(0===f)return n;for(r=0,u=n.length-1;u>=0;u--){if(i=n[u],r+=1,e.test(i)){if(0===u)break;o=n[u-1],t.test(o)&&(u-=1)}if(r===f)break}return n.substring(0,u)}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).removeLastCodePoint=t(); +//# sourceMappingURL=browser.js.map diff --git a/browser.js.map b/browser.js.map new file mode 100644 index 0000000..19908eb --- /dev/null +++ b/browser.js.map @@ -0,0 +1 @@ +{"version":3,"file":"browser.js","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\nvar RE_UTF16_LOW_SURROGATE = /[\\uDC00-\\uDFFF]/; // TODO: replace with stdlib pkg\nvar RE_UTF16_HIGH_SURROGATE = /[\\uD800-\\uDBFF]/; // TODO: replace with stdlib pkg\n\n\n// MAIN //\n\n/**\n* Removes the last `n` Unicode code points of a string.\n*\n* @param {string} str - input string\n* @param {NonNegativeInteger} n - number of Unicode code points to remove\n* @returns {string} output string\n*\n* @example\n* var out = removeLast( 'last man standing', 1 );\n* // returns 'last man standin'\n*\n* @example\n* var out = removeLast( 'presidential election', 1 );\n* // returns 'presidential electio'\n*\n* @example\n* var out = removeLast( 'JavaScript', 1 );\n* // returns 'JavaScrip'\n*\n* @example\n* var out = removeLast( 'Hidden Treasures', 1 );\n* // returns 'Hidden Treasure'\n*/\nfunction removeLast( str, n ) {\n\tvar len;\n\tvar ch1;\n\tvar ch2;\n\tvar cnt;\n\tvar i;\n\tif ( n === 0 ) {\n\t\treturn str;\n\t}\n\tlen = str.length;\n\tcnt = 0;\n\n\t// Process the string one Unicode code unit at a time and count UTF-16 surrogate pairs as a single Unicode code point...\n\tfor ( i = len - 1; i >= 0; i-- ) {\n\t\tch1 = str[ i ];\n\t\tcnt += 1;\n\n\t\t// Check for a low UTF-16 surrogate...\n\t\tif ( RE_UTF16_LOW_SURROGATE.test( ch1 ) ) {\n\t\t\t// Check for an unpaired surrogate at the end of the input string...\n\t\t\tif ( i === 0 ) {\n\t\t\t\t// We found an unpaired surrogate...\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\t// Check whether the high surrogate is paired with a low surrogate...\n\t\t\tch2 = str[ i-1 ];\n\t\t\tif ( RE_UTF16_HIGH_SURROGATE.test( ch2 ) ) {\n\t\t\t\t// We found a surrogate pair:\n\t\t\t\ti -= 1; // bump the index to process the next code unit\n\t\t\t}\n\t\t}\n\t\t// Check whether we've found the desired number of code points...\n\t\tif ( cnt === n ) {\n\t\t\tbreak;\n\t\t}\n\t}\n\treturn str.substring( 0, i );\n}\n\n\n// EXPORTS //\n\nexport default removeLast;\n"],"names":["RE_UTF16_LOW_SURROGATE","RE_UTF16_HIGH_SURROGATE","str","n","ch1","ch2","cnt","i","length","test","substring"],"mappings":";yCAsBA,IAAIA,EAAyB,kBACzBC,EAA0B,yBA4B9B,SAAqBC,EAAKC,GACzB,IACIC,EACAC,EACAC,EACAC,EACJ,GAAW,IAANJ,EACJ,OAAOD,EAMR,IAHAI,EAAM,EAGAC,EAJAL,EAAIM,OAIM,EAAGD,GAAK,EAAGA,IAAM,CAKhC,GAJAH,EAAMF,EAAKK,GACXD,GAAO,EAGFN,EAAuBS,KAAML,GAAQ,CAEzC,GAAW,IAANG,EAEJ,MAGDF,EAAMH,EAAKK,EAAE,GACRN,EAAwBQ,KAAMJ,KAElCE,GAAK,EAEN,CAED,GAAKD,IAAQH,EACZ,KAED,CACD,OAAOD,EAAIQ,UAAW,EAAGH,EAC1B"} \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index 8c96fd7..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import removeLast from '../docs/types/index'; -export = removeLast; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index e6b7220..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var s=function(e,t){return function(){return t||e((t={exports:{}}).exports,t),t.exports}};var f=s(function(D,n){ -var F=/[\uDC00-\uDFFF]/,c=/[\uD800-\uDBFF]/;function R(e,t){var i,u,v,a,r;if(t===0)return e;for(i=e.length,a=0,r=i-1;r>=0;r--){if(u=e[r],a+=1,F.test(u)){if(r===0)break;v=e[r-1],c.test(v)&&(r-=1)}if(a===t)break}return e.substring(0,r)}n.exports=R -});var _=f();module.exports=_; -/** @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 72561cf..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\nvar RE_UTF16_LOW_SURROGATE = /[\\uDC00-\\uDFFF]/; // TODO: replace with stdlib pkg\nvar RE_UTF16_HIGH_SURROGATE = /[\\uD800-\\uDBFF]/; // TODO: replace with stdlib pkg\n\n\n// MAIN //\n\n/**\n* Removes the last `n` Unicode code points of a string.\n*\n* @param {string} str - input string\n* @param {NonNegativeInteger} n - number of Unicode code points to remove\n* @returns {string} output string\n*\n* @example\n* var out = removeLast( 'last man standing', 1 );\n* // returns 'last man standin'\n*\n* @example\n* var out = removeLast( 'presidential election', 1 );\n* // returns 'presidential electio'\n*\n* @example\n* var out = removeLast( 'JavaScript', 1 );\n* // returns 'JavaScrip'\n*\n* @example\n* var out = removeLast( 'Hidden Treasures', 1 );\n* // returns 'Hidden Treasure'\n*/\nfunction removeLast( str, n ) {\n\tvar len;\n\tvar ch1;\n\tvar ch2;\n\tvar cnt;\n\tvar i;\n\tif ( n === 0 ) {\n\t\treturn str;\n\t}\n\tlen = str.length;\n\tcnt = 0;\n\n\t// Process the string one Unicode code unit at a time and count UTF-16 surrogate pairs as a single Unicode code point...\n\tfor ( i = len - 1; i >= 0; i-- ) {\n\t\tch1 = str[ i ];\n\t\tcnt += 1;\n\n\t\t// Check for a low UTF-16 surrogate...\n\t\tif ( RE_UTF16_LOW_SURROGATE.test( ch1 ) ) {\n\t\t\t// Check for an unpaired surrogate at the end of the input string...\n\t\t\tif ( i === 0 ) {\n\t\t\t\t// We found an unpaired surrogate...\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\t// Check whether the high surrogate is paired with a low surrogate...\n\t\t\tch2 = str[ i-1 ];\n\t\t\tif ( RE_UTF16_HIGH_SURROGATE.test( ch2 ) ) {\n\t\t\t\t// We found a surrogate pair:\n\t\t\t\ti -= 1; // bump the index to process the next code unit\n\t\t\t}\n\t\t}\n\t\t// Check whether we've found the desired number of code points...\n\t\tif ( cnt === n ) {\n\t\t\tbreak;\n\t\t}\n\t}\n\treturn str.substring( 0, i );\n}\n\n\n// EXPORTS //\n\nmodule.exports = removeLast;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Remove the last `n` Unicode code points of a string.\n*\n* @module @stdlib/string-base-remove-last-code-point\n*\n* @example\n* var removeLast = require( '@stdlib/string-base-remove-last-code-point' );\n*\n* var out = removeLast( 'last man standing', 1 );\n* // returns 'last man standin'\n*\n* out = removeLast( 'Hidden Treasures', 1 );\n* // returns 'Hidden Treasure';\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,EAAyB,kBACzBC,EAA0B,kBA4B9B,SAASC,EAAYC,EAAKC,EAAI,CAC7B,IAAIC,EACAC,EACAC,EACAC,EACAC,EACJ,GAAKL,IAAM,EACV,OAAOD,EAMR,IAJAE,EAAMF,EAAI,OACVK,EAAM,EAGAC,EAAIJ,EAAM,EAAGI,GAAK,EAAGA,IAAM,CAKhC,GAJAH,EAAMH,EAAKM,CAAE,EACbD,GAAO,EAGFR,EAAuB,KAAMM,CAAI,EAAI,CAEzC,GAAKG,IAAM,EAEV,MAGDF,EAAMJ,EAAKM,EAAE,CAAE,EACVR,EAAwB,KAAMM,CAAI,IAEtCE,GAAK,EAEP,CAEA,GAAKD,IAAQJ,EACZ,KAEF,CACA,OAAOD,EAAI,UAAW,EAAGM,CAAE,CAC5B,CAKAV,EAAO,QAAUG,ICxDjB,IAAIQ,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "RE_UTF16_LOW_SURROGATE", "RE_UTF16_HIGH_SURROGATE", "removeLast", "str", "n", "len", "ch1", "ch2", "cnt", "i", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index a08ea55..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,29 +0,0 @@ - -{{alias}}( str, n ) - Removes the last `n` Unicode code points of a string. - - Parameters - ---------- - str: string - Input string. - - n: integer - Number of Unicode code points to remove. - - Returns - ------- - out: string - Output string. - - Examples - -------- - > var out = {{alias}}( 'beep', 1 ) - 'bee' - > out = {{alias}}( 'Boop', 1 ) - 'Boo' - > out = {{alias}}( 'foo bar', 5 ) - 'fo' - - See Also - -------- - diff --git a/docs/types/index.d.ts b/docs/types/index.d.ts deleted file mode 100644 index 8a1c90b..0000000 --- a/docs/types/index.d.ts +++ /dev/null @@ -1,53 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 - -/** -* Removes the last `n` Unicode code points of a string. -* -* @param str - input string -* @param n - number of code points to remove -* @returns output string -* -* @example -* var out = removeLast( 'last man standing', 1 ); -* // returns 'last man standin' -* -* @example -* var out = removeLast( 'presidential election', 1 ); -* // returns 'presidential electio' -* -* @example -* var out = removeLast( 'JavaScript', 1 ); -* // returns 'JavaScrip' -* -* @example -* var out = removeLast( 'Hidden Treasures', 1 ); -* // returns 'Hidden Treasure' -* -* @example -* var out = removeLast( 'foo bar', 5 ); -* // returns 'fo' -*/ -declare function removeLast( str: string, n: number ): string; - - -// EXPORTS // - -export = removeLast; diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index fd426d2..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,57 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 removeLast = require( './index' ); - - -// TESTS // - -// The function returns a string... -{ - removeLast( 'abc', 1 ); // $ExpectType string -} - -// The compiler throws an error if the function is provided a value other than a string... -{ - removeLast( true, 1 ); // $ExpectError - removeLast( false, 1 ); // $ExpectError - removeLast( null, 1 ); // $ExpectError - removeLast( undefined, 1 ); // $ExpectError - removeLast( 5, 1 ); // $ExpectError - removeLast( [], 1 ); // $ExpectError - removeLast( {}, 1 ); // $ExpectError - removeLast( ( x: number ): number => x, 1 ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument that is not a number... -{ - removeLast( 'abc', true ); // $ExpectError - removeLast( 'abc', false ); // $ExpectError - removeLast( 'abc', null ); // $ExpectError - removeLast( 'abc', 'abc' ); // $ExpectError - removeLast( 'abc', [] ); // $ExpectError - removeLast( 'abc', {} ); // $ExpectError - removeLast( 'abc', ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - removeLast(); // $ExpectError - removeLast( 'abc' ); // $ExpectError - removeLast( 'abc', 1, 2 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 085633e..0000000 --- a/examples/index.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var removeLastCodePoint = require( './../lib' ); - -console.log( removeLastCodePoint( 'presidential election', 1 ) ); -// => 'presidential electio' - -console.log( removeLastCodePoint( 'JavaScript', 1 ) ); -// => 'JavaScrip' - -console.log( removeLastCodePoint( 'The Last of the Mohicans', 5 ) ); -// => 'The Last of the Moh' - -console.log( removeLastCodePoint( 'अनुच्छेद', 1 ) ); -// => 'अनुच्छे' diff --git a/index.js b/index.js new file mode 100644 index 0000000..4e500d1 --- /dev/null +++ b/index.js @@ -0,0 +1,3 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +var e,t;e=this,t=function(){"use strict";var e=/[\uDC00-\uDFFF]/,t=/[\uD800-\uDBFF]/;return function(n,f){var i,o,r,u;if(0===f)return n;for(r=0,u=n.length-1;u>=0;u--){if(i=n[u],r+=1,e.test(i)){if(0===u)break;o=n[u-1],t.test(o)&&(u-=1)}if(r===f)break}return n.substring(0,u)}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).removeLastCodePoint=t(); +//# sourceMappingURL=index.js.map diff --git a/index.js.map b/index.js.map new file mode 100644 index 0000000..d557af8 --- /dev/null +++ b/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\nvar RE_UTF16_LOW_SURROGATE = /[\\uDC00-\\uDFFF]/; // TODO: replace with stdlib pkg\nvar RE_UTF16_HIGH_SURROGATE = /[\\uD800-\\uDBFF]/; // TODO: replace with stdlib pkg\n\n\n// MAIN //\n\n/**\n* Removes the last `n` Unicode code points of a string.\n*\n* @param {string} str - input string\n* @param {NonNegativeInteger} n - number of Unicode code points to remove\n* @returns {string} output string\n*\n* @example\n* var out = removeLast( 'last man standing', 1 );\n* // returns 'last man standin'\n*\n* @example\n* var out = removeLast( 'presidential election', 1 );\n* // returns 'presidential electio'\n*\n* @example\n* var out = removeLast( 'JavaScript', 1 );\n* // returns 'JavaScrip'\n*\n* @example\n* var out = removeLast( 'Hidden Treasures', 1 );\n* // returns 'Hidden Treasure'\n*/\nfunction removeLast( str, n ) {\n\tvar len;\n\tvar ch1;\n\tvar ch2;\n\tvar cnt;\n\tvar i;\n\tif ( n === 0 ) {\n\t\treturn str;\n\t}\n\tlen = str.length;\n\tcnt = 0;\n\n\t// Process the string one Unicode code unit at a time and count UTF-16 surrogate pairs as a single Unicode code point...\n\tfor ( i = len - 1; i >= 0; i-- ) {\n\t\tch1 = str[ i ];\n\t\tcnt += 1;\n\n\t\t// Check for a low UTF-16 surrogate...\n\t\tif ( RE_UTF16_LOW_SURROGATE.test( ch1 ) ) {\n\t\t\t// Check for an unpaired surrogate at the end of the input string...\n\t\t\tif ( i === 0 ) {\n\t\t\t\t// We found an unpaired surrogate...\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\t// Check whether the high surrogate is paired with a low surrogate...\n\t\t\tch2 = str[ i-1 ];\n\t\t\tif ( RE_UTF16_HIGH_SURROGATE.test( ch2 ) ) {\n\t\t\t\t// We found a surrogate pair:\n\t\t\t\ti -= 1; // bump the index to process the next code unit\n\t\t\t}\n\t\t}\n\t\t// Check whether we've found the desired number of code points...\n\t\tif ( cnt === n ) {\n\t\t\tbreak;\n\t\t}\n\t}\n\treturn str.substring( 0, i );\n}\n\n\n// EXPORTS //\n\nexport default removeLast;\n"],"names":["RE_UTF16_LOW_SURROGATE","RE_UTF16_HIGH_SURROGATE","str","n","ch1","ch2","cnt","i","length","test","substring"],"mappings":";yCAsBA,IAAIA,EAAyB,kBACzBC,EAA0B,yBA4B9B,SAAqBC,EAAKC,GACzB,IACIC,EACAC,EACAC,EACAC,EACJ,GAAW,IAANJ,EACJ,OAAOD,EAMR,IAHAI,EAAM,EAGAC,EAJAL,EAAIM,OAIM,EAAGD,GAAK,EAAGA,IAAM,CAKhC,GAJAH,EAAMF,EAAKK,GACXD,GAAO,EAGFN,EAAuBS,KAAML,GAAQ,CAEzC,GAAW,IAANG,EAEJ,MAGDF,EAAMH,EAAKK,EAAE,GACRN,EAAwBQ,KAAMJ,KAElCE,GAAK,EAEN,CAED,GAAKD,IAAQH,EACZ,KAED,CACD,OAAOD,EAAIQ,UAAW,EAAGH,EAC1B"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 9860da0..0000000 --- a/lib/index.js +++ /dev/null @@ -1,43 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Remove the last `n` Unicode code points of a string. -* -* @module @stdlib/string-base-remove-last-code-point -* -* @example -* var removeLast = require( '@stdlib/string-base-remove-last-code-point' ); -* -* var out = removeLast( 'last man standing', 1 ); -* // returns 'last man standin' -* -* out = removeLast( 'Hidden Treasures', 1 ); -* // returns 'Hidden Treasure'; -*/ - -// 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 fc34187..0000000 --- a/lib/main.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// VARIABLES // - -var RE_UTF16_LOW_SURROGATE = /[\uDC00-\uDFFF]/; // TODO: replace with stdlib pkg -var RE_UTF16_HIGH_SURROGATE = /[\uD800-\uDBFF]/; // TODO: replace with stdlib pkg - - -// MAIN // - -/** -* Removes the last `n` Unicode code points of a string. -* -* @param {string} str - input string -* @param {NonNegativeInteger} n - number of Unicode code points to remove -* @returns {string} output string -* -* @example -* var out = removeLast( 'last man standing', 1 ); -* // returns 'last man standin' -* -* @example -* var out = removeLast( 'presidential election', 1 ); -* // returns 'presidential electio' -* -* @example -* var out = removeLast( 'JavaScript', 1 ); -* // returns 'JavaScrip' -* -* @example -* var out = removeLast( 'Hidden Treasures', 1 ); -* // returns 'Hidden Treasure' -*/ -function removeLast( str, n ) { - var len; - var ch1; - var ch2; - var cnt; - var i; - if ( n === 0 ) { - return str; - } - len = str.length; - cnt = 0; - - // Process the string one Unicode code unit at a time and count UTF-16 surrogate pairs as a single Unicode code point... - for ( i = len - 1; i >= 0; i-- ) { - ch1 = str[ i ]; - cnt += 1; - - // Check for a low UTF-16 surrogate... - if ( RE_UTF16_LOW_SURROGATE.test( ch1 ) ) { - // Check for an unpaired surrogate at the end of the input string... - if ( i === 0 ) { - // We found an unpaired surrogate... - break; - } - // Check whether the high surrogate is paired with a low surrogate... - ch2 = str[ i-1 ]; - if ( RE_UTF16_HIGH_SURROGATE.test( ch2 ) ) { - // We found a surrogate pair: - i -= 1; // bump the index to process the next code unit - } - } - // Check whether we've found the desired number of code points... - if ( cnt === n ) { - break; - } - } - return str.substring( 0, i ); -} - - -// EXPORTS // - -module.exports = removeLast; diff --git a/package.json b/package.json index 7d6f49d..f3c9a46 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,7 @@ "version": "0.2.1", "description": "Remove the last Unicode code point of a string.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "main": "./index.js", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,31 +12,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/error-tools-fmtprodmsg": "^0.2.1" - }, - "devDependencies": { - "@stdlib/assert-is-string": "^0.2.1", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.1" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdstring", @@ -81,4 +32,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/stats_browser.html b/stats_browser.html new file mode 100644 index 0000000..2c17dcc --- /dev/null +++ b/stats_browser.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/stats_node.html b/stats_node.html new file mode 100644 index 0000000..1e086d4 --- /dev/null +++ b/stats_node.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index a25545e..0000000 --- a/test/test.js +++ /dev/null @@ -1,108 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var removeLast = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof removeLast, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns an empty string if provided an empty string', function test( t ) { - t.strictEqual( removeLast( '', 1 ), '', 'returns expected value' ); - t.strictEqual( removeLast( '', 2 ), '', 'returns expected value' ); - t.strictEqual( removeLast( '', 3 ), '', 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns the input string if provided zero as the second argument', function test( t ) { - t.strictEqual( removeLast( 'hello world', 0 ), 'hello world', 'returns expected value' ); - t.end(); -}); - -tape( 'the function removes the last Unicode code point of a provided string (ascii)', function test( t ) { - var out; - - out = removeLast( 'hello world', 1 ); - t.strictEqual( out, 'hello worl', 'returns expected value' ); - - out = removeLast( '!!!', 1 ); - t.strictEqual( out, '!!', 'returns expected value' ); - - out = removeLast( 'Hello World', 1 ); - t.strictEqual( out, 'Hello Worl', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function removes the last Unicode code point of a provided string (Unicode)', function test( t ) { - var out; - - out = removeLast( 'अनुच्छेद', 1 ); - t.strictEqual( out, 'अनुच्छे', 'returns expected value' ); - - out = removeLast( '六书/六書', 1 ); - t.strictEqual( out, '六书/六', 'returns expected value' ); - - out = removeLast( '𐒻𐓟', 1 ); - t.strictEqual( out, '𐒻', 'returns expected value' ); - - out = removeLast( '𐒻𐓟', 1 ); - t.strictEqual( out, '𐒻', 'returns expected value' ); - - out = removeLast( '\uDC00', 1 ); - t.strictEqual( out, '', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports removing the last `n` Unicode code points of a provided string', function test( t ) { - var out; - - out = removeLast( 'hello world', 1 ); - t.strictEqual( out, 'hello worl', 'returns expected value' ); - - out = removeLast( 'hello world', 7 ); - t.strictEqual( out, 'hell', 'returns expected value' ); - - out = removeLast( '!!!', 1 ); - t.strictEqual( out, '!!', 'returns expected value' ); - - out = removeLast( '!!!', 2 ); - t.strictEqual( out, '!', 'returns expected value' ); - - out = removeLast( 'अनुच्छेद', 1 ); - t.strictEqual( out, 'अनुच्छे', 'returns expected value' ); - - out = removeLast( '六书/六書', 3 ); - t.strictEqual( out, '六书', 'returns expected value' ); - - out = removeLast( '𐒻𐓟𐓟', 2 ); - t.strictEqual( out, '𐒻', 'returns expected value' ); - - t.end(); -}); From 9ca5db602ca1246525f509fa9f6020a1fe24aa77 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 11 Apr 2024 20:42:03 +0000 Subject: [PATCH 52/92] Transform error messages --- package.json | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 2bbf191..7d6f49d 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,9 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": {}, + "dependencies": { + "@stdlib/error-tools-fmtprodmsg": "^0.2.1" + }, "devDependencies": { "@stdlib/assert-is-string": "^0.2.1", "tape": "git+https://github.com/kgryte/tape.git#fix/globby", @@ -79,4 +81,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From ffb13107e1da907d8a4451ff4f745f676167d417 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 11 Apr 2024 20:51:42 +0000 Subject: [PATCH 53/92] Remove files --- browser.js | 3 - browser.js.map | 1 - index.js | 3 - index.js.map | 1 - stats_browser.html | 4842 -------------------------------------------- stats_node.html | 4842 -------------------------------------------- 6 files changed, 9692 deletions(-) delete mode 100644 browser.js delete mode 100644 browser.js.map delete mode 100644 index.js delete mode 100644 index.js.map delete mode 100644 stats_browser.html delete mode 100644 stats_node.html diff --git a/browser.js b/browser.js deleted file mode 100644 index f3a511a..0000000 --- a/browser.js +++ /dev/null @@ -1,3 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -var e,t;e=this,t=function(){"use strict";var e=/[\uDC00-\uDFFF]/,t=/[\uD800-\uDBFF]/;return function(n,f){var i,o,r,u;if(0===f)return n;for(r=0,u=n.length-1;u>=0;u--){if(i=n[u],r+=1,e.test(i)){if(0===u)break;o=n[u-1],t.test(o)&&(u-=1)}if(r===f)break}return n.substring(0,u)}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).removeLastCodePoint=t(); -//# sourceMappingURL=browser.js.map diff --git a/browser.js.map b/browser.js.map deleted file mode 100644 index 19908eb..0000000 --- a/browser.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"browser.js","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\nvar RE_UTF16_LOW_SURROGATE = /[\\uDC00-\\uDFFF]/; // TODO: replace with stdlib pkg\nvar RE_UTF16_HIGH_SURROGATE = /[\\uD800-\\uDBFF]/; // TODO: replace with stdlib pkg\n\n\n// MAIN //\n\n/**\n* Removes the last `n` Unicode code points of a string.\n*\n* @param {string} str - input string\n* @param {NonNegativeInteger} n - number of Unicode code points to remove\n* @returns {string} output string\n*\n* @example\n* var out = removeLast( 'last man standing', 1 );\n* // returns 'last man standin'\n*\n* @example\n* var out = removeLast( 'presidential election', 1 );\n* // returns 'presidential electio'\n*\n* @example\n* var out = removeLast( 'JavaScript', 1 );\n* // returns 'JavaScrip'\n*\n* @example\n* var out = removeLast( 'Hidden Treasures', 1 );\n* // returns 'Hidden Treasure'\n*/\nfunction removeLast( str, n ) {\n\tvar len;\n\tvar ch1;\n\tvar ch2;\n\tvar cnt;\n\tvar i;\n\tif ( n === 0 ) {\n\t\treturn str;\n\t}\n\tlen = str.length;\n\tcnt = 0;\n\n\t// Process the string one Unicode code unit at a time and count UTF-16 surrogate pairs as a single Unicode code point...\n\tfor ( i = len - 1; i >= 0; i-- ) {\n\t\tch1 = str[ i ];\n\t\tcnt += 1;\n\n\t\t// Check for a low UTF-16 surrogate...\n\t\tif ( RE_UTF16_LOW_SURROGATE.test( ch1 ) ) {\n\t\t\t// Check for an unpaired surrogate at the end of the input string...\n\t\t\tif ( i === 0 ) {\n\t\t\t\t// We found an unpaired surrogate...\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\t// Check whether the high surrogate is paired with a low surrogate...\n\t\t\tch2 = str[ i-1 ];\n\t\t\tif ( RE_UTF16_HIGH_SURROGATE.test( ch2 ) ) {\n\t\t\t\t// We found a surrogate pair:\n\t\t\t\ti -= 1; // bump the index to process the next code unit\n\t\t\t}\n\t\t}\n\t\t// Check whether we've found the desired number of code points...\n\t\tif ( cnt === n ) {\n\t\t\tbreak;\n\t\t}\n\t}\n\treturn str.substring( 0, i );\n}\n\n\n// EXPORTS //\n\nexport default removeLast;\n"],"names":["RE_UTF16_LOW_SURROGATE","RE_UTF16_HIGH_SURROGATE","str","n","ch1","ch2","cnt","i","length","test","substring"],"mappings":";yCAsBA,IAAIA,EAAyB,kBACzBC,EAA0B,yBA4B9B,SAAqBC,EAAKC,GACzB,IACIC,EACAC,EACAC,EACAC,EACJ,GAAW,IAANJ,EACJ,OAAOD,EAMR,IAHAI,EAAM,EAGAC,EAJAL,EAAIM,OAIM,EAAGD,GAAK,EAAGA,IAAM,CAKhC,GAJAH,EAAMF,EAAKK,GACXD,GAAO,EAGFN,EAAuBS,KAAML,GAAQ,CAEzC,GAAW,IAANG,EAEJ,MAGDF,EAAMH,EAAKK,EAAE,GACRN,EAAwBQ,KAAMJ,KAElCE,GAAK,EAEN,CAED,GAAKD,IAAQH,EACZ,KAED,CACD,OAAOD,EAAIQ,UAAW,EAAGH,EAC1B"} \ No newline at end of file diff --git a/index.js b/index.js deleted file mode 100644 index 4e500d1..0000000 --- a/index.js +++ /dev/null @@ -1,3 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -var e,t;e=this,t=function(){"use strict";var e=/[\uDC00-\uDFFF]/,t=/[\uD800-\uDBFF]/;return function(n,f){var i,o,r,u;if(0===f)return n;for(r=0,u=n.length-1;u>=0;u--){if(i=n[u],r+=1,e.test(i)){if(0===u)break;o=n[u-1],t.test(o)&&(u-=1)}if(r===f)break}return n.substring(0,u)}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).removeLastCodePoint=t(); -//# sourceMappingURL=index.js.map diff --git a/index.js.map b/index.js.map deleted file mode 100644 index d557af8..0000000 --- a/index.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.js","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\nvar RE_UTF16_LOW_SURROGATE = /[\\uDC00-\\uDFFF]/; // TODO: replace with stdlib pkg\nvar RE_UTF16_HIGH_SURROGATE = /[\\uD800-\\uDBFF]/; // TODO: replace with stdlib pkg\n\n\n// MAIN //\n\n/**\n* Removes the last `n` Unicode code points of a string.\n*\n* @param {string} str - input string\n* @param {NonNegativeInteger} n - number of Unicode code points to remove\n* @returns {string} output string\n*\n* @example\n* var out = removeLast( 'last man standing', 1 );\n* // returns 'last man standin'\n*\n* @example\n* var out = removeLast( 'presidential election', 1 );\n* // returns 'presidential electio'\n*\n* @example\n* var out = removeLast( 'JavaScript', 1 );\n* // returns 'JavaScrip'\n*\n* @example\n* var out = removeLast( 'Hidden Treasures', 1 );\n* // returns 'Hidden Treasure'\n*/\nfunction removeLast( str, n ) {\n\tvar len;\n\tvar ch1;\n\tvar ch2;\n\tvar cnt;\n\tvar i;\n\tif ( n === 0 ) {\n\t\treturn str;\n\t}\n\tlen = str.length;\n\tcnt = 0;\n\n\t// Process the string one Unicode code unit at a time and count UTF-16 surrogate pairs as a single Unicode code point...\n\tfor ( i = len - 1; i >= 0; i-- ) {\n\t\tch1 = str[ i ];\n\t\tcnt += 1;\n\n\t\t// Check for a low UTF-16 surrogate...\n\t\tif ( RE_UTF16_LOW_SURROGATE.test( ch1 ) ) {\n\t\t\t// Check for an unpaired surrogate at the end of the input string...\n\t\t\tif ( i === 0 ) {\n\t\t\t\t// We found an unpaired surrogate...\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\t// Check whether the high surrogate is paired with a low surrogate...\n\t\t\tch2 = str[ i-1 ];\n\t\t\tif ( RE_UTF16_HIGH_SURROGATE.test( ch2 ) ) {\n\t\t\t\t// We found a surrogate pair:\n\t\t\t\ti -= 1; // bump the index to process the next code unit\n\t\t\t}\n\t\t}\n\t\t// Check whether we've found the desired number of code points...\n\t\tif ( cnt === n ) {\n\t\t\tbreak;\n\t\t}\n\t}\n\treturn str.substring( 0, i );\n}\n\n\n// EXPORTS //\n\nexport default removeLast;\n"],"names":["RE_UTF16_LOW_SURROGATE","RE_UTF16_HIGH_SURROGATE","str","n","ch1","ch2","cnt","i","length","test","substring"],"mappings":";yCAsBA,IAAIA,EAAyB,kBACzBC,EAA0B,yBA4B9B,SAAqBC,EAAKC,GACzB,IACIC,EACAC,EACAC,EACAC,EACJ,GAAW,IAANJ,EACJ,OAAOD,EAMR,IAHAI,EAAM,EAGAC,EAJAL,EAAIM,OAIM,EAAGD,GAAK,EAAGA,IAAM,CAKhC,GAJAH,EAAMF,EAAKK,GACXD,GAAO,EAGFN,EAAuBS,KAAML,GAAQ,CAEzC,GAAW,IAANG,EAEJ,MAGDF,EAAMH,EAAKK,EAAE,GACRN,EAAwBQ,KAAMJ,KAElCE,GAAK,EAEN,CAED,GAAKD,IAAQH,EACZ,KAED,CACD,OAAOD,EAAIQ,UAAW,EAAGH,EAC1B"} \ No newline at end of file diff --git a/stats_browser.html b/stats_browser.html deleted file mode 100644 index 2c17dcc..0000000 --- a/stats_browser.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - diff --git a/stats_node.html b/stats_node.html deleted file mode 100644 index 1e086d4..0000000 --- a/stats_node.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 2fd8f095953647a5ef381cf1a3b2905c588bef55 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 11 Apr 2024 20:52:05 +0000 Subject: [PATCH 54/92] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 797 ---- .github/workflows/publish.yml | 249 -- .github/workflows/test.yml | 100 - .github/workflows/test_bundles.yml | 189 - .github/workflows/test_coverage.yml | 134 - .github/workflows/test_install.yml | 86 - .gitignore | 188 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 52 +- SECURITY.md | 5 - benchmark/benchmark.js | 56 - branches.md | 56 - browser.js | 3 + browser.js.map | 1 + dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 29 - docs/types/index.d.ts | 53 - docs/types/test.ts | 57 - examples/index.js | 33 - index.js | 3 + index.js.map | 1 + lib/index.js | 43 - lib/main.js | 94 - package.json | 53 +- stats_browser.html | 4842 +++++++++++++++++++++ stats_node.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 108 - 45 files changed, 9728 insertions(+), 3818 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md create mode 100644 browser.js create mode 100644 browser.js.map 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/index.d.ts delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js create mode 100644 index.js create mode 100644 index.js.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats_browser.html create mode 100644 stats_node.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 52cd9c4..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/base/remove-last-code-point) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 533eeee..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/base/remove-last-code-point) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 2a724f2..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: '29 5 * * 0' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index ec90164..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,797 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n +``` -```javascript -var removeLastCodePoint = require( '@stdlib/string-base-remove-last-code-point' ); +If no recognized module system is present, access bundle contents via the global scope: + +```html + ``` #### removeLastCodePoint( str, n ) @@ -91,8 +97,13 @@ out = removeLastCodePoint( 'foo bar', 10 ); -```javascript -var removeLastCodePoint = require( '@stdlib/string-base-remove-last-code-point' ); +```html + + + + + + + ```
diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index a39bd29..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,56 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var removeLast = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var values; - var out; - var i; - - values = [ - 'beep boop', - 'foo bar', - 'xyz abc', - '🐶🐮🐷🐰🐸' - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = removeLast( values[ i%values.length ], 1 ); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( !isString( out ) ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index f585c99..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/base/remove-last-code-point" -%% click B href "https://github.com/stdlib-js/string-base-remove-last-code-point/tree/main" -%% click C href "https://github.com/stdlib-js/string-base-remove-last-code-point/tree/production" -%% click D href "https://github.com/stdlib-js/string-base-remove-last-code-point/tree/esm" -%% click E href "https://github.com/stdlib-js/string-base-remove-last-code-point/tree/deno" -%% click F href "https://github.com/stdlib-js/string-base-remove-last-code-point/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/base/remove-last-code-point -[production-url]: https://github.com/stdlib-js/string-base-remove-last-code-point/tree/production -[deno-url]: https://github.com/stdlib-js/string-base-remove-last-code-point/tree/deno -[deno-readme]: https://github.com/stdlib-js/string-base-remove-last-code-point/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/string-base-remove-last-code-point/tree/umd -[umd-readme]: https://github.com/stdlib-js/string-base-remove-last-code-point/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/string-base-remove-last-code-point/tree/esm -[esm-readme]: https://github.com/stdlib-js/string-base-remove-last-code-point/blob/esm/README.md \ No newline at end of file diff --git a/browser.js b/browser.js new file mode 100644 index 0000000..f3a511a --- /dev/null +++ b/browser.js @@ -0,0 +1,3 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +var e,t;e=this,t=function(){"use strict";var e=/[\uDC00-\uDFFF]/,t=/[\uD800-\uDBFF]/;return function(n,f){var i,o,r,u;if(0===f)return n;for(r=0,u=n.length-1;u>=0;u--){if(i=n[u],r+=1,e.test(i)){if(0===u)break;o=n[u-1],t.test(o)&&(u-=1)}if(r===f)break}return n.substring(0,u)}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).removeLastCodePoint=t(); +//# sourceMappingURL=browser.js.map diff --git a/browser.js.map b/browser.js.map new file mode 100644 index 0000000..19908eb --- /dev/null +++ b/browser.js.map @@ -0,0 +1 @@ +{"version":3,"file":"browser.js","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\nvar RE_UTF16_LOW_SURROGATE = /[\\uDC00-\\uDFFF]/; // TODO: replace with stdlib pkg\nvar RE_UTF16_HIGH_SURROGATE = /[\\uD800-\\uDBFF]/; // TODO: replace with stdlib pkg\n\n\n// MAIN //\n\n/**\n* Removes the last `n` Unicode code points of a string.\n*\n* @param {string} str - input string\n* @param {NonNegativeInteger} n - number of Unicode code points to remove\n* @returns {string} output string\n*\n* @example\n* var out = removeLast( 'last man standing', 1 );\n* // returns 'last man standin'\n*\n* @example\n* var out = removeLast( 'presidential election', 1 );\n* // returns 'presidential electio'\n*\n* @example\n* var out = removeLast( 'JavaScript', 1 );\n* // returns 'JavaScrip'\n*\n* @example\n* var out = removeLast( 'Hidden Treasures', 1 );\n* // returns 'Hidden Treasure'\n*/\nfunction removeLast( str, n ) {\n\tvar len;\n\tvar ch1;\n\tvar ch2;\n\tvar cnt;\n\tvar i;\n\tif ( n === 0 ) {\n\t\treturn str;\n\t}\n\tlen = str.length;\n\tcnt = 0;\n\n\t// Process the string one Unicode code unit at a time and count UTF-16 surrogate pairs as a single Unicode code point...\n\tfor ( i = len - 1; i >= 0; i-- ) {\n\t\tch1 = str[ i ];\n\t\tcnt += 1;\n\n\t\t// Check for a low UTF-16 surrogate...\n\t\tif ( RE_UTF16_LOW_SURROGATE.test( ch1 ) ) {\n\t\t\t// Check for an unpaired surrogate at the end of the input string...\n\t\t\tif ( i === 0 ) {\n\t\t\t\t// We found an unpaired surrogate...\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\t// Check whether the high surrogate is paired with a low surrogate...\n\t\t\tch2 = str[ i-1 ];\n\t\t\tif ( RE_UTF16_HIGH_SURROGATE.test( ch2 ) ) {\n\t\t\t\t// We found a surrogate pair:\n\t\t\t\ti -= 1; // bump the index to process the next code unit\n\t\t\t}\n\t\t}\n\t\t// Check whether we've found the desired number of code points...\n\t\tif ( cnt === n ) {\n\t\t\tbreak;\n\t\t}\n\t}\n\treturn str.substring( 0, i );\n}\n\n\n// EXPORTS //\n\nexport default removeLast;\n"],"names":["RE_UTF16_LOW_SURROGATE","RE_UTF16_HIGH_SURROGATE","str","n","ch1","ch2","cnt","i","length","test","substring"],"mappings":";yCAsBA,IAAIA,EAAyB,kBACzBC,EAA0B,yBA4B9B,SAAqBC,EAAKC,GACzB,IACIC,EACAC,EACAC,EACAC,EACJ,GAAW,IAANJ,EACJ,OAAOD,EAMR,IAHAI,EAAM,EAGAC,EAJAL,EAAIM,OAIM,EAAGD,GAAK,EAAGA,IAAM,CAKhC,GAJAH,EAAMF,EAAKK,GACXD,GAAO,EAGFN,EAAuBS,KAAML,GAAQ,CAEzC,GAAW,IAANG,EAEJ,MAGDF,EAAMH,EAAKK,EAAE,GACRN,EAAwBQ,KAAMJ,KAElCE,GAAK,EAEN,CAED,GAAKD,IAAQH,EACZ,KAED,CACD,OAAOD,EAAIQ,UAAW,EAAGH,EAC1B"} \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index 8c96fd7..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import removeLast from '../docs/types/index'; -export = removeLast; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index e6b7220..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var s=function(e,t){return function(){return t||e((t={exports:{}}).exports,t),t.exports}};var f=s(function(D,n){ -var F=/[\uDC00-\uDFFF]/,c=/[\uD800-\uDBFF]/;function R(e,t){var i,u,v,a,r;if(t===0)return e;for(i=e.length,a=0,r=i-1;r>=0;r--){if(u=e[r],a+=1,F.test(u)){if(r===0)break;v=e[r-1],c.test(v)&&(r-=1)}if(a===t)break}return e.substring(0,r)}n.exports=R -});var _=f();module.exports=_; -/** @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 72561cf..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\nvar RE_UTF16_LOW_SURROGATE = /[\\uDC00-\\uDFFF]/; // TODO: replace with stdlib pkg\nvar RE_UTF16_HIGH_SURROGATE = /[\\uD800-\\uDBFF]/; // TODO: replace with stdlib pkg\n\n\n// MAIN //\n\n/**\n* Removes the last `n` Unicode code points of a string.\n*\n* @param {string} str - input string\n* @param {NonNegativeInteger} n - number of Unicode code points to remove\n* @returns {string} output string\n*\n* @example\n* var out = removeLast( 'last man standing', 1 );\n* // returns 'last man standin'\n*\n* @example\n* var out = removeLast( 'presidential election', 1 );\n* // returns 'presidential electio'\n*\n* @example\n* var out = removeLast( 'JavaScript', 1 );\n* // returns 'JavaScrip'\n*\n* @example\n* var out = removeLast( 'Hidden Treasures', 1 );\n* // returns 'Hidden Treasure'\n*/\nfunction removeLast( str, n ) {\n\tvar len;\n\tvar ch1;\n\tvar ch2;\n\tvar cnt;\n\tvar i;\n\tif ( n === 0 ) {\n\t\treturn str;\n\t}\n\tlen = str.length;\n\tcnt = 0;\n\n\t// Process the string one Unicode code unit at a time and count UTF-16 surrogate pairs as a single Unicode code point...\n\tfor ( i = len - 1; i >= 0; i-- ) {\n\t\tch1 = str[ i ];\n\t\tcnt += 1;\n\n\t\t// Check for a low UTF-16 surrogate...\n\t\tif ( RE_UTF16_LOW_SURROGATE.test( ch1 ) ) {\n\t\t\t// Check for an unpaired surrogate at the end of the input string...\n\t\t\tif ( i === 0 ) {\n\t\t\t\t// We found an unpaired surrogate...\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\t// Check whether the high surrogate is paired with a low surrogate...\n\t\t\tch2 = str[ i-1 ];\n\t\t\tif ( RE_UTF16_HIGH_SURROGATE.test( ch2 ) ) {\n\t\t\t\t// We found a surrogate pair:\n\t\t\t\ti -= 1; // bump the index to process the next code unit\n\t\t\t}\n\t\t}\n\t\t// Check whether we've found the desired number of code points...\n\t\tif ( cnt === n ) {\n\t\t\tbreak;\n\t\t}\n\t}\n\treturn str.substring( 0, i );\n}\n\n\n// EXPORTS //\n\nmodule.exports = removeLast;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Remove the last `n` Unicode code points of a string.\n*\n* @module @stdlib/string-base-remove-last-code-point\n*\n* @example\n* var removeLast = require( '@stdlib/string-base-remove-last-code-point' );\n*\n* var out = removeLast( 'last man standing', 1 );\n* // returns 'last man standin'\n*\n* out = removeLast( 'Hidden Treasures', 1 );\n* // returns 'Hidden Treasure';\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,EAAyB,kBACzBC,EAA0B,kBA4B9B,SAASC,EAAYC,EAAKC,EAAI,CAC7B,IAAIC,EACAC,EACAC,EACAC,EACAC,EACJ,GAAKL,IAAM,EACV,OAAOD,EAMR,IAJAE,EAAMF,EAAI,OACVK,EAAM,EAGAC,EAAIJ,EAAM,EAAGI,GAAK,EAAGA,IAAM,CAKhC,GAJAH,EAAMH,EAAKM,CAAE,EACbD,GAAO,EAGFR,EAAuB,KAAMM,CAAI,EAAI,CAEzC,GAAKG,IAAM,EAEV,MAGDF,EAAMJ,EAAKM,EAAE,CAAE,EACVR,EAAwB,KAAMM,CAAI,IAEtCE,GAAK,EAEP,CAEA,GAAKD,IAAQJ,EACZ,KAEF,CACA,OAAOD,EAAI,UAAW,EAAGM,CAAE,CAC5B,CAKAV,EAAO,QAAUG,ICxDjB,IAAIQ,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "RE_UTF16_LOW_SURROGATE", "RE_UTF16_HIGH_SURROGATE", "removeLast", "str", "n", "len", "ch1", "ch2", "cnt", "i", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index a08ea55..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,29 +0,0 @@ - -{{alias}}( str, n ) - Removes the last `n` Unicode code points of a string. - - Parameters - ---------- - str: string - Input string. - - n: integer - Number of Unicode code points to remove. - - Returns - ------- - out: string - Output string. - - Examples - -------- - > var out = {{alias}}( 'beep', 1 ) - 'bee' - > out = {{alias}}( 'Boop', 1 ) - 'Boo' - > out = {{alias}}( 'foo bar', 5 ) - 'fo' - - See Also - -------- - diff --git a/docs/types/index.d.ts b/docs/types/index.d.ts deleted file mode 100644 index 8a1c90b..0000000 --- a/docs/types/index.d.ts +++ /dev/null @@ -1,53 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 - -/** -* Removes the last `n` Unicode code points of a string. -* -* @param str - input string -* @param n - number of code points to remove -* @returns output string -* -* @example -* var out = removeLast( 'last man standing', 1 ); -* // returns 'last man standin' -* -* @example -* var out = removeLast( 'presidential election', 1 ); -* // returns 'presidential electio' -* -* @example -* var out = removeLast( 'JavaScript', 1 ); -* // returns 'JavaScrip' -* -* @example -* var out = removeLast( 'Hidden Treasures', 1 ); -* // returns 'Hidden Treasure' -* -* @example -* var out = removeLast( 'foo bar', 5 ); -* // returns 'fo' -*/ -declare function removeLast( str: string, n: number ): string; - - -// EXPORTS // - -export = removeLast; diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index fd426d2..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,57 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 removeLast = require( './index' ); - - -// TESTS // - -// The function returns a string... -{ - removeLast( 'abc', 1 ); // $ExpectType string -} - -// The compiler throws an error if the function is provided a value other than a string... -{ - removeLast( true, 1 ); // $ExpectError - removeLast( false, 1 ); // $ExpectError - removeLast( null, 1 ); // $ExpectError - removeLast( undefined, 1 ); // $ExpectError - removeLast( 5, 1 ); // $ExpectError - removeLast( [], 1 ); // $ExpectError - removeLast( {}, 1 ); // $ExpectError - removeLast( ( x: number ): number => x, 1 ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument that is not a number... -{ - removeLast( 'abc', true ); // $ExpectError - removeLast( 'abc', false ); // $ExpectError - removeLast( 'abc', null ); // $ExpectError - removeLast( 'abc', 'abc' ); // $ExpectError - removeLast( 'abc', [] ); // $ExpectError - removeLast( 'abc', {} ); // $ExpectError - removeLast( 'abc', ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - removeLast(); // $ExpectError - removeLast( 'abc' ); // $ExpectError - removeLast( 'abc', 1, 2 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 085633e..0000000 --- a/examples/index.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var removeLastCodePoint = require( './../lib' ); - -console.log( removeLastCodePoint( 'presidential election', 1 ) ); -// => 'presidential electio' - -console.log( removeLastCodePoint( 'JavaScript', 1 ) ); -// => 'JavaScrip' - -console.log( removeLastCodePoint( 'The Last of the Mohicans', 5 ) ); -// => 'The Last of the Moh' - -console.log( removeLastCodePoint( 'अनुच्छेद', 1 ) ); -// => 'अनुच्छे' diff --git a/index.js b/index.js new file mode 100644 index 0000000..4e500d1 --- /dev/null +++ b/index.js @@ -0,0 +1,3 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +var e,t;e=this,t=function(){"use strict";var e=/[\uDC00-\uDFFF]/,t=/[\uD800-\uDBFF]/;return function(n,f){var i,o,r,u;if(0===f)return n;for(r=0,u=n.length-1;u>=0;u--){if(i=n[u],r+=1,e.test(i)){if(0===u)break;o=n[u-1],t.test(o)&&(u-=1)}if(r===f)break}return n.substring(0,u)}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).removeLastCodePoint=t(); +//# sourceMappingURL=index.js.map diff --git a/index.js.map b/index.js.map new file mode 100644 index 0000000..d557af8 --- /dev/null +++ b/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\nvar RE_UTF16_LOW_SURROGATE = /[\\uDC00-\\uDFFF]/; // TODO: replace with stdlib pkg\nvar RE_UTF16_HIGH_SURROGATE = /[\\uD800-\\uDBFF]/; // TODO: replace with stdlib pkg\n\n\n// MAIN //\n\n/**\n* Removes the last `n` Unicode code points of a string.\n*\n* @param {string} str - input string\n* @param {NonNegativeInteger} n - number of Unicode code points to remove\n* @returns {string} output string\n*\n* @example\n* var out = removeLast( 'last man standing', 1 );\n* // returns 'last man standin'\n*\n* @example\n* var out = removeLast( 'presidential election', 1 );\n* // returns 'presidential electio'\n*\n* @example\n* var out = removeLast( 'JavaScript', 1 );\n* // returns 'JavaScrip'\n*\n* @example\n* var out = removeLast( 'Hidden Treasures', 1 );\n* // returns 'Hidden Treasure'\n*/\nfunction removeLast( str, n ) {\n\tvar len;\n\tvar ch1;\n\tvar ch2;\n\tvar cnt;\n\tvar i;\n\tif ( n === 0 ) {\n\t\treturn str;\n\t}\n\tlen = str.length;\n\tcnt = 0;\n\n\t// Process the string one Unicode code unit at a time and count UTF-16 surrogate pairs as a single Unicode code point...\n\tfor ( i = len - 1; i >= 0; i-- ) {\n\t\tch1 = str[ i ];\n\t\tcnt += 1;\n\n\t\t// Check for a low UTF-16 surrogate...\n\t\tif ( RE_UTF16_LOW_SURROGATE.test( ch1 ) ) {\n\t\t\t// Check for an unpaired surrogate at the end of the input string...\n\t\t\tif ( i === 0 ) {\n\t\t\t\t// We found an unpaired surrogate...\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\t// Check whether the high surrogate is paired with a low surrogate...\n\t\t\tch2 = str[ i-1 ];\n\t\t\tif ( RE_UTF16_HIGH_SURROGATE.test( ch2 ) ) {\n\t\t\t\t// We found a surrogate pair:\n\t\t\t\ti -= 1; // bump the index to process the next code unit\n\t\t\t}\n\t\t}\n\t\t// Check whether we've found the desired number of code points...\n\t\tif ( cnt === n ) {\n\t\t\tbreak;\n\t\t}\n\t}\n\treturn str.substring( 0, i );\n}\n\n\n// EXPORTS //\n\nexport default removeLast;\n"],"names":["RE_UTF16_LOW_SURROGATE","RE_UTF16_HIGH_SURROGATE","str","n","ch1","ch2","cnt","i","length","test","substring"],"mappings":";yCAsBA,IAAIA,EAAyB,kBACzBC,EAA0B,yBA4B9B,SAAqBC,EAAKC,GACzB,IACIC,EACAC,EACAC,EACAC,EACJ,GAAW,IAANJ,EACJ,OAAOD,EAMR,IAHAI,EAAM,EAGAC,EAJAL,EAAIM,OAIM,EAAGD,GAAK,EAAGA,IAAM,CAKhC,GAJAH,EAAMF,EAAKK,GACXD,GAAO,EAGFN,EAAuBS,KAAML,GAAQ,CAEzC,GAAW,IAANG,EAEJ,MAGDF,EAAMH,EAAKK,EAAE,GACRN,EAAwBQ,KAAMJ,KAElCE,GAAK,EAEN,CAED,GAAKD,IAAQH,EACZ,KAED,CACD,OAAOD,EAAIQ,UAAW,EAAGH,EAC1B"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 9860da0..0000000 --- a/lib/index.js +++ /dev/null @@ -1,43 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Remove the last `n` Unicode code points of a string. -* -* @module @stdlib/string-base-remove-last-code-point -* -* @example -* var removeLast = require( '@stdlib/string-base-remove-last-code-point' ); -* -* var out = removeLast( 'last man standing', 1 ); -* // returns 'last man standin' -* -* out = removeLast( 'Hidden Treasures', 1 ); -* // returns 'Hidden Treasure'; -*/ - -// 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 fc34187..0000000 --- a/lib/main.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// VARIABLES // - -var RE_UTF16_LOW_SURROGATE = /[\uDC00-\uDFFF]/; // TODO: replace with stdlib pkg -var RE_UTF16_HIGH_SURROGATE = /[\uD800-\uDBFF]/; // TODO: replace with stdlib pkg - - -// MAIN // - -/** -* Removes the last `n` Unicode code points of a string. -* -* @param {string} str - input string -* @param {NonNegativeInteger} n - number of Unicode code points to remove -* @returns {string} output string -* -* @example -* var out = removeLast( 'last man standing', 1 ); -* // returns 'last man standin' -* -* @example -* var out = removeLast( 'presidential election', 1 ); -* // returns 'presidential electio' -* -* @example -* var out = removeLast( 'JavaScript', 1 ); -* // returns 'JavaScrip' -* -* @example -* var out = removeLast( 'Hidden Treasures', 1 ); -* // returns 'Hidden Treasure' -*/ -function removeLast( str, n ) { - var len; - var ch1; - var ch2; - var cnt; - var i; - if ( n === 0 ) { - return str; - } - len = str.length; - cnt = 0; - - // Process the string one Unicode code unit at a time and count UTF-16 surrogate pairs as a single Unicode code point... - for ( i = len - 1; i >= 0; i-- ) { - ch1 = str[ i ]; - cnt += 1; - - // Check for a low UTF-16 surrogate... - if ( RE_UTF16_LOW_SURROGATE.test( ch1 ) ) { - // Check for an unpaired surrogate at the end of the input string... - if ( i === 0 ) { - // We found an unpaired surrogate... - break; - } - // Check whether the high surrogate is paired with a low surrogate... - ch2 = str[ i-1 ]; - if ( RE_UTF16_HIGH_SURROGATE.test( ch2 ) ) { - // We found a surrogate pair: - i -= 1; // bump the index to process the next code unit - } - } - // Check whether we've found the desired number of code points... - if ( cnt === n ) { - break; - } - } - return str.substring( 0, i ); -} - - -// EXPORTS // - -module.exports = removeLast; diff --git a/package.json b/package.json index 7d6f49d..f3c9a46 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,7 @@ "version": "0.2.1", "description": "Remove the last Unicode code point of a string.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "main": "./index.js", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,31 +12,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/error-tools-fmtprodmsg": "^0.2.1" - }, - "devDependencies": { - "@stdlib/assert-is-string": "^0.2.1", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.1" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdstring", @@ -81,4 +32,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/stats_browser.html b/stats_browser.html new file mode 100644 index 0000000..2c17dcc --- /dev/null +++ b/stats_browser.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/stats_node.html b/stats_node.html new file mode 100644 index 0000000..1e086d4 --- /dev/null +++ b/stats_node.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index a25545e..0000000 --- a/test/test.js +++ /dev/null @@ -1,108 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var removeLast = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof removeLast, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns an empty string if provided an empty string', function test( t ) { - t.strictEqual( removeLast( '', 1 ), '', 'returns expected value' ); - t.strictEqual( removeLast( '', 2 ), '', 'returns expected value' ); - t.strictEqual( removeLast( '', 3 ), '', 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns the input string if provided zero as the second argument', function test( t ) { - t.strictEqual( removeLast( 'hello world', 0 ), 'hello world', 'returns expected value' ); - t.end(); -}); - -tape( 'the function removes the last Unicode code point of a provided string (ascii)', function test( t ) { - var out; - - out = removeLast( 'hello world', 1 ); - t.strictEqual( out, 'hello worl', 'returns expected value' ); - - out = removeLast( '!!!', 1 ); - t.strictEqual( out, '!!', 'returns expected value' ); - - out = removeLast( 'Hello World', 1 ); - t.strictEqual( out, 'Hello Worl', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function removes the last Unicode code point of a provided string (Unicode)', function test( t ) { - var out; - - out = removeLast( 'अनुच्छेद', 1 ); - t.strictEqual( out, 'अनुच्छे', 'returns expected value' ); - - out = removeLast( '六书/六書', 1 ); - t.strictEqual( out, '六书/六', 'returns expected value' ); - - out = removeLast( '𐒻𐓟', 1 ); - t.strictEqual( out, '𐒻', 'returns expected value' ); - - out = removeLast( '𐒻𐓟', 1 ); - t.strictEqual( out, '𐒻', 'returns expected value' ); - - out = removeLast( '\uDC00', 1 ); - t.strictEqual( out, '', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports removing the last `n` Unicode code points of a provided string', function test( t ) { - var out; - - out = removeLast( 'hello world', 1 ); - t.strictEqual( out, 'hello worl', 'returns expected value' ); - - out = removeLast( 'hello world', 7 ); - t.strictEqual( out, 'hell', 'returns expected value' ); - - out = removeLast( '!!!', 1 ); - t.strictEqual( out, '!!', 'returns expected value' ); - - out = removeLast( '!!!', 2 ); - t.strictEqual( out, '!', 'returns expected value' ); - - out = removeLast( 'अनुच्छेद', 1 ); - t.strictEqual( out, 'अनुच्छे', 'returns expected value' ); - - out = removeLast( '六书/六書', 3 ); - t.strictEqual( out, '六书', 'returns expected value' ); - - out = removeLast( '𐒻𐓟𐓟', 2 ); - t.strictEqual( out, '𐒻', 'returns expected value' ); - - t.end(); -}); From 63b8d46f23881226c152ec764fc75ceedd68a393 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 1 May 2024 00:31:53 +0000 Subject: [PATCH 55/92] Transform error messages --- package.json | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 2bbf191..7d6f49d 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,9 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": {}, + "dependencies": { + "@stdlib/error-tools-fmtprodmsg": "^0.2.1" + }, "devDependencies": { "@stdlib/assert-is-string": "^0.2.1", "tape": "git+https://github.com/kgryte/tape.git#fix/globby", @@ -79,4 +81,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From c7cdb0791e53511e9feed78f8076c3154ebb2395 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 1 May 2024 00:41:48 +0000 Subject: [PATCH 56/92] Remove files --- browser.js | 3 - browser.js.map | 1 - index.js | 3 - index.js.map | 1 - stats_browser.html | 4842 -------------------------------------------- stats_node.html | 4842 -------------------------------------------- 6 files changed, 9692 deletions(-) delete mode 100644 browser.js delete mode 100644 browser.js.map delete mode 100644 index.js delete mode 100644 index.js.map delete mode 100644 stats_browser.html delete mode 100644 stats_node.html diff --git a/browser.js b/browser.js deleted file mode 100644 index f3a511a..0000000 --- a/browser.js +++ /dev/null @@ -1,3 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -var e,t;e=this,t=function(){"use strict";var e=/[\uDC00-\uDFFF]/,t=/[\uD800-\uDBFF]/;return function(n,f){var i,o,r,u;if(0===f)return n;for(r=0,u=n.length-1;u>=0;u--){if(i=n[u],r+=1,e.test(i)){if(0===u)break;o=n[u-1],t.test(o)&&(u-=1)}if(r===f)break}return n.substring(0,u)}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).removeLastCodePoint=t(); -//# sourceMappingURL=browser.js.map diff --git a/browser.js.map b/browser.js.map deleted file mode 100644 index 19908eb..0000000 --- a/browser.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"browser.js","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\nvar RE_UTF16_LOW_SURROGATE = /[\\uDC00-\\uDFFF]/; // TODO: replace with stdlib pkg\nvar RE_UTF16_HIGH_SURROGATE = /[\\uD800-\\uDBFF]/; // TODO: replace with stdlib pkg\n\n\n// MAIN //\n\n/**\n* Removes the last `n` Unicode code points of a string.\n*\n* @param {string} str - input string\n* @param {NonNegativeInteger} n - number of Unicode code points to remove\n* @returns {string} output string\n*\n* @example\n* var out = removeLast( 'last man standing', 1 );\n* // returns 'last man standin'\n*\n* @example\n* var out = removeLast( 'presidential election', 1 );\n* // returns 'presidential electio'\n*\n* @example\n* var out = removeLast( 'JavaScript', 1 );\n* // returns 'JavaScrip'\n*\n* @example\n* var out = removeLast( 'Hidden Treasures', 1 );\n* // returns 'Hidden Treasure'\n*/\nfunction removeLast( str, n ) {\n\tvar len;\n\tvar ch1;\n\tvar ch2;\n\tvar cnt;\n\tvar i;\n\tif ( n === 0 ) {\n\t\treturn str;\n\t}\n\tlen = str.length;\n\tcnt = 0;\n\n\t// Process the string one Unicode code unit at a time and count UTF-16 surrogate pairs as a single Unicode code point...\n\tfor ( i = len - 1; i >= 0; i-- ) {\n\t\tch1 = str[ i ];\n\t\tcnt += 1;\n\n\t\t// Check for a low UTF-16 surrogate...\n\t\tif ( RE_UTF16_LOW_SURROGATE.test( ch1 ) ) {\n\t\t\t// Check for an unpaired surrogate at the end of the input string...\n\t\t\tif ( i === 0 ) {\n\t\t\t\t// We found an unpaired surrogate...\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\t// Check whether the high surrogate is paired with a low surrogate...\n\t\t\tch2 = str[ i-1 ];\n\t\t\tif ( RE_UTF16_HIGH_SURROGATE.test( ch2 ) ) {\n\t\t\t\t// We found a surrogate pair:\n\t\t\t\ti -= 1; // bump the index to process the next code unit\n\t\t\t}\n\t\t}\n\t\t// Check whether we've found the desired number of code points...\n\t\tif ( cnt === n ) {\n\t\t\tbreak;\n\t\t}\n\t}\n\treturn str.substring( 0, i );\n}\n\n\n// EXPORTS //\n\nexport default removeLast;\n"],"names":["RE_UTF16_LOW_SURROGATE","RE_UTF16_HIGH_SURROGATE","str","n","ch1","ch2","cnt","i","length","test","substring"],"mappings":";yCAsBA,IAAIA,EAAyB,kBACzBC,EAA0B,yBA4B9B,SAAqBC,EAAKC,GACzB,IACIC,EACAC,EACAC,EACAC,EACJ,GAAW,IAANJ,EACJ,OAAOD,EAMR,IAHAI,EAAM,EAGAC,EAJAL,EAAIM,OAIM,EAAGD,GAAK,EAAGA,IAAM,CAKhC,GAJAH,EAAMF,EAAKK,GACXD,GAAO,EAGFN,EAAuBS,KAAML,GAAQ,CAEzC,GAAW,IAANG,EAEJ,MAGDF,EAAMH,EAAKK,EAAE,GACRN,EAAwBQ,KAAMJ,KAElCE,GAAK,EAEN,CAED,GAAKD,IAAQH,EACZ,KAED,CACD,OAAOD,EAAIQ,UAAW,EAAGH,EAC1B"} \ No newline at end of file diff --git a/index.js b/index.js deleted file mode 100644 index 4e500d1..0000000 --- a/index.js +++ /dev/null @@ -1,3 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -var e,t;e=this,t=function(){"use strict";var e=/[\uDC00-\uDFFF]/,t=/[\uD800-\uDBFF]/;return function(n,f){var i,o,r,u;if(0===f)return n;for(r=0,u=n.length-1;u>=0;u--){if(i=n[u],r+=1,e.test(i)){if(0===u)break;o=n[u-1],t.test(o)&&(u-=1)}if(r===f)break}return n.substring(0,u)}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).removeLastCodePoint=t(); -//# sourceMappingURL=index.js.map diff --git a/index.js.map b/index.js.map deleted file mode 100644 index d557af8..0000000 --- a/index.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.js","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\nvar RE_UTF16_LOW_SURROGATE = /[\\uDC00-\\uDFFF]/; // TODO: replace with stdlib pkg\nvar RE_UTF16_HIGH_SURROGATE = /[\\uD800-\\uDBFF]/; // TODO: replace with stdlib pkg\n\n\n// MAIN //\n\n/**\n* Removes the last `n` Unicode code points of a string.\n*\n* @param {string} str - input string\n* @param {NonNegativeInteger} n - number of Unicode code points to remove\n* @returns {string} output string\n*\n* @example\n* var out = removeLast( 'last man standing', 1 );\n* // returns 'last man standin'\n*\n* @example\n* var out = removeLast( 'presidential election', 1 );\n* // returns 'presidential electio'\n*\n* @example\n* var out = removeLast( 'JavaScript', 1 );\n* // returns 'JavaScrip'\n*\n* @example\n* var out = removeLast( 'Hidden Treasures', 1 );\n* // returns 'Hidden Treasure'\n*/\nfunction removeLast( str, n ) {\n\tvar len;\n\tvar ch1;\n\tvar ch2;\n\tvar cnt;\n\tvar i;\n\tif ( n === 0 ) {\n\t\treturn str;\n\t}\n\tlen = str.length;\n\tcnt = 0;\n\n\t// Process the string one Unicode code unit at a time and count UTF-16 surrogate pairs as a single Unicode code point...\n\tfor ( i = len - 1; i >= 0; i-- ) {\n\t\tch1 = str[ i ];\n\t\tcnt += 1;\n\n\t\t// Check for a low UTF-16 surrogate...\n\t\tif ( RE_UTF16_LOW_SURROGATE.test( ch1 ) ) {\n\t\t\t// Check for an unpaired surrogate at the end of the input string...\n\t\t\tif ( i === 0 ) {\n\t\t\t\t// We found an unpaired surrogate...\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\t// Check whether the high surrogate is paired with a low surrogate...\n\t\t\tch2 = str[ i-1 ];\n\t\t\tif ( RE_UTF16_HIGH_SURROGATE.test( ch2 ) ) {\n\t\t\t\t// We found a surrogate pair:\n\t\t\t\ti -= 1; // bump the index to process the next code unit\n\t\t\t}\n\t\t}\n\t\t// Check whether we've found the desired number of code points...\n\t\tif ( cnt === n ) {\n\t\t\tbreak;\n\t\t}\n\t}\n\treturn str.substring( 0, i );\n}\n\n\n// EXPORTS //\n\nexport default removeLast;\n"],"names":["RE_UTF16_LOW_SURROGATE","RE_UTF16_HIGH_SURROGATE","str","n","ch1","ch2","cnt","i","length","test","substring"],"mappings":";yCAsBA,IAAIA,EAAyB,kBACzBC,EAA0B,yBA4B9B,SAAqBC,EAAKC,GACzB,IACIC,EACAC,EACAC,EACAC,EACJ,GAAW,IAANJ,EACJ,OAAOD,EAMR,IAHAI,EAAM,EAGAC,EAJAL,EAAIM,OAIM,EAAGD,GAAK,EAAGA,IAAM,CAKhC,GAJAH,EAAMF,EAAKK,GACXD,GAAO,EAGFN,EAAuBS,KAAML,GAAQ,CAEzC,GAAW,IAANG,EAEJ,MAGDF,EAAMH,EAAKK,EAAE,GACRN,EAAwBQ,KAAMJ,KAElCE,GAAK,EAEN,CAED,GAAKD,IAAQH,EACZ,KAED,CACD,OAAOD,EAAIQ,UAAW,EAAGH,EAC1B"} \ No newline at end of file diff --git a/stats_browser.html b/stats_browser.html deleted file mode 100644 index 2c17dcc..0000000 --- a/stats_browser.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - diff --git a/stats_node.html b/stats_node.html deleted file mode 100644 index 1e086d4..0000000 --- a/stats_node.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 53b6fafd35eece9651d3791187adf27ec8f6d4e9 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 1 May 2024 00:42:05 +0000 Subject: [PATCH 57/92] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 66 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 794 ---- .github/workflows/publish.yml | 248 -- .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .gitignore | 188 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 52 +- SECURITY.md | 5 - benchmark/benchmark.js | 56 - branches.md | 56 - browser.js | 3 + browser.js.map | 1 + dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 29 - docs/types/index.d.ts | 53 - docs/types/test.ts | 57 - examples/index.js | 33 - index.js | 3 + index.js.map | 1 + lib/index.js | 43 - lib/main.js | 94 - package.json | 53 +- stats_browser.html | 4842 +++++++++++++++++++++ stats_node.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 108 - 46 files changed, 9728 insertions(+), 3826 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md create mode 100644 browser.js create mode 100644 browser.js.map 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/index.d.ts delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js create mode 100644 index.js create mode 100644 index.js.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats_browser.html create mode 100644 stats_node.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 68a0dae..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-05-01T00:30:55.883Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 52cd9c4..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/base/remove-last-code-point) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 533eeee..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/base/remove-last-code-point) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 2a724f2..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: '29 5 * * 0' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index f92a6c5..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,794 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n +``` -```javascript -var removeLastCodePoint = require( '@stdlib/string-base-remove-last-code-point' ); +If no recognized module system is present, access bundle contents via the global scope: + +```html + ``` #### removeLastCodePoint( str, n ) @@ -91,8 +97,13 @@ out = removeLastCodePoint( 'foo bar', 10 ); -```javascript -var removeLastCodePoint = require( '@stdlib/string-base-remove-last-code-point' ); +```html + + + + + + + ```
diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index a39bd29..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,56 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var removeLast = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var values; - var out; - var i; - - values = [ - 'beep boop', - 'foo bar', - 'xyz abc', - '🐶🐮🐷🐰🐸' - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = removeLast( values[ i%values.length ], 1 ); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( !isString( out ) ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index f585c99..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/base/remove-last-code-point" -%% click B href "https://github.com/stdlib-js/string-base-remove-last-code-point/tree/main" -%% click C href "https://github.com/stdlib-js/string-base-remove-last-code-point/tree/production" -%% click D href "https://github.com/stdlib-js/string-base-remove-last-code-point/tree/esm" -%% click E href "https://github.com/stdlib-js/string-base-remove-last-code-point/tree/deno" -%% click F href "https://github.com/stdlib-js/string-base-remove-last-code-point/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/base/remove-last-code-point -[production-url]: https://github.com/stdlib-js/string-base-remove-last-code-point/tree/production -[deno-url]: https://github.com/stdlib-js/string-base-remove-last-code-point/tree/deno -[deno-readme]: https://github.com/stdlib-js/string-base-remove-last-code-point/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/string-base-remove-last-code-point/tree/umd -[umd-readme]: https://github.com/stdlib-js/string-base-remove-last-code-point/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/string-base-remove-last-code-point/tree/esm -[esm-readme]: https://github.com/stdlib-js/string-base-remove-last-code-point/blob/esm/README.md \ No newline at end of file diff --git a/browser.js b/browser.js new file mode 100644 index 0000000..f3a511a --- /dev/null +++ b/browser.js @@ -0,0 +1,3 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +var e,t;e=this,t=function(){"use strict";var e=/[\uDC00-\uDFFF]/,t=/[\uD800-\uDBFF]/;return function(n,f){var i,o,r,u;if(0===f)return n;for(r=0,u=n.length-1;u>=0;u--){if(i=n[u],r+=1,e.test(i)){if(0===u)break;o=n[u-1],t.test(o)&&(u-=1)}if(r===f)break}return n.substring(0,u)}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).removeLastCodePoint=t(); +//# sourceMappingURL=browser.js.map diff --git a/browser.js.map b/browser.js.map new file mode 100644 index 0000000..19908eb --- /dev/null +++ b/browser.js.map @@ -0,0 +1 @@ +{"version":3,"file":"browser.js","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\nvar RE_UTF16_LOW_SURROGATE = /[\\uDC00-\\uDFFF]/; // TODO: replace with stdlib pkg\nvar RE_UTF16_HIGH_SURROGATE = /[\\uD800-\\uDBFF]/; // TODO: replace with stdlib pkg\n\n\n// MAIN //\n\n/**\n* Removes the last `n` Unicode code points of a string.\n*\n* @param {string} str - input string\n* @param {NonNegativeInteger} n - number of Unicode code points to remove\n* @returns {string} output string\n*\n* @example\n* var out = removeLast( 'last man standing', 1 );\n* // returns 'last man standin'\n*\n* @example\n* var out = removeLast( 'presidential election', 1 );\n* // returns 'presidential electio'\n*\n* @example\n* var out = removeLast( 'JavaScript', 1 );\n* // returns 'JavaScrip'\n*\n* @example\n* var out = removeLast( 'Hidden Treasures', 1 );\n* // returns 'Hidden Treasure'\n*/\nfunction removeLast( str, n ) {\n\tvar len;\n\tvar ch1;\n\tvar ch2;\n\tvar cnt;\n\tvar i;\n\tif ( n === 0 ) {\n\t\treturn str;\n\t}\n\tlen = str.length;\n\tcnt = 0;\n\n\t// Process the string one Unicode code unit at a time and count UTF-16 surrogate pairs as a single Unicode code point...\n\tfor ( i = len - 1; i >= 0; i-- ) {\n\t\tch1 = str[ i ];\n\t\tcnt += 1;\n\n\t\t// Check for a low UTF-16 surrogate...\n\t\tif ( RE_UTF16_LOW_SURROGATE.test( ch1 ) ) {\n\t\t\t// Check for an unpaired surrogate at the end of the input string...\n\t\t\tif ( i === 0 ) {\n\t\t\t\t// We found an unpaired surrogate...\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\t// Check whether the high surrogate is paired with a low surrogate...\n\t\t\tch2 = str[ i-1 ];\n\t\t\tif ( RE_UTF16_HIGH_SURROGATE.test( ch2 ) ) {\n\t\t\t\t// We found a surrogate pair:\n\t\t\t\ti -= 1; // bump the index to process the next code unit\n\t\t\t}\n\t\t}\n\t\t// Check whether we've found the desired number of code points...\n\t\tif ( cnt === n ) {\n\t\t\tbreak;\n\t\t}\n\t}\n\treturn str.substring( 0, i );\n}\n\n\n// EXPORTS //\n\nexport default removeLast;\n"],"names":["RE_UTF16_LOW_SURROGATE","RE_UTF16_HIGH_SURROGATE","str","n","ch1","ch2","cnt","i","length","test","substring"],"mappings":";yCAsBA,IAAIA,EAAyB,kBACzBC,EAA0B,yBA4B9B,SAAqBC,EAAKC,GACzB,IACIC,EACAC,EACAC,EACAC,EACJ,GAAW,IAANJ,EACJ,OAAOD,EAMR,IAHAI,EAAM,EAGAC,EAJAL,EAAIM,OAIM,EAAGD,GAAK,EAAGA,IAAM,CAKhC,GAJAH,EAAMF,EAAKK,GACXD,GAAO,EAGFN,EAAuBS,KAAML,GAAQ,CAEzC,GAAW,IAANG,EAEJ,MAGDF,EAAMH,EAAKK,EAAE,GACRN,EAAwBQ,KAAMJ,KAElCE,GAAK,EAEN,CAED,GAAKD,IAAQH,EACZ,KAED,CACD,OAAOD,EAAIQ,UAAW,EAAGH,EAC1B"} \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index 8c96fd7..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import removeLast from '../docs/types/index'; -export = removeLast; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index e6b7220..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var s=function(e,t){return function(){return t||e((t={exports:{}}).exports,t),t.exports}};var f=s(function(D,n){ -var F=/[\uDC00-\uDFFF]/,c=/[\uD800-\uDBFF]/;function R(e,t){var i,u,v,a,r;if(t===0)return e;for(i=e.length,a=0,r=i-1;r>=0;r--){if(u=e[r],a+=1,F.test(u)){if(r===0)break;v=e[r-1],c.test(v)&&(r-=1)}if(a===t)break}return e.substring(0,r)}n.exports=R -});var _=f();module.exports=_; -/** @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 72561cf..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\nvar RE_UTF16_LOW_SURROGATE = /[\\uDC00-\\uDFFF]/; // TODO: replace with stdlib pkg\nvar RE_UTF16_HIGH_SURROGATE = /[\\uD800-\\uDBFF]/; // TODO: replace with stdlib pkg\n\n\n// MAIN //\n\n/**\n* Removes the last `n` Unicode code points of a string.\n*\n* @param {string} str - input string\n* @param {NonNegativeInteger} n - number of Unicode code points to remove\n* @returns {string} output string\n*\n* @example\n* var out = removeLast( 'last man standing', 1 );\n* // returns 'last man standin'\n*\n* @example\n* var out = removeLast( 'presidential election', 1 );\n* // returns 'presidential electio'\n*\n* @example\n* var out = removeLast( 'JavaScript', 1 );\n* // returns 'JavaScrip'\n*\n* @example\n* var out = removeLast( 'Hidden Treasures', 1 );\n* // returns 'Hidden Treasure'\n*/\nfunction removeLast( str, n ) {\n\tvar len;\n\tvar ch1;\n\tvar ch2;\n\tvar cnt;\n\tvar i;\n\tif ( n === 0 ) {\n\t\treturn str;\n\t}\n\tlen = str.length;\n\tcnt = 0;\n\n\t// Process the string one Unicode code unit at a time and count UTF-16 surrogate pairs as a single Unicode code point...\n\tfor ( i = len - 1; i >= 0; i-- ) {\n\t\tch1 = str[ i ];\n\t\tcnt += 1;\n\n\t\t// Check for a low UTF-16 surrogate...\n\t\tif ( RE_UTF16_LOW_SURROGATE.test( ch1 ) ) {\n\t\t\t// Check for an unpaired surrogate at the end of the input string...\n\t\t\tif ( i === 0 ) {\n\t\t\t\t// We found an unpaired surrogate...\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\t// Check whether the high surrogate is paired with a low surrogate...\n\t\t\tch2 = str[ i-1 ];\n\t\t\tif ( RE_UTF16_HIGH_SURROGATE.test( ch2 ) ) {\n\t\t\t\t// We found a surrogate pair:\n\t\t\t\ti -= 1; // bump the index to process the next code unit\n\t\t\t}\n\t\t}\n\t\t// Check whether we've found the desired number of code points...\n\t\tif ( cnt === n ) {\n\t\t\tbreak;\n\t\t}\n\t}\n\treturn str.substring( 0, i );\n}\n\n\n// EXPORTS //\n\nmodule.exports = removeLast;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Remove the last `n` Unicode code points of a string.\n*\n* @module @stdlib/string-base-remove-last-code-point\n*\n* @example\n* var removeLast = require( '@stdlib/string-base-remove-last-code-point' );\n*\n* var out = removeLast( 'last man standing', 1 );\n* // returns 'last man standin'\n*\n* out = removeLast( 'Hidden Treasures', 1 );\n* // returns 'Hidden Treasure';\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,EAAyB,kBACzBC,EAA0B,kBA4B9B,SAASC,EAAYC,EAAKC,EAAI,CAC7B,IAAIC,EACAC,EACAC,EACAC,EACAC,EACJ,GAAKL,IAAM,EACV,OAAOD,EAMR,IAJAE,EAAMF,EAAI,OACVK,EAAM,EAGAC,EAAIJ,EAAM,EAAGI,GAAK,EAAGA,IAAM,CAKhC,GAJAH,EAAMH,EAAKM,CAAE,EACbD,GAAO,EAGFR,EAAuB,KAAMM,CAAI,EAAI,CAEzC,GAAKG,IAAM,EAEV,MAGDF,EAAMJ,EAAKM,EAAE,CAAE,EACVR,EAAwB,KAAMM,CAAI,IAEtCE,GAAK,EAEP,CAEA,GAAKD,IAAQJ,EACZ,KAEF,CACA,OAAOD,EAAI,UAAW,EAAGM,CAAE,CAC5B,CAKAV,EAAO,QAAUG,ICxDjB,IAAIQ,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "RE_UTF16_LOW_SURROGATE", "RE_UTF16_HIGH_SURROGATE", "removeLast", "str", "n", "len", "ch1", "ch2", "cnt", "i", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index a08ea55..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,29 +0,0 @@ - -{{alias}}( str, n ) - Removes the last `n` Unicode code points of a string. - - Parameters - ---------- - str: string - Input string. - - n: integer - Number of Unicode code points to remove. - - Returns - ------- - out: string - Output string. - - Examples - -------- - > var out = {{alias}}( 'beep', 1 ) - 'bee' - > out = {{alias}}( 'Boop', 1 ) - 'Boo' - > out = {{alias}}( 'foo bar', 5 ) - 'fo' - - See Also - -------- - diff --git a/docs/types/index.d.ts b/docs/types/index.d.ts deleted file mode 100644 index 8a1c90b..0000000 --- a/docs/types/index.d.ts +++ /dev/null @@ -1,53 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 - -/** -* Removes the last `n` Unicode code points of a string. -* -* @param str - input string -* @param n - number of code points to remove -* @returns output string -* -* @example -* var out = removeLast( 'last man standing', 1 ); -* // returns 'last man standin' -* -* @example -* var out = removeLast( 'presidential election', 1 ); -* // returns 'presidential electio' -* -* @example -* var out = removeLast( 'JavaScript', 1 ); -* // returns 'JavaScrip' -* -* @example -* var out = removeLast( 'Hidden Treasures', 1 ); -* // returns 'Hidden Treasure' -* -* @example -* var out = removeLast( 'foo bar', 5 ); -* // returns 'fo' -*/ -declare function removeLast( str: string, n: number ): string; - - -// EXPORTS // - -export = removeLast; diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index fd426d2..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,57 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 removeLast = require( './index' ); - - -// TESTS // - -// The function returns a string... -{ - removeLast( 'abc', 1 ); // $ExpectType string -} - -// The compiler throws an error if the function is provided a value other than a string... -{ - removeLast( true, 1 ); // $ExpectError - removeLast( false, 1 ); // $ExpectError - removeLast( null, 1 ); // $ExpectError - removeLast( undefined, 1 ); // $ExpectError - removeLast( 5, 1 ); // $ExpectError - removeLast( [], 1 ); // $ExpectError - removeLast( {}, 1 ); // $ExpectError - removeLast( ( x: number ): number => x, 1 ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument that is not a number... -{ - removeLast( 'abc', true ); // $ExpectError - removeLast( 'abc', false ); // $ExpectError - removeLast( 'abc', null ); // $ExpectError - removeLast( 'abc', 'abc' ); // $ExpectError - removeLast( 'abc', [] ); // $ExpectError - removeLast( 'abc', {} ); // $ExpectError - removeLast( 'abc', ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - removeLast(); // $ExpectError - removeLast( 'abc' ); // $ExpectError - removeLast( 'abc', 1, 2 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 085633e..0000000 --- a/examples/index.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var removeLastCodePoint = require( './../lib' ); - -console.log( removeLastCodePoint( 'presidential election', 1 ) ); -// => 'presidential electio' - -console.log( removeLastCodePoint( 'JavaScript', 1 ) ); -// => 'JavaScrip' - -console.log( removeLastCodePoint( 'The Last of the Mohicans', 5 ) ); -// => 'The Last of the Moh' - -console.log( removeLastCodePoint( 'अनुच्छेद', 1 ) ); -// => 'अनुच्छे' diff --git a/index.js b/index.js new file mode 100644 index 0000000..4e500d1 --- /dev/null +++ b/index.js @@ -0,0 +1,3 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +var e,t;e=this,t=function(){"use strict";var e=/[\uDC00-\uDFFF]/,t=/[\uD800-\uDBFF]/;return function(n,f){var i,o,r,u;if(0===f)return n;for(r=0,u=n.length-1;u>=0;u--){if(i=n[u],r+=1,e.test(i)){if(0===u)break;o=n[u-1],t.test(o)&&(u-=1)}if(r===f)break}return n.substring(0,u)}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).removeLastCodePoint=t(); +//# sourceMappingURL=index.js.map diff --git a/index.js.map b/index.js.map new file mode 100644 index 0000000..d557af8 --- /dev/null +++ b/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\nvar RE_UTF16_LOW_SURROGATE = /[\\uDC00-\\uDFFF]/; // TODO: replace with stdlib pkg\nvar RE_UTF16_HIGH_SURROGATE = /[\\uD800-\\uDBFF]/; // TODO: replace with stdlib pkg\n\n\n// MAIN //\n\n/**\n* Removes the last `n` Unicode code points of a string.\n*\n* @param {string} str - input string\n* @param {NonNegativeInteger} n - number of Unicode code points to remove\n* @returns {string} output string\n*\n* @example\n* var out = removeLast( 'last man standing', 1 );\n* // returns 'last man standin'\n*\n* @example\n* var out = removeLast( 'presidential election', 1 );\n* // returns 'presidential electio'\n*\n* @example\n* var out = removeLast( 'JavaScript', 1 );\n* // returns 'JavaScrip'\n*\n* @example\n* var out = removeLast( 'Hidden Treasures', 1 );\n* // returns 'Hidden Treasure'\n*/\nfunction removeLast( str, n ) {\n\tvar len;\n\tvar ch1;\n\tvar ch2;\n\tvar cnt;\n\tvar i;\n\tif ( n === 0 ) {\n\t\treturn str;\n\t}\n\tlen = str.length;\n\tcnt = 0;\n\n\t// Process the string one Unicode code unit at a time and count UTF-16 surrogate pairs as a single Unicode code point...\n\tfor ( i = len - 1; i >= 0; i-- ) {\n\t\tch1 = str[ i ];\n\t\tcnt += 1;\n\n\t\t// Check for a low UTF-16 surrogate...\n\t\tif ( RE_UTF16_LOW_SURROGATE.test( ch1 ) ) {\n\t\t\t// Check for an unpaired surrogate at the end of the input string...\n\t\t\tif ( i === 0 ) {\n\t\t\t\t// We found an unpaired surrogate...\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\t// Check whether the high surrogate is paired with a low surrogate...\n\t\t\tch2 = str[ i-1 ];\n\t\t\tif ( RE_UTF16_HIGH_SURROGATE.test( ch2 ) ) {\n\t\t\t\t// We found a surrogate pair:\n\t\t\t\ti -= 1; // bump the index to process the next code unit\n\t\t\t}\n\t\t}\n\t\t// Check whether we've found the desired number of code points...\n\t\tif ( cnt === n ) {\n\t\t\tbreak;\n\t\t}\n\t}\n\treturn str.substring( 0, i );\n}\n\n\n// EXPORTS //\n\nexport default removeLast;\n"],"names":["RE_UTF16_LOW_SURROGATE","RE_UTF16_HIGH_SURROGATE","str","n","ch1","ch2","cnt","i","length","test","substring"],"mappings":";yCAsBA,IAAIA,EAAyB,kBACzBC,EAA0B,yBA4B9B,SAAqBC,EAAKC,GACzB,IACIC,EACAC,EACAC,EACAC,EACJ,GAAW,IAANJ,EACJ,OAAOD,EAMR,IAHAI,EAAM,EAGAC,EAJAL,EAAIM,OAIM,EAAGD,GAAK,EAAGA,IAAM,CAKhC,GAJAH,EAAMF,EAAKK,GACXD,GAAO,EAGFN,EAAuBS,KAAML,GAAQ,CAEzC,GAAW,IAANG,EAEJ,MAGDF,EAAMH,EAAKK,EAAE,GACRN,EAAwBQ,KAAMJ,KAElCE,GAAK,EAEN,CAED,GAAKD,IAAQH,EACZ,KAED,CACD,OAAOD,EAAIQ,UAAW,EAAGH,EAC1B"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 9860da0..0000000 --- a/lib/index.js +++ /dev/null @@ -1,43 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Remove the last `n` Unicode code points of a string. -* -* @module @stdlib/string-base-remove-last-code-point -* -* @example -* var removeLast = require( '@stdlib/string-base-remove-last-code-point' ); -* -* var out = removeLast( 'last man standing', 1 ); -* // returns 'last man standin' -* -* out = removeLast( 'Hidden Treasures', 1 ); -* // returns 'Hidden Treasure'; -*/ - -// 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 fc34187..0000000 --- a/lib/main.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// VARIABLES // - -var RE_UTF16_LOW_SURROGATE = /[\uDC00-\uDFFF]/; // TODO: replace with stdlib pkg -var RE_UTF16_HIGH_SURROGATE = /[\uD800-\uDBFF]/; // TODO: replace with stdlib pkg - - -// MAIN // - -/** -* Removes the last `n` Unicode code points of a string. -* -* @param {string} str - input string -* @param {NonNegativeInteger} n - number of Unicode code points to remove -* @returns {string} output string -* -* @example -* var out = removeLast( 'last man standing', 1 ); -* // returns 'last man standin' -* -* @example -* var out = removeLast( 'presidential election', 1 ); -* // returns 'presidential electio' -* -* @example -* var out = removeLast( 'JavaScript', 1 ); -* // returns 'JavaScrip' -* -* @example -* var out = removeLast( 'Hidden Treasures', 1 ); -* // returns 'Hidden Treasure' -*/ -function removeLast( str, n ) { - var len; - var ch1; - var ch2; - var cnt; - var i; - if ( n === 0 ) { - return str; - } - len = str.length; - cnt = 0; - - // Process the string one Unicode code unit at a time and count UTF-16 surrogate pairs as a single Unicode code point... - for ( i = len - 1; i >= 0; i-- ) { - ch1 = str[ i ]; - cnt += 1; - - // Check for a low UTF-16 surrogate... - if ( RE_UTF16_LOW_SURROGATE.test( ch1 ) ) { - // Check for an unpaired surrogate at the end of the input string... - if ( i === 0 ) { - // We found an unpaired surrogate... - break; - } - // Check whether the high surrogate is paired with a low surrogate... - ch2 = str[ i-1 ]; - if ( RE_UTF16_HIGH_SURROGATE.test( ch2 ) ) { - // We found a surrogate pair: - i -= 1; // bump the index to process the next code unit - } - } - // Check whether we've found the desired number of code points... - if ( cnt === n ) { - break; - } - } - return str.substring( 0, i ); -} - - -// EXPORTS // - -module.exports = removeLast; diff --git a/package.json b/package.json index 7d6f49d..f3c9a46 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,7 @@ "version": "0.2.1", "description": "Remove the last Unicode code point of a string.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "main": "./index.js", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,31 +12,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/error-tools-fmtprodmsg": "^0.2.1" - }, - "devDependencies": { - "@stdlib/assert-is-string": "^0.2.1", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.1" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdstring", @@ -81,4 +32,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/stats_browser.html b/stats_browser.html new file mode 100644 index 0000000..2c17dcc --- /dev/null +++ b/stats_browser.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/stats_node.html b/stats_node.html new file mode 100644 index 0000000..1e086d4 --- /dev/null +++ b/stats_node.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index a25545e..0000000 --- a/test/test.js +++ /dev/null @@ -1,108 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var removeLast = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof removeLast, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns an empty string if provided an empty string', function test( t ) { - t.strictEqual( removeLast( '', 1 ), '', 'returns expected value' ); - t.strictEqual( removeLast( '', 2 ), '', 'returns expected value' ); - t.strictEqual( removeLast( '', 3 ), '', 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns the input string if provided zero as the second argument', function test( t ) { - t.strictEqual( removeLast( 'hello world', 0 ), 'hello world', 'returns expected value' ); - t.end(); -}); - -tape( 'the function removes the last Unicode code point of a provided string (ascii)', function test( t ) { - var out; - - out = removeLast( 'hello world', 1 ); - t.strictEqual( out, 'hello worl', 'returns expected value' ); - - out = removeLast( '!!!', 1 ); - t.strictEqual( out, '!!', 'returns expected value' ); - - out = removeLast( 'Hello World', 1 ); - t.strictEqual( out, 'Hello Worl', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function removes the last Unicode code point of a provided string (Unicode)', function test( t ) { - var out; - - out = removeLast( 'अनुच्छेद', 1 ); - t.strictEqual( out, 'अनुच्छे', 'returns expected value' ); - - out = removeLast( '六书/六書', 1 ); - t.strictEqual( out, '六书/六', 'returns expected value' ); - - out = removeLast( '𐒻𐓟', 1 ); - t.strictEqual( out, '𐒻', 'returns expected value' ); - - out = removeLast( '𐒻𐓟', 1 ); - t.strictEqual( out, '𐒻', 'returns expected value' ); - - out = removeLast( '\uDC00', 1 ); - t.strictEqual( out, '', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports removing the last `n` Unicode code points of a provided string', function test( t ) { - var out; - - out = removeLast( 'hello world', 1 ); - t.strictEqual( out, 'hello worl', 'returns expected value' ); - - out = removeLast( 'hello world', 7 ); - t.strictEqual( out, 'hell', 'returns expected value' ); - - out = removeLast( '!!!', 1 ); - t.strictEqual( out, '!!', 'returns expected value' ); - - out = removeLast( '!!!', 2 ); - t.strictEqual( out, '!', 'returns expected value' ); - - out = removeLast( 'अनुच्छेद', 1 ); - t.strictEqual( out, 'अनुच्छे', 'returns expected value' ); - - out = removeLast( '六书/六書', 3 ); - t.strictEqual( out, '六书', 'returns expected value' ); - - out = removeLast( '𐒻𐓟𐓟', 2 ); - t.strictEqual( out, '𐒻', 'returns expected value' ); - - t.end(); -}); From 4b11b34003c70f6a8f03570c297f659dc7ac68b6 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 1 Jun 2024 00:33:25 +0000 Subject: [PATCH 58/92] Transform error messages --- package.json | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 2bbf191..7d6f49d 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,9 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": {}, + "dependencies": { + "@stdlib/error-tools-fmtprodmsg": "^0.2.1" + }, "devDependencies": { "@stdlib/assert-is-string": "^0.2.1", "tape": "git+https://github.com/kgryte/tape.git#fix/globby", @@ -79,4 +81,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From eff8bf6d6785531e07b9741296537db4f2a5ca51 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 1 Jun 2024 00:40:42 +0000 Subject: [PATCH 59/92] Remove files --- browser.js | 3 - browser.js.map | 1 - index.js | 3 - index.js.map | 1 - stats_browser.html | 4842 -------------------------------------------- stats_node.html | 4842 -------------------------------------------- 6 files changed, 9692 deletions(-) delete mode 100644 browser.js delete mode 100644 browser.js.map delete mode 100644 index.js delete mode 100644 index.js.map delete mode 100644 stats_browser.html delete mode 100644 stats_node.html diff --git a/browser.js b/browser.js deleted file mode 100644 index f3a511a..0000000 --- a/browser.js +++ /dev/null @@ -1,3 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -var e,t;e=this,t=function(){"use strict";var e=/[\uDC00-\uDFFF]/,t=/[\uD800-\uDBFF]/;return function(n,f){var i,o,r,u;if(0===f)return n;for(r=0,u=n.length-1;u>=0;u--){if(i=n[u],r+=1,e.test(i)){if(0===u)break;o=n[u-1],t.test(o)&&(u-=1)}if(r===f)break}return n.substring(0,u)}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).removeLastCodePoint=t(); -//# sourceMappingURL=browser.js.map diff --git a/browser.js.map b/browser.js.map deleted file mode 100644 index 19908eb..0000000 --- a/browser.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"browser.js","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\nvar RE_UTF16_LOW_SURROGATE = /[\\uDC00-\\uDFFF]/; // TODO: replace with stdlib pkg\nvar RE_UTF16_HIGH_SURROGATE = /[\\uD800-\\uDBFF]/; // TODO: replace with stdlib pkg\n\n\n// MAIN //\n\n/**\n* Removes the last `n` Unicode code points of a string.\n*\n* @param {string} str - input string\n* @param {NonNegativeInteger} n - number of Unicode code points to remove\n* @returns {string} output string\n*\n* @example\n* var out = removeLast( 'last man standing', 1 );\n* // returns 'last man standin'\n*\n* @example\n* var out = removeLast( 'presidential election', 1 );\n* // returns 'presidential electio'\n*\n* @example\n* var out = removeLast( 'JavaScript', 1 );\n* // returns 'JavaScrip'\n*\n* @example\n* var out = removeLast( 'Hidden Treasures', 1 );\n* // returns 'Hidden Treasure'\n*/\nfunction removeLast( str, n ) {\n\tvar len;\n\tvar ch1;\n\tvar ch2;\n\tvar cnt;\n\tvar i;\n\tif ( n === 0 ) {\n\t\treturn str;\n\t}\n\tlen = str.length;\n\tcnt = 0;\n\n\t// Process the string one Unicode code unit at a time and count UTF-16 surrogate pairs as a single Unicode code point...\n\tfor ( i = len - 1; i >= 0; i-- ) {\n\t\tch1 = str[ i ];\n\t\tcnt += 1;\n\n\t\t// Check for a low UTF-16 surrogate...\n\t\tif ( RE_UTF16_LOW_SURROGATE.test( ch1 ) ) {\n\t\t\t// Check for an unpaired surrogate at the end of the input string...\n\t\t\tif ( i === 0 ) {\n\t\t\t\t// We found an unpaired surrogate...\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\t// Check whether the high surrogate is paired with a low surrogate...\n\t\t\tch2 = str[ i-1 ];\n\t\t\tif ( RE_UTF16_HIGH_SURROGATE.test( ch2 ) ) {\n\t\t\t\t// We found a surrogate pair:\n\t\t\t\ti -= 1; // bump the index to process the next code unit\n\t\t\t}\n\t\t}\n\t\t// Check whether we've found the desired number of code points...\n\t\tif ( cnt === n ) {\n\t\t\tbreak;\n\t\t}\n\t}\n\treturn str.substring( 0, i );\n}\n\n\n// EXPORTS //\n\nexport default removeLast;\n"],"names":["RE_UTF16_LOW_SURROGATE","RE_UTF16_HIGH_SURROGATE","str","n","ch1","ch2","cnt","i","length","test","substring"],"mappings":";yCAsBA,IAAIA,EAAyB,kBACzBC,EAA0B,yBA4B9B,SAAqBC,EAAKC,GACzB,IACIC,EACAC,EACAC,EACAC,EACJ,GAAW,IAANJ,EACJ,OAAOD,EAMR,IAHAI,EAAM,EAGAC,EAJAL,EAAIM,OAIM,EAAGD,GAAK,EAAGA,IAAM,CAKhC,GAJAH,EAAMF,EAAKK,GACXD,GAAO,EAGFN,EAAuBS,KAAML,GAAQ,CAEzC,GAAW,IAANG,EAEJ,MAGDF,EAAMH,EAAKK,EAAE,GACRN,EAAwBQ,KAAMJ,KAElCE,GAAK,EAEN,CAED,GAAKD,IAAQH,EACZ,KAED,CACD,OAAOD,EAAIQ,UAAW,EAAGH,EAC1B"} \ No newline at end of file diff --git a/index.js b/index.js deleted file mode 100644 index 4e500d1..0000000 --- a/index.js +++ /dev/null @@ -1,3 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -var e,t;e=this,t=function(){"use strict";var e=/[\uDC00-\uDFFF]/,t=/[\uD800-\uDBFF]/;return function(n,f){var i,o,r,u;if(0===f)return n;for(r=0,u=n.length-1;u>=0;u--){if(i=n[u],r+=1,e.test(i)){if(0===u)break;o=n[u-1],t.test(o)&&(u-=1)}if(r===f)break}return n.substring(0,u)}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).removeLastCodePoint=t(); -//# sourceMappingURL=index.js.map diff --git a/index.js.map b/index.js.map deleted file mode 100644 index d557af8..0000000 --- a/index.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.js","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\nvar RE_UTF16_LOW_SURROGATE = /[\\uDC00-\\uDFFF]/; // TODO: replace with stdlib pkg\nvar RE_UTF16_HIGH_SURROGATE = /[\\uD800-\\uDBFF]/; // TODO: replace with stdlib pkg\n\n\n// MAIN //\n\n/**\n* Removes the last `n` Unicode code points of a string.\n*\n* @param {string} str - input string\n* @param {NonNegativeInteger} n - number of Unicode code points to remove\n* @returns {string} output string\n*\n* @example\n* var out = removeLast( 'last man standing', 1 );\n* // returns 'last man standin'\n*\n* @example\n* var out = removeLast( 'presidential election', 1 );\n* // returns 'presidential electio'\n*\n* @example\n* var out = removeLast( 'JavaScript', 1 );\n* // returns 'JavaScrip'\n*\n* @example\n* var out = removeLast( 'Hidden Treasures', 1 );\n* // returns 'Hidden Treasure'\n*/\nfunction removeLast( str, n ) {\n\tvar len;\n\tvar ch1;\n\tvar ch2;\n\tvar cnt;\n\tvar i;\n\tif ( n === 0 ) {\n\t\treturn str;\n\t}\n\tlen = str.length;\n\tcnt = 0;\n\n\t// Process the string one Unicode code unit at a time and count UTF-16 surrogate pairs as a single Unicode code point...\n\tfor ( i = len - 1; i >= 0; i-- ) {\n\t\tch1 = str[ i ];\n\t\tcnt += 1;\n\n\t\t// Check for a low UTF-16 surrogate...\n\t\tif ( RE_UTF16_LOW_SURROGATE.test( ch1 ) ) {\n\t\t\t// Check for an unpaired surrogate at the end of the input string...\n\t\t\tif ( i === 0 ) {\n\t\t\t\t// We found an unpaired surrogate...\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\t// Check whether the high surrogate is paired with a low surrogate...\n\t\t\tch2 = str[ i-1 ];\n\t\t\tif ( RE_UTF16_HIGH_SURROGATE.test( ch2 ) ) {\n\t\t\t\t// We found a surrogate pair:\n\t\t\t\ti -= 1; // bump the index to process the next code unit\n\t\t\t}\n\t\t}\n\t\t// Check whether we've found the desired number of code points...\n\t\tif ( cnt === n ) {\n\t\t\tbreak;\n\t\t}\n\t}\n\treturn str.substring( 0, i );\n}\n\n\n// EXPORTS //\n\nexport default removeLast;\n"],"names":["RE_UTF16_LOW_SURROGATE","RE_UTF16_HIGH_SURROGATE","str","n","ch1","ch2","cnt","i","length","test","substring"],"mappings":";yCAsBA,IAAIA,EAAyB,kBACzBC,EAA0B,yBA4B9B,SAAqBC,EAAKC,GACzB,IACIC,EACAC,EACAC,EACAC,EACJ,GAAW,IAANJ,EACJ,OAAOD,EAMR,IAHAI,EAAM,EAGAC,EAJAL,EAAIM,OAIM,EAAGD,GAAK,EAAGA,IAAM,CAKhC,GAJAH,EAAMF,EAAKK,GACXD,GAAO,EAGFN,EAAuBS,KAAML,GAAQ,CAEzC,GAAW,IAANG,EAEJ,MAGDF,EAAMH,EAAKK,EAAE,GACRN,EAAwBQ,KAAMJ,KAElCE,GAAK,EAEN,CAED,GAAKD,IAAQH,EACZ,KAED,CACD,OAAOD,EAAIQ,UAAW,EAAGH,EAC1B"} \ No newline at end of file diff --git a/stats_browser.html b/stats_browser.html deleted file mode 100644 index 2c17dcc..0000000 --- a/stats_browser.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - diff --git a/stats_node.html b/stats_node.html deleted file mode 100644 index 1e086d4..0000000 --- a/stats_node.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 534d840dde1deda24fdd854b47d5f1a9e6fc9f62 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 1 Jun 2024 00:40:59 +0000 Subject: [PATCH 60/92] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 66 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 794 ---- .github/workflows/publish.yml | 248 -- .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .gitignore | 188 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 52 +- SECURITY.md | 5 - benchmark/benchmark.js | 56 - branches.md | 56 - browser.js | 3 + browser.js.map | 1 + dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 29 - docs/types/index.d.ts | 53 - docs/types/test.ts | 57 - examples/index.js | 33 - index.js | 3 + index.js.map | 1 + lib/index.js | 43 - lib/main.js | 94 - package.json | 53 +- stats_browser.html | 4842 +++++++++++++++++++++ stats_node.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 108 - 46 files changed, 9728 insertions(+), 3826 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md create mode 100644 browser.js create mode 100644 browser.js.map 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/index.d.ts delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js create mode 100644 index.js create mode 100644 index.js.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats_browser.html create mode 100644 stats_node.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 1a020fe..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-06-01T00:32:51.404Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 52cd9c4..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/base/remove-last-code-point) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 533eeee..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/base/remove-last-code-point) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 2a724f2..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: '29 5 * * 0' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index f92a6c5..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,794 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n +``` -```javascript -var removeLastCodePoint = require( '@stdlib/string-base-remove-last-code-point' ); +If no recognized module system is present, access bundle contents via the global scope: + +```html + ``` #### removeLastCodePoint( str, n ) @@ -91,8 +97,13 @@ out = removeLastCodePoint( 'foo bar', 10 ); -```javascript -var removeLastCodePoint = require( '@stdlib/string-base-remove-last-code-point' ); +```html + + + + + + + ```
diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index a39bd29..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,56 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var removeLast = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var values; - var out; - var i; - - values = [ - 'beep boop', - 'foo bar', - 'xyz abc', - '🐶🐮🐷🐰🐸' - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = removeLast( values[ i%values.length ], 1 ); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( !isString( out ) ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index f585c99..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/base/remove-last-code-point" -%% click B href "https://github.com/stdlib-js/string-base-remove-last-code-point/tree/main" -%% click C href "https://github.com/stdlib-js/string-base-remove-last-code-point/tree/production" -%% click D href "https://github.com/stdlib-js/string-base-remove-last-code-point/tree/esm" -%% click E href "https://github.com/stdlib-js/string-base-remove-last-code-point/tree/deno" -%% click F href "https://github.com/stdlib-js/string-base-remove-last-code-point/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/base/remove-last-code-point -[production-url]: https://github.com/stdlib-js/string-base-remove-last-code-point/tree/production -[deno-url]: https://github.com/stdlib-js/string-base-remove-last-code-point/tree/deno -[deno-readme]: https://github.com/stdlib-js/string-base-remove-last-code-point/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/string-base-remove-last-code-point/tree/umd -[umd-readme]: https://github.com/stdlib-js/string-base-remove-last-code-point/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/string-base-remove-last-code-point/tree/esm -[esm-readme]: https://github.com/stdlib-js/string-base-remove-last-code-point/blob/esm/README.md \ No newline at end of file diff --git a/browser.js b/browser.js new file mode 100644 index 0000000..f3a511a --- /dev/null +++ b/browser.js @@ -0,0 +1,3 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +var e,t;e=this,t=function(){"use strict";var e=/[\uDC00-\uDFFF]/,t=/[\uD800-\uDBFF]/;return function(n,f){var i,o,r,u;if(0===f)return n;for(r=0,u=n.length-1;u>=0;u--){if(i=n[u],r+=1,e.test(i)){if(0===u)break;o=n[u-1],t.test(o)&&(u-=1)}if(r===f)break}return n.substring(0,u)}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).removeLastCodePoint=t(); +//# sourceMappingURL=browser.js.map diff --git a/browser.js.map b/browser.js.map new file mode 100644 index 0000000..19908eb --- /dev/null +++ b/browser.js.map @@ -0,0 +1 @@ +{"version":3,"file":"browser.js","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\nvar RE_UTF16_LOW_SURROGATE = /[\\uDC00-\\uDFFF]/; // TODO: replace with stdlib pkg\nvar RE_UTF16_HIGH_SURROGATE = /[\\uD800-\\uDBFF]/; // TODO: replace with stdlib pkg\n\n\n// MAIN //\n\n/**\n* Removes the last `n` Unicode code points of a string.\n*\n* @param {string} str - input string\n* @param {NonNegativeInteger} n - number of Unicode code points to remove\n* @returns {string} output string\n*\n* @example\n* var out = removeLast( 'last man standing', 1 );\n* // returns 'last man standin'\n*\n* @example\n* var out = removeLast( 'presidential election', 1 );\n* // returns 'presidential electio'\n*\n* @example\n* var out = removeLast( 'JavaScript', 1 );\n* // returns 'JavaScrip'\n*\n* @example\n* var out = removeLast( 'Hidden Treasures', 1 );\n* // returns 'Hidden Treasure'\n*/\nfunction removeLast( str, n ) {\n\tvar len;\n\tvar ch1;\n\tvar ch2;\n\tvar cnt;\n\tvar i;\n\tif ( n === 0 ) {\n\t\treturn str;\n\t}\n\tlen = str.length;\n\tcnt = 0;\n\n\t// Process the string one Unicode code unit at a time and count UTF-16 surrogate pairs as a single Unicode code point...\n\tfor ( i = len - 1; i >= 0; i-- ) {\n\t\tch1 = str[ i ];\n\t\tcnt += 1;\n\n\t\t// Check for a low UTF-16 surrogate...\n\t\tif ( RE_UTF16_LOW_SURROGATE.test( ch1 ) ) {\n\t\t\t// Check for an unpaired surrogate at the end of the input string...\n\t\t\tif ( i === 0 ) {\n\t\t\t\t// We found an unpaired surrogate...\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\t// Check whether the high surrogate is paired with a low surrogate...\n\t\t\tch2 = str[ i-1 ];\n\t\t\tif ( RE_UTF16_HIGH_SURROGATE.test( ch2 ) ) {\n\t\t\t\t// We found a surrogate pair:\n\t\t\t\ti -= 1; // bump the index to process the next code unit\n\t\t\t}\n\t\t}\n\t\t// Check whether we've found the desired number of code points...\n\t\tif ( cnt === n ) {\n\t\t\tbreak;\n\t\t}\n\t}\n\treturn str.substring( 0, i );\n}\n\n\n// EXPORTS //\n\nexport default removeLast;\n"],"names":["RE_UTF16_LOW_SURROGATE","RE_UTF16_HIGH_SURROGATE","str","n","ch1","ch2","cnt","i","length","test","substring"],"mappings":";yCAsBA,IAAIA,EAAyB,kBACzBC,EAA0B,yBA4B9B,SAAqBC,EAAKC,GACzB,IACIC,EACAC,EACAC,EACAC,EACJ,GAAW,IAANJ,EACJ,OAAOD,EAMR,IAHAI,EAAM,EAGAC,EAJAL,EAAIM,OAIM,EAAGD,GAAK,EAAGA,IAAM,CAKhC,GAJAH,EAAMF,EAAKK,GACXD,GAAO,EAGFN,EAAuBS,KAAML,GAAQ,CAEzC,GAAW,IAANG,EAEJ,MAGDF,EAAMH,EAAKK,EAAE,GACRN,EAAwBQ,KAAMJ,KAElCE,GAAK,EAEN,CAED,GAAKD,IAAQH,EACZ,KAED,CACD,OAAOD,EAAIQ,UAAW,EAAGH,EAC1B"} \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index 8c96fd7..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import removeLast from '../docs/types/index'; -export = removeLast; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index e6b7220..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var s=function(e,t){return function(){return t||e((t={exports:{}}).exports,t),t.exports}};var f=s(function(D,n){ -var F=/[\uDC00-\uDFFF]/,c=/[\uD800-\uDBFF]/;function R(e,t){var i,u,v,a,r;if(t===0)return e;for(i=e.length,a=0,r=i-1;r>=0;r--){if(u=e[r],a+=1,F.test(u)){if(r===0)break;v=e[r-1],c.test(v)&&(r-=1)}if(a===t)break}return e.substring(0,r)}n.exports=R -});var _=f();module.exports=_; -/** @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 72561cf..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\nvar RE_UTF16_LOW_SURROGATE = /[\\uDC00-\\uDFFF]/; // TODO: replace with stdlib pkg\nvar RE_UTF16_HIGH_SURROGATE = /[\\uD800-\\uDBFF]/; // TODO: replace with stdlib pkg\n\n\n// MAIN //\n\n/**\n* Removes the last `n` Unicode code points of a string.\n*\n* @param {string} str - input string\n* @param {NonNegativeInteger} n - number of Unicode code points to remove\n* @returns {string} output string\n*\n* @example\n* var out = removeLast( 'last man standing', 1 );\n* // returns 'last man standin'\n*\n* @example\n* var out = removeLast( 'presidential election', 1 );\n* // returns 'presidential electio'\n*\n* @example\n* var out = removeLast( 'JavaScript', 1 );\n* // returns 'JavaScrip'\n*\n* @example\n* var out = removeLast( 'Hidden Treasures', 1 );\n* // returns 'Hidden Treasure'\n*/\nfunction removeLast( str, n ) {\n\tvar len;\n\tvar ch1;\n\tvar ch2;\n\tvar cnt;\n\tvar i;\n\tif ( n === 0 ) {\n\t\treturn str;\n\t}\n\tlen = str.length;\n\tcnt = 0;\n\n\t// Process the string one Unicode code unit at a time and count UTF-16 surrogate pairs as a single Unicode code point...\n\tfor ( i = len - 1; i >= 0; i-- ) {\n\t\tch1 = str[ i ];\n\t\tcnt += 1;\n\n\t\t// Check for a low UTF-16 surrogate...\n\t\tif ( RE_UTF16_LOW_SURROGATE.test( ch1 ) ) {\n\t\t\t// Check for an unpaired surrogate at the end of the input string...\n\t\t\tif ( i === 0 ) {\n\t\t\t\t// We found an unpaired surrogate...\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\t// Check whether the high surrogate is paired with a low surrogate...\n\t\t\tch2 = str[ i-1 ];\n\t\t\tif ( RE_UTF16_HIGH_SURROGATE.test( ch2 ) ) {\n\t\t\t\t// We found a surrogate pair:\n\t\t\t\ti -= 1; // bump the index to process the next code unit\n\t\t\t}\n\t\t}\n\t\t// Check whether we've found the desired number of code points...\n\t\tif ( cnt === n ) {\n\t\t\tbreak;\n\t\t}\n\t}\n\treturn str.substring( 0, i );\n}\n\n\n// EXPORTS //\n\nmodule.exports = removeLast;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Remove the last `n` Unicode code points of a string.\n*\n* @module @stdlib/string-base-remove-last-code-point\n*\n* @example\n* var removeLast = require( '@stdlib/string-base-remove-last-code-point' );\n*\n* var out = removeLast( 'last man standing', 1 );\n* // returns 'last man standin'\n*\n* out = removeLast( 'Hidden Treasures', 1 );\n* // returns 'Hidden Treasure';\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,EAAyB,kBACzBC,EAA0B,kBA4B9B,SAASC,EAAYC,EAAKC,EAAI,CAC7B,IAAIC,EACAC,EACAC,EACAC,EACAC,EACJ,GAAKL,IAAM,EACV,OAAOD,EAMR,IAJAE,EAAMF,EAAI,OACVK,EAAM,EAGAC,EAAIJ,EAAM,EAAGI,GAAK,EAAGA,IAAM,CAKhC,GAJAH,EAAMH,EAAKM,CAAE,EACbD,GAAO,EAGFR,EAAuB,KAAMM,CAAI,EAAI,CAEzC,GAAKG,IAAM,EAEV,MAGDF,EAAMJ,EAAKM,EAAE,CAAE,EACVR,EAAwB,KAAMM,CAAI,IAEtCE,GAAK,EAEP,CAEA,GAAKD,IAAQJ,EACZ,KAEF,CACA,OAAOD,EAAI,UAAW,EAAGM,CAAE,CAC5B,CAKAV,EAAO,QAAUG,ICxDjB,IAAIQ,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "RE_UTF16_LOW_SURROGATE", "RE_UTF16_HIGH_SURROGATE", "removeLast", "str", "n", "len", "ch1", "ch2", "cnt", "i", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index a08ea55..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,29 +0,0 @@ - -{{alias}}( str, n ) - Removes the last `n` Unicode code points of a string. - - Parameters - ---------- - str: string - Input string. - - n: integer - Number of Unicode code points to remove. - - Returns - ------- - out: string - Output string. - - Examples - -------- - > var out = {{alias}}( 'beep', 1 ) - 'bee' - > out = {{alias}}( 'Boop', 1 ) - 'Boo' - > out = {{alias}}( 'foo bar', 5 ) - 'fo' - - See Also - -------- - diff --git a/docs/types/index.d.ts b/docs/types/index.d.ts deleted file mode 100644 index 8a1c90b..0000000 --- a/docs/types/index.d.ts +++ /dev/null @@ -1,53 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 - -/** -* Removes the last `n` Unicode code points of a string. -* -* @param str - input string -* @param n - number of code points to remove -* @returns output string -* -* @example -* var out = removeLast( 'last man standing', 1 ); -* // returns 'last man standin' -* -* @example -* var out = removeLast( 'presidential election', 1 ); -* // returns 'presidential electio' -* -* @example -* var out = removeLast( 'JavaScript', 1 ); -* // returns 'JavaScrip' -* -* @example -* var out = removeLast( 'Hidden Treasures', 1 ); -* // returns 'Hidden Treasure' -* -* @example -* var out = removeLast( 'foo bar', 5 ); -* // returns 'fo' -*/ -declare function removeLast( str: string, n: number ): string; - - -// EXPORTS // - -export = removeLast; diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index fd426d2..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,57 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 removeLast = require( './index' ); - - -// TESTS // - -// The function returns a string... -{ - removeLast( 'abc', 1 ); // $ExpectType string -} - -// The compiler throws an error if the function is provided a value other than a string... -{ - removeLast( true, 1 ); // $ExpectError - removeLast( false, 1 ); // $ExpectError - removeLast( null, 1 ); // $ExpectError - removeLast( undefined, 1 ); // $ExpectError - removeLast( 5, 1 ); // $ExpectError - removeLast( [], 1 ); // $ExpectError - removeLast( {}, 1 ); // $ExpectError - removeLast( ( x: number ): number => x, 1 ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument that is not a number... -{ - removeLast( 'abc', true ); // $ExpectError - removeLast( 'abc', false ); // $ExpectError - removeLast( 'abc', null ); // $ExpectError - removeLast( 'abc', 'abc' ); // $ExpectError - removeLast( 'abc', [] ); // $ExpectError - removeLast( 'abc', {} ); // $ExpectError - removeLast( 'abc', ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - removeLast(); // $ExpectError - removeLast( 'abc' ); // $ExpectError - removeLast( 'abc', 1, 2 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 085633e..0000000 --- a/examples/index.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var removeLastCodePoint = require( './../lib' ); - -console.log( removeLastCodePoint( 'presidential election', 1 ) ); -// => 'presidential electio' - -console.log( removeLastCodePoint( 'JavaScript', 1 ) ); -// => 'JavaScrip' - -console.log( removeLastCodePoint( 'The Last of the Mohicans', 5 ) ); -// => 'The Last of the Moh' - -console.log( removeLastCodePoint( 'अनुच्छेद', 1 ) ); -// => 'अनुच्छे' diff --git a/index.js b/index.js new file mode 100644 index 0000000..4e500d1 --- /dev/null +++ b/index.js @@ -0,0 +1,3 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +var e,t;e=this,t=function(){"use strict";var e=/[\uDC00-\uDFFF]/,t=/[\uD800-\uDBFF]/;return function(n,f){var i,o,r,u;if(0===f)return n;for(r=0,u=n.length-1;u>=0;u--){if(i=n[u],r+=1,e.test(i)){if(0===u)break;o=n[u-1],t.test(o)&&(u-=1)}if(r===f)break}return n.substring(0,u)}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).removeLastCodePoint=t(); +//# sourceMappingURL=index.js.map diff --git a/index.js.map b/index.js.map new file mode 100644 index 0000000..d557af8 --- /dev/null +++ b/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\nvar RE_UTF16_LOW_SURROGATE = /[\\uDC00-\\uDFFF]/; // TODO: replace with stdlib pkg\nvar RE_UTF16_HIGH_SURROGATE = /[\\uD800-\\uDBFF]/; // TODO: replace with stdlib pkg\n\n\n// MAIN //\n\n/**\n* Removes the last `n` Unicode code points of a string.\n*\n* @param {string} str - input string\n* @param {NonNegativeInteger} n - number of Unicode code points to remove\n* @returns {string} output string\n*\n* @example\n* var out = removeLast( 'last man standing', 1 );\n* // returns 'last man standin'\n*\n* @example\n* var out = removeLast( 'presidential election', 1 );\n* // returns 'presidential electio'\n*\n* @example\n* var out = removeLast( 'JavaScript', 1 );\n* // returns 'JavaScrip'\n*\n* @example\n* var out = removeLast( 'Hidden Treasures', 1 );\n* // returns 'Hidden Treasure'\n*/\nfunction removeLast( str, n ) {\n\tvar len;\n\tvar ch1;\n\tvar ch2;\n\tvar cnt;\n\tvar i;\n\tif ( n === 0 ) {\n\t\treturn str;\n\t}\n\tlen = str.length;\n\tcnt = 0;\n\n\t// Process the string one Unicode code unit at a time and count UTF-16 surrogate pairs as a single Unicode code point...\n\tfor ( i = len - 1; i >= 0; i-- ) {\n\t\tch1 = str[ i ];\n\t\tcnt += 1;\n\n\t\t// Check for a low UTF-16 surrogate...\n\t\tif ( RE_UTF16_LOW_SURROGATE.test( ch1 ) ) {\n\t\t\t// Check for an unpaired surrogate at the end of the input string...\n\t\t\tif ( i === 0 ) {\n\t\t\t\t// We found an unpaired surrogate...\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\t// Check whether the high surrogate is paired with a low surrogate...\n\t\t\tch2 = str[ i-1 ];\n\t\t\tif ( RE_UTF16_HIGH_SURROGATE.test( ch2 ) ) {\n\t\t\t\t// We found a surrogate pair:\n\t\t\t\ti -= 1; // bump the index to process the next code unit\n\t\t\t}\n\t\t}\n\t\t// Check whether we've found the desired number of code points...\n\t\tif ( cnt === n ) {\n\t\t\tbreak;\n\t\t}\n\t}\n\treturn str.substring( 0, i );\n}\n\n\n// EXPORTS //\n\nexport default removeLast;\n"],"names":["RE_UTF16_LOW_SURROGATE","RE_UTF16_HIGH_SURROGATE","str","n","ch1","ch2","cnt","i","length","test","substring"],"mappings":";yCAsBA,IAAIA,EAAyB,kBACzBC,EAA0B,yBA4B9B,SAAqBC,EAAKC,GACzB,IACIC,EACAC,EACAC,EACAC,EACJ,GAAW,IAANJ,EACJ,OAAOD,EAMR,IAHAI,EAAM,EAGAC,EAJAL,EAAIM,OAIM,EAAGD,GAAK,EAAGA,IAAM,CAKhC,GAJAH,EAAMF,EAAKK,GACXD,GAAO,EAGFN,EAAuBS,KAAML,GAAQ,CAEzC,GAAW,IAANG,EAEJ,MAGDF,EAAMH,EAAKK,EAAE,GACRN,EAAwBQ,KAAMJ,KAElCE,GAAK,EAEN,CAED,GAAKD,IAAQH,EACZ,KAED,CACD,OAAOD,EAAIQ,UAAW,EAAGH,EAC1B"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 9860da0..0000000 --- a/lib/index.js +++ /dev/null @@ -1,43 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Remove the last `n` Unicode code points of a string. -* -* @module @stdlib/string-base-remove-last-code-point -* -* @example -* var removeLast = require( '@stdlib/string-base-remove-last-code-point' ); -* -* var out = removeLast( 'last man standing', 1 ); -* // returns 'last man standin' -* -* out = removeLast( 'Hidden Treasures', 1 ); -* // returns 'Hidden Treasure'; -*/ - -// 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 fc34187..0000000 --- a/lib/main.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// VARIABLES // - -var RE_UTF16_LOW_SURROGATE = /[\uDC00-\uDFFF]/; // TODO: replace with stdlib pkg -var RE_UTF16_HIGH_SURROGATE = /[\uD800-\uDBFF]/; // TODO: replace with stdlib pkg - - -// MAIN // - -/** -* Removes the last `n` Unicode code points of a string. -* -* @param {string} str - input string -* @param {NonNegativeInteger} n - number of Unicode code points to remove -* @returns {string} output string -* -* @example -* var out = removeLast( 'last man standing', 1 ); -* // returns 'last man standin' -* -* @example -* var out = removeLast( 'presidential election', 1 ); -* // returns 'presidential electio' -* -* @example -* var out = removeLast( 'JavaScript', 1 ); -* // returns 'JavaScrip' -* -* @example -* var out = removeLast( 'Hidden Treasures', 1 ); -* // returns 'Hidden Treasure' -*/ -function removeLast( str, n ) { - var len; - var ch1; - var ch2; - var cnt; - var i; - if ( n === 0 ) { - return str; - } - len = str.length; - cnt = 0; - - // Process the string one Unicode code unit at a time and count UTF-16 surrogate pairs as a single Unicode code point... - for ( i = len - 1; i >= 0; i-- ) { - ch1 = str[ i ]; - cnt += 1; - - // Check for a low UTF-16 surrogate... - if ( RE_UTF16_LOW_SURROGATE.test( ch1 ) ) { - // Check for an unpaired surrogate at the end of the input string... - if ( i === 0 ) { - // We found an unpaired surrogate... - break; - } - // Check whether the high surrogate is paired with a low surrogate... - ch2 = str[ i-1 ]; - if ( RE_UTF16_HIGH_SURROGATE.test( ch2 ) ) { - // We found a surrogate pair: - i -= 1; // bump the index to process the next code unit - } - } - // Check whether we've found the desired number of code points... - if ( cnt === n ) { - break; - } - } - return str.substring( 0, i ); -} - - -// EXPORTS // - -module.exports = removeLast; diff --git a/package.json b/package.json index 7d6f49d..f3c9a46 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,7 @@ "version": "0.2.1", "description": "Remove the last Unicode code point of a string.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "main": "./index.js", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,31 +12,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/error-tools-fmtprodmsg": "^0.2.1" - }, - "devDependencies": { - "@stdlib/assert-is-string": "^0.2.1", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.1" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdstring", @@ -81,4 +32,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/stats_browser.html b/stats_browser.html new file mode 100644 index 0000000..2c17dcc --- /dev/null +++ b/stats_browser.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/stats_node.html b/stats_node.html new file mode 100644 index 0000000..1e086d4 --- /dev/null +++ b/stats_node.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index a25545e..0000000 --- a/test/test.js +++ /dev/null @@ -1,108 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var removeLast = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof removeLast, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns an empty string if provided an empty string', function test( t ) { - t.strictEqual( removeLast( '', 1 ), '', 'returns expected value' ); - t.strictEqual( removeLast( '', 2 ), '', 'returns expected value' ); - t.strictEqual( removeLast( '', 3 ), '', 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns the input string if provided zero as the second argument', function test( t ) { - t.strictEqual( removeLast( 'hello world', 0 ), 'hello world', 'returns expected value' ); - t.end(); -}); - -tape( 'the function removes the last Unicode code point of a provided string (ascii)', function test( t ) { - var out; - - out = removeLast( 'hello world', 1 ); - t.strictEqual( out, 'hello worl', 'returns expected value' ); - - out = removeLast( '!!!', 1 ); - t.strictEqual( out, '!!', 'returns expected value' ); - - out = removeLast( 'Hello World', 1 ); - t.strictEqual( out, 'Hello Worl', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function removes the last Unicode code point of a provided string (Unicode)', function test( t ) { - var out; - - out = removeLast( 'अनुच्छेद', 1 ); - t.strictEqual( out, 'अनुच्छे', 'returns expected value' ); - - out = removeLast( '六书/六書', 1 ); - t.strictEqual( out, '六书/六', 'returns expected value' ); - - out = removeLast( '𐒻𐓟', 1 ); - t.strictEqual( out, '𐒻', 'returns expected value' ); - - out = removeLast( '𐒻𐓟', 1 ); - t.strictEqual( out, '𐒻', 'returns expected value' ); - - out = removeLast( '\uDC00', 1 ); - t.strictEqual( out, '', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports removing the last `n` Unicode code points of a provided string', function test( t ) { - var out; - - out = removeLast( 'hello world', 1 ); - t.strictEqual( out, 'hello worl', 'returns expected value' ); - - out = removeLast( 'hello world', 7 ); - t.strictEqual( out, 'hell', 'returns expected value' ); - - out = removeLast( '!!!', 1 ); - t.strictEqual( out, '!!', 'returns expected value' ); - - out = removeLast( '!!!', 2 ); - t.strictEqual( out, '!', 'returns expected value' ); - - out = removeLast( 'अनुच्छेद', 1 ); - t.strictEqual( out, 'अनुच्छे', 'returns expected value' ); - - out = removeLast( '六书/六書', 3 ); - t.strictEqual( out, '六书', 'returns expected value' ); - - out = removeLast( '𐒻𐓟𐓟', 2 ); - t.strictEqual( out, '𐒻', 'returns expected value' ); - - t.end(); -}); From 34603844d932cfa6edde4503ce8a913048de4b8e Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Jul 2024 00:37:00 +0000 Subject: [PATCH 61/92] Transform error messages --- package.json | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 2bbf191..7d6f49d 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,9 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": {}, + "dependencies": { + "@stdlib/error-tools-fmtprodmsg": "^0.2.1" + }, "devDependencies": { "@stdlib/assert-is-string": "^0.2.1", "tape": "git+https://github.com/kgryte/tape.git#fix/globby", @@ -79,4 +81,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 966d3ff3e47a4ece7462ff1a7e762d6c9183c3e2 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Jul 2024 00:44:33 +0000 Subject: [PATCH 62/92] Remove files --- browser.js | 3 - browser.js.map | 1 - index.js | 3 - index.js.map | 1 - stats_browser.html | 4842 -------------------------------------------- stats_node.html | 4842 -------------------------------------------- 6 files changed, 9692 deletions(-) delete mode 100644 browser.js delete mode 100644 browser.js.map delete mode 100644 index.js delete mode 100644 index.js.map delete mode 100644 stats_browser.html delete mode 100644 stats_node.html diff --git a/browser.js b/browser.js deleted file mode 100644 index f3a511a..0000000 --- a/browser.js +++ /dev/null @@ -1,3 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -var e,t;e=this,t=function(){"use strict";var e=/[\uDC00-\uDFFF]/,t=/[\uD800-\uDBFF]/;return function(n,f){var i,o,r,u;if(0===f)return n;for(r=0,u=n.length-1;u>=0;u--){if(i=n[u],r+=1,e.test(i)){if(0===u)break;o=n[u-1],t.test(o)&&(u-=1)}if(r===f)break}return n.substring(0,u)}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).removeLastCodePoint=t(); -//# sourceMappingURL=browser.js.map diff --git a/browser.js.map b/browser.js.map deleted file mode 100644 index 19908eb..0000000 --- a/browser.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"browser.js","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\nvar RE_UTF16_LOW_SURROGATE = /[\\uDC00-\\uDFFF]/; // TODO: replace with stdlib pkg\nvar RE_UTF16_HIGH_SURROGATE = /[\\uD800-\\uDBFF]/; // TODO: replace with stdlib pkg\n\n\n// MAIN //\n\n/**\n* Removes the last `n` Unicode code points of a string.\n*\n* @param {string} str - input string\n* @param {NonNegativeInteger} n - number of Unicode code points to remove\n* @returns {string} output string\n*\n* @example\n* var out = removeLast( 'last man standing', 1 );\n* // returns 'last man standin'\n*\n* @example\n* var out = removeLast( 'presidential election', 1 );\n* // returns 'presidential electio'\n*\n* @example\n* var out = removeLast( 'JavaScript', 1 );\n* // returns 'JavaScrip'\n*\n* @example\n* var out = removeLast( 'Hidden Treasures', 1 );\n* // returns 'Hidden Treasure'\n*/\nfunction removeLast( str, n ) {\n\tvar len;\n\tvar ch1;\n\tvar ch2;\n\tvar cnt;\n\tvar i;\n\tif ( n === 0 ) {\n\t\treturn str;\n\t}\n\tlen = str.length;\n\tcnt = 0;\n\n\t// Process the string one Unicode code unit at a time and count UTF-16 surrogate pairs as a single Unicode code point...\n\tfor ( i = len - 1; i >= 0; i-- ) {\n\t\tch1 = str[ i ];\n\t\tcnt += 1;\n\n\t\t// Check for a low UTF-16 surrogate...\n\t\tif ( RE_UTF16_LOW_SURROGATE.test( ch1 ) ) {\n\t\t\t// Check for an unpaired surrogate at the end of the input string...\n\t\t\tif ( i === 0 ) {\n\t\t\t\t// We found an unpaired surrogate...\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\t// Check whether the high surrogate is paired with a low surrogate...\n\t\t\tch2 = str[ i-1 ];\n\t\t\tif ( RE_UTF16_HIGH_SURROGATE.test( ch2 ) ) {\n\t\t\t\t// We found a surrogate pair:\n\t\t\t\ti -= 1; // bump the index to process the next code unit\n\t\t\t}\n\t\t}\n\t\t// Check whether we've found the desired number of code points...\n\t\tif ( cnt === n ) {\n\t\t\tbreak;\n\t\t}\n\t}\n\treturn str.substring( 0, i );\n}\n\n\n// EXPORTS //\n\nexport default removeLast;\n"],"names":["RE_UTF16_LOW_SURROGATE","RE_UTF16_HIGH_SURROGATE","str","n","ch1","ch2","cnt","i","length","test","substring"],"mappings":";yCAsBA,IAAIA,EAAyB,kBACzBC,EAA0B,yBA4B9B,SAAqBC,EAAKC,GACzB,IACIC,EACAC,EACAC,EACAC,EACJ,GAAW,IAANJ,EACJ,OAAOD,EAMR,IAHAI,EAAM,EAGAC,EAJAL,EAAIM,OAIM,EAAGD,GAAK,EAAGA,IAAM,CAKhC,GAJAH,EAAMF,EAAKK,GACXD,GAAO,EAGFN,EAAuBS,KAAML,GAAQ,CAEzC,GAAW,IAANG,EAEJ,MAGDF,EAAMH,EAAKK,EAAE,GACRN,EAAwBQ,KAAMJ,KAElCE,GAAK,EAEN,CAED,GAAKD,IAAQH,EACZ,KAED,CACD,OAAOD,EAAIQ,UAAW,EAAGH,EAC1B"} \ No newline at end of file diff --git a/index.js b/index.js deleted file mode 100644 index 4e500d1..0000000 --- a/index.js +++ /dev/null @@ -1,3 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -var e,t;e=this,t=function(){"use strict";var e=/[\uDC00-\uDFFF]/,t=/[\uD800-\uDBFF]/;return function(n,f){var i,o,r,u;if(0===f)return n;for(r=0,u=n.length-1;u>=0;u--){if(i=n[u],r+=1,e.test(i)){if(0===u)break;o=n[u-1],t.test(o)&&(u-=1)}if(r===f)break}return n.substring(0,u)}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).removeLastCodePoint=t(); -//# sourceMappingURL=index.js.map diff --git a/index.js.map b/index.js.map deleted file mode 100644 index d557af8..0000000 --- a/index.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.js","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\nvar RE_UTF16_LOW_SURROGATE = /[\\uDC00-\\uDFFF]/; // TODO: replace with stdlib pkg\nvar RE_UTF16_HIGH_SURROGATE = /[\\uD800-\\uDBFF]/; // TODO: replace with stdlib pkg\n\n\n// MAIN //\n\n/**\n* Removes the last `n` Unicode code points of a string.\n*\n* @param {string} str - input string\n* @param {NonNegativeInteger} n - number of Unicode code points to remove\n* @returns {string} output string\n*\n* @example\n* var out = removeLast( 'last man standing', 1 );\n* // returns 'last man standin'\n*\n* @example\n* var out = removeLast( 'presidential election', 1 );\n* // returns 'presidential electio'\n*\n* @example\n* var out = removeLast( 'JavaScript', 1 );\n* // returns 'JavaScrip'\n*\n* @example\n* var out = removeLast( 'Hidden Treasures', 1 );\n* // returns 'Hidden Treasure'\n*/\nfunction removeLast( str, n ) {\n\tvar len;\n\tvar ch1;\n\tvar ch2;\n\tvar cnt;\n\tvar i;\n\tif ( n === 0 ) {\n\t\treturn str;\n\t}\n\tlen = str.length;\n\tcnt = 0;\n\n\t// Process the string one Unicode code unit at a time and count UTF-16 surrogate pairs as a single Unicode code point...\n\tfor ( i = len - 1; i >= 0; i-- ) {\n\t\tch1 = str[ i ];\n\t\tcnt += 1;\n\n\t\t// Check for a low UTF-16 surrogate...\n\t\tif ( RE_UTF16_LOW_SURROGATE.test( ch1 ) ) {\n\t\t\t// Check for an unpaired surrogate at the end of the input string...\n\t\t\tif ( i === 0 ) {\n\t\t\t\t// We found an unpaired surrogate...\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\t// Check whether the high surrogate is paired with a low surrogate...\n\t\t\tch2 = str[ i-1 ];\n\t\t\tif ( RE_UTF16_HIGH_SURROGATE.test( ch2 ) ) {\n\t\t\t\t// We found a surrogate pair:\n\t\t\t\ti -= 1; // bump the index to process the next code unit\n\t\t\t}\n\t\t}\n\t\t// Check whether we've found the desired number of code points...\n\t\tif ( cnt === n ) {\n\t\t\tbreak;\n\t\t}\n\t}\n\treturn str.substring( 0, i );\n}\n\n\n// EXPORTS //\n\nexport default removeLast;\n"],"names":["RE_UTF16_LOW_SURROGATE","RE_UTF16_HIGH_SURROGATE","str","n","ch1","ch2","cnt","i","length","test","substring"],"mappings":";yCAsBA,IAAIA,EAAyB,kBACzBC,EAA0B,yBA4B9B,SAAqBC,EAAKC,GACzB,IACIC,EACAC,EACAC,EACAC,EACJ,GAAW,IAANJ,EACJ,OAAOD,EAMR,IAHAI,EAAM,EAGAC,EAJAL,EAAIM,OAIM,EAAGD,GAAK,EAAGA,IAAM,CAKhC,GAJAH,EAAMF,EAAKK,GACXD,GAAO,EAGFN,EAAuBS,KAAML,GAAQ,CAEzC,GAAW,IAANG,EAEJ,MAGDF,EAAMH,EAAKK,EAAE,GACRN,EAAwBQ,KAAMJ,KAElCE,GAAK,EAEN,CAED,GAAKD,IAAQH,EACZ,KAED,CACD,OAAOD,EAAIQ,UAAW,EAAGH,EAC1B"} \ No newline at end of file diff --git a/stats_browser.html b/stats_browser.html deleted file mode 100644 index 2c17dcc..0000000 --- a/stats_browser.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - diff --git a/stats_node.html b/stats_node.html deleted file mode 100644 index 1e086d4..0000000 --- a/stats_node.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 68027a674628b50a2e807d113603970980513c1e Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Jul 2024 00:44:45 +0000 Subject: [PATCH 63/92] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 66 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 794 ---- .github/workflows/publish.yml | 252 -- .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .gitignore | 188 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 38 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 52 +- SECURITY.md | 5 - benchmark/benchmark.js | 56 - branches.md | 56 - browser.js | 3 + browser.js.map | 1 + dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 29 - docs/types/index.d.ts | 53 - docs/types/test.ts | 57 - examples/index.js | 33 - index.js | 3 + index.js.map | 1 + lib/index.js | 43 - lib/main.js | 94 - package.json | 53 +- stats_browser.html | 4842 +++++++++++++++++++++ stats_node.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 108 - 46 files changed, 9728 insertions(+), 3863 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md create mode 100644 browser.js create mode 100644 browser.js.map 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/index.d.ts delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js create mode 100644 index.js create mode 100644 index.js.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats_browser.html create mode 100644 stats_node.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index e683681..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-07-01T00:36:21.658Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 52cd9c4..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/base/remove-last-code-point) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 533eeee..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/base/remove-last-code-point) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 2a724f2..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: '29 5 * * 0' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index f92a6c5..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,794 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n +``` -```javascript -var removeLastCodePoint = require( '@stdlib/string-base-remove-last-code-point' ); +If no recognized module system is present, access bundle contents via the global scope: + +```html + ``` #### removeLastCodePoint( str, n ) @@ -91,8 +97,13 @@ out = removeLastCodePoint( 'foo bar', 10 ); -```javascript -var removeLastCodePoint = require( '@stdlib/string-base-remove-last-code-point' ); +```html + + + + + + + ```
diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index a39bd29..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,56 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var removeLast = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var values; - var out; - var i; - - values = [ - 'beep boop', - 'foo bar', - 'xyz abc', - '🐶🐮🐷🐰🐸' - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = removeLast( values[ i%values.length ], 1 ); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( !isString( out ) ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index f585c99..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/base/remove-last-code-point" -%% click B href "https://github.com/stdlib-js/string-base-remove-last-code-point/tree/main" -%% click C href "https://github.com/stdlib-js/string-base-remove-last-code-point/tree/production" -%% click D href "https://github.com/stdlib-js/string-base-remove-last-code-point/tree/esm" -%% click E href "https://github.com/stdlib-js/string-base-remove-last-code-point/tree/deno" -%% click F href "https://github.com/stdlib-js/string-base-remove-last-code-point/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/base/remove-last-code-point -[production-url]: https://github.com/stdlib-js/string-base-remove-last-code-point/tree/production -[deno-url]: https://github.com/stdlib-js/string-base-remove-last-code-point/tree/deno -[deno-readme]: https://github.com/stdlib-js/string-base-remove-last-code-point/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/string-base-remove-last-code-point/tree/umd -[umd-readme]: https://github.com/stdlib-js/string-base-remove-last-code-point/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/string-base-remove-last-code-point/tree/esm -[esm-readme]: https://github.com/stdlib-js/string-base-remove-last-code-point/blob/esm/README.md \ No newline at end of file diff --git a/browser.js b/browser.js new file mode 100644 index 0000000..f3a511a --- /dev/null +++ b/browser.js @@ -0,0 +1,3 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +var e,t;e=this,t=function(){"use strict";var e=/[\uDC00-\uDFFF]/,t=/[\uD800-\uDBFF]/;return function(n,f){var i,o,r,u;if(0===f)return n;for(r=0,u=n.length-1;u>=0;u--){if(i=n[u],r+=1,e.test(i)){if(0===u)break;o=n[u-1],t.test(o)&&(u-=1)}if(r===f)break}return n.substring(0,u)}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).removeLastCodePoint=t(); +//# sourceMappingURL=browser.js.map diff --git a/browser.js.map b/browser.js.map new file mode 100644 index 0000000..19908eb --- /dev/null +++ b/browser.js.map @@ -0,0 +1 @@ +{"version":3,"file":"browser.js","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\nvar RE_UTF16_LOW_SURROGATE = /[\\uDC00-\\uDFFF]/; // TODO: replace with stdlib pkg\nvar RE_UTF16_HIGH_SURROGATE = /[\\uD800-\\uDBFF]/; // TODO: replace with stdlib pkg\n\n\n// MAIN //\n\n/**\n* Removes the last `n` Unicode code points of a string.\n*\n* @param {string} str - input string\n* @param {NonNegativeInteger} n - number of Unicode code points to remove\n* @returns {string} output string\n*\n* @example\n* var out = removeLast( 'last man standing', 1 );\n* // returns 'last man standin'\n*\n* @example\n* var out = removeLast( 'presidential election', 1 );\n* // returns 'presidential electio'\n*\n* @example\n* var out = removeLast( 'JavaScript', 1 );\n* // returns 'JavaScrip'\n*\n* @example\n* var out = removeLast( 'Hidden Treasures', 1 );\n* // returns 'Hidden Treasure'\n*/\nfunction removeLast( str, n ) {\n\tvar len;\n\tvar ch1;\n\tvar ch2;\n\tvar cnt;\n\tvar i;\n\tif ( n === 0 ) {\n\t\treturn str;\n\t}\n\tlen = str.length;\n\tcnt = 0;\n\n\t// Process the string one Unicode code unit at a time and count UTF-16 surrogate pairs as a single Unicode code point...\n\tfor ( i = len - 1; i >= 0; i-- ) {\n\t\tch1 = str[ i ];\n\t\tcnt += 1;\n\n\t\t// Check for a low UTF-16 surrogate...\n\t\tif ( RE_UTF16_LOW_SURROGATE.test( ch1 ) ) {\n\t\t\t// Check for an unpaired surrogate at the end of the input string...\n\t\t\tif ( i === 0 ) {\n\t\t\t\t// We found an unpaired surrogate...\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\t// Check whether the high surrogate is paired with a low surrogate...\n\t\t\tch2 = str[ i-1 ];\n\t\t\tif ( RE_UTF16_HIGH_SURROGATE.test( ch2 ) ) {\n\t\t\t\t// We found a surrogate pair:\n\t\t\t\ti -= 1; // bump the index to process the next code unit\n\t\t\t}\n\t\t}\n\t\t// Check whether we've found the desired number of code points...\n\t\tif ( cnt === n ) {\n\t\t\tbreak;\n\t\t}\n\t}\n\treturn str.substring( 0, i );\n}\n\n\n// EXPORTS //\n\nexport default removeLast;\n"],"names":["RE_UTF16_LOW_SURROGATE","RE_UTF16_HIGH_SURROGATE","str","n","ch1","ch2","cnt","i","length","test","substring"],"mappings":";yCAsBA,IAAIA,EAAyB,kBACzBC,EAA0B,yBA4B9B,SAAqBC,EAAKC,GACzB,IACIC,EACAC,EACAC,EACAC,EACJ,GAAW,IAANJ,EACJ,OAAOD,EAMR,IAHAI,EAAM,EAGAC,EAJAL,EAAIM,OAIM,EAAGD,GAAK,EAAGA,IAAM,CAKhC,GAJAH,EAAMF,EAAKK,GACXD,GAAO,EAGFN,EAAuBS,KAAML,GAAQ,CAEzC,GAAW,IAANG,EAEJ,MAGDF,EAAMH,EAAKK,EAAE,GACRN,EAAwBQ,KAAMJ,KAElCE,GAAK,EAEN,CAED,GAAKD,IAAQH,EACZ,KAED,CACD,OAAOD,EAAIQ,UAAW,EAAGH,EAC1B"} \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index 8c96fd7..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import removeLast from '../docs/types/index'; -export = removeLast; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index e6b7220..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var s=function(e,t){return function(){return t||e((t={exports:{}}).exports,t),t.exports}};var f=s(function(D,n){ -var F=/[\uDC00-\uDFFF]/,c=/[\uD800-\uDBFF]/;function R(e,t){var i,u,v,a,r;if(t===0)return e;for(i=e.length,a=0,r=i-1;r>=0;r--){if(u=e[r],a+=1,F.test(u)){if(r===0)break;v=e[r-1],c.test(v)&&(r-=1)}if(a===t)break}return e.substring(0,r)}n.exports=R -});var _=f();module.exports=_; -/** @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 72561cf..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\nvar RE_UTF16_LOW_SURROGATE = /[\\uDC00-\\uDFFF]/; // TODO: replace with stdlib pkg\nvar RE_UTF16_HIGH_SURROGATE = /[\\uD800-\\uDBFF]/; // TODO: replace with stdlib pkg\n\n\n// MAIN //\n\n/**\n* Removes the last `n` Unicode code points of a string.\n*\n* @param {string} str - input string\n* @param {NonNegativeInteger} n - number of Unicode code points to remove\n* @returns {string} output string\n*\n* @example\n* var out = removeLast( 'last man standing', 1 );\n* // returns 'last man standin'\n*\n* @example\n* var out = removeLast( 'presidential election', 1 );\n* // returns 'presidential electio'\n*\n* @example\n* var out = removeLast( 'JavaScript', 1 );\n* // returns 'JavaScrip'\n*\n* @example\n* var out = removeLast( 'Hidden Treasures', 1 );\n* // returns 'Hidden Treasure'\n*/\nfunction removeLast( str, n ) {\n\tvar len;\n\tvar ch1;\n\tvar ch2;\n\tvar cnt;\n\tvar i;\n\tif ( n === 0 ) {\n\t\treturn str;\n\t}\n\tlen = str.length;\n\tcnt = 0;\n\n\t// Process the string one Unicode code unit at a time and count UTF-16 surrogate pairs as a single Unicode code point...\n\tfor ( i = len - 1; i >= 0; i-- ) {\n\t\tch1 = str[ i ];\n\t\tcnt += 1;\n\n\t\t// Check for a low UTF-16 surrogate...\n\t\tif ( RE_UTF16_LOW_SURROGATE.test( ch1 ) ) {\n\t\t\t// Check for an unpaired surrogate at the end of the input string...\n\t\t\tif ( i === 0 ) {\n\t\t\t\t// We found an unpaired surrogate...\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\t// Check whether the high surrogate is paired with a low surrogate...\n\t\t\tch2 = str[ i-1 ];\n\t\t\tif ( RE_UTF16_HIGH_SURROGATE.test( ch2 ) ) {\n\t\t\t\t// We found a surrogate pair:\n\t\t\t\ti -= 1; // bump the index to process the next code unit\n\t\t\t}\n\t\t}\n\t\t// Check whether we've found the desired number of code points...\n\t\tif ( cnt === n ) {\n\t\t\tbreak;\n\t\t}\n\t}\n\treturn str.substring( 0, i );\n}\n\n\n// EXPORTS //\n\nmodule.exports = removeLast;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Remove the last `n` Unicode code points of a string.\n*\n* @module @stdlib/string-base-remove-last-code-point\n*\n* @example\n* var removeLast = require( '@stdlib/string-base-remove-last-code-point' );\n*\n* var out = removeLast( 'last man standing', 1 );\n* // returns 'last man standin'\n*\n* out = removeLast( 'Hidden Treasures', 1 );\n* // returns 'Hidden Treasure';\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,EAAyB,kBACzBC,EAA0B,kBA4B9B,SAASC,EAAYC,EAAKC,EAAI,CAC7B,IAAIC,EACAC,EACAC,EACAC,EACAC,EACJ,GAAKL,IAAM,EACV,OAAOD,EAMR,IAJAE,EAAMF,EAAI,OACVK,EAAM,EAGAC,EAAIJ,EAAM,EAAGI,GAAK,EAAGA,IAAM,CAKhC,GAJAH,EAAMH,EAAKM,CAAE,EACbD,GAAO,EAGFR,EAAuB,KAAMM,CAAI,EAAI,CAEzC,GAAKG,IAAM,EAEV,MAGDF,EAAMJ,EAAKM,EAAE,CAAE,EACVR,EAAwB,KAAMM,CAAI,IAEtCE,GAAK,EAEP,CAEA,GAAKD,IAAQJ,EACZ,KAEF,CACA,OAAOD,EAAI,UAAW,EAAGM,CAAE,CAC5B,CAKAV,EAAO,QAAUG,ICxDjB,IAAIQ,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "RE_UTF16_LOW_SURROGATE", "RE_UTF16_HIGH_SURROGATE", "removeLast", "str", "n", "len", "ch1", "ch2", "cnt", "i", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index a08ea55..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,29 +0,0 @@ - -{{alias}}( str, n ) - Removes the last `n` Unicode code points of a string. - - Parameters - ---------- - str: string - Input string. - - n: integer - Number of Unicode code points to remove. - - Returns - ------- - out: string - Output string. - - Examples - -------- - > var out = {{alias}}( 'beep', 1 ) - 'bee' - > out = {{alias}}( 'Boop', 1 ) - 'Boo' - > out = {{alias}}( 'foo bar', 5 ) - 'fo' - - See Also - -------- - diff --git a/docs/types/index.d.ts b/docs/types/index.d.ts deleted file mode 100644 index 8a1c90b..0000000 --- a/docs/types/index.d.ts +++ /dev/null @@ -1,53 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 - -/** -* Removes the last `n` Unicode code points of a string. -* -* @param str - input string -* @param n - number of code points to remove -* @returns output string -* -* @example -* var out = removeLast( 'last man standing', 1 ); -* // returns 'last man standin' -* -* @example -* var out = removeLast( 'presidential election', 1 ); -* // returns 'presidential electio' -* -* @example -* var out = removeLast( 'JavaScript', 1 ); -* // returns 'JavaScrip' -* -* @example -* var out = removeLast( 'Hidden Treasures', 1 ); -* // returns 'Hidden Treasure' -* -* @example -* var out = removeLast( 'foo bar', 5 ); -* // returns 'fo' -*/ -declare function removeLast( str: string, n: number ): string; - - -// EXPORTS // - -export = removeLast; diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index fd426d2..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,57 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 removeLast = require( './index' ); - - -// TESTS // - -// The function returns a string... -{ - removeLast( 'abc', 1 ); // $ExpectType string -} - -// The compiler throws an error if the function is provided a value other than a string... -{ - removeLast( true, 1 ); // $ExpectError - removeLast( false, 1 ); // $ExpectError - removeLast( null, 1 ); // $ExpectError - removeLast( undefined, 1 ); // $ExpectError - removeLast( 5, 1 ); // $ExpectError - removeLast( [], 1 ); // $ExpectError - removeLast( {}, 1 ); // $ExpectError - removeLast( ( x: number ): number => x, 1 ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument that is not a number... -{ - removeLast( 'abc', true ); // $ExpectError - removeLast( 'abc', false ); // $ExpectError - removeLast( 'abc', null ); // $ExpectError - removeLast( 'abc', 'abc' ); // $ExpectError - removeLast( 'abc', [] ); // $ExpectError - removeLast( 'abc', {} ); // $ExpectError - removeLast( 'abc', ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - removeLast(); // $ExpectError - removeLast( 'abc' ); // $ExpectError - removeLast( 'abc', 1, 2 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 085633e..0000000 --- a/examples/index.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var removeLastCodePoint = require( './../lib' ); - -console.log( removeLastCodePoint( 'presidential election', 1 ) ); -// => 'presidential electio' - -console.log( removeLastCodePoint( 'JavaScript', 1 ) ); -// => 'JavaScrip' - -console.log( removeLastCodePoint( 'The Last of the Mohicans', 5 ) ); -// => 'The Last of the Moh' - -console.log( removeLastCodePoint( 'अनुच्छेद', 1 ) ); -// => 'अनुच्छे' diff --git a/index.js b/index.js new file mode 100644 index 0000000..4e500d1 --- /dev/null +++ b/index.js @@ -0,0 +1,3 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +var e,t;e=this,t=function(){"use strict";var e=/[\uDC00-\uDFFF]/,t=/[\uD800-\uDBFF]/;return function(n,f){var i,o,r,u;if(0===f)return n;for(r=0,u=n.length-1;u>=0;u--){if(i=n[u],r+=1,e.test(i)){if(0===u)break;o=n[u-1],t.test(o)&&(u-=1)}if(r===f)break}return n.substring(0,u)}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).removeLastCodePoint=t(); +//# sourceMappingURL=index.js.map diff --git a/index.js.map b/index.js.map new file mode 100644 index 0000000..d557af8 --- /dev/null +++ b/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\nvar RE_UTF16_LOW_SURROGATE = /[\\uDC00-\\uDFFF]/; // TODO: replace with stdlib pkg\nvar RE_UTF16_HIGH_SURROGATE = /[\\uD800-\\uDBFF]/; // TODO: replace with stdlib pkg\n\n\n// MAIN //\n\n/**\n* Removes the last `n` Unicode code points of a string.\n*\n* @param {string} str - input string\n* @param {NonNegativeInteger} n - number of Unicode code points to remove\n* @returns {string} output string\n*\n* @example\n* var out = removeLast( 'last man standing', 1 );\n* // returns 'last man standin'\n*\n* @example\n* var out = removeLast( 'presidential election', 1 );\n* // returns 'presidential electio'\n*\n* @example\n* var out = removeLast( 'JavaScript', 1 );\n* // returns 'JavaScrip'\n*\n* @example\n* var out = removeLast( 'Hidden Treasures', 1 );\n* // returns 'Hidden Treasure'\n*/\nfunction removeLast( str, n ) {\n\tvar len;\n\tvar ch1;\n\tvar ch2;\n\tvar cnt;\n\tvar i;\n\tif ( n === 0 ) {\n\t\treturn str;\n\t}\n\tlen = str.length;\n\tcnt = 0;\n\n\t// Process the string one Unicode code unit at a time and count UTF-16 surrogate pairs as a single Unicode code point...\n\tfor ( i = len - 1; i >= 0; i-- ) {\n\t\tch1 = str[ i ];\n\t\tcnt += 1;\n\n\t\t// Check for a low UTF-16 surrogate...\n\t\tif ( RE_UTF16_LOW_SURROGATE.test( ch1 ) ) {\n\t\t\t// Check for an unpaired surrogate at the end of the input string...\n\t\t\tif ( i === 0 ) {\n\t\t\t\t// We found an unpaired surrogate...\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\t// Check whether the high surrogate is paired with a low surrogate...\n\t\t\tch2 = str[ i-1 ];\n\t\t\tif ( RE_UTF16_HIGH_SURROGATE.test( ch2 ) ) {\n\t\t\t\t// We found a surrogate pair:\n\t\t\t\ti -= 1; // bump the index to process the next code unit\n\t\t\t}\n\t\t}\n\t\t// Check whether we've found the desired number of code points...\n\t\tif ( cnt === n ) {\n\t\t\tbreak;\n\t\t}\n\t}\n\treturn str.substring( 0, i );\n}\n\n\n// EXPORTS //\n\nexport default removeLast;\n"],"names":["RE_UTF16_LOW_SURROGATE","RE_UTF16_HIGH_SURROGATE","str","n","ch1","ch2","cnt","i","length","test","substring"],"mappings":";yCAsBA,IAAIA,EAAyB,kBACzBC,EAA0B,yBA4B9B,SAAqBC,EAAKC,GACzB,IACIC,EACAC,EACAC,EACAC,EACJ,GAAW,IAANJ,EACJ,OAAOD,EAMR,IAHAI,EAAM,EAGAC,EAJAL,EAAIM,OAIM,EAAGD,GAAK,EAAGA,IAAM,CAKhC,GAJAH,EAAMF,EAAKK,GACXD,GAAO,EAGFN,EAAuBS,KAAML,GAAQ,CAEzC,GAAW,IAANG,EAEJ,MAGDF,EAAMH,EAAKK,EAAE,GACRN,EAAwBQ,KAAMJ,KAElCE,GAAK,EAEN,CAED,GAAKD,IAAQH,EACZ,KAED,CACD,OAAOD,EAAIQ,UAAW,EAAGH,EAC1B"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 9860da0..0000000 --- a/lib/index.js +++ /dev/null @@ -1,43 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Remove the last `n` Unicode code points of a string. -* -* @module @stdlib/string-base-remove-last-code-point -* -* @example -* var removeLast = require( '@stdlib/string-base-remove-last-code-point' ); -* -* var out = removeLast( 'last man standing', 1 ); -* // returns 'last man standin' -* -* out = removeLast( 'Hidden Treasures', 1 ); -* // returns 'Hidden Treasure'; -*/ - -// 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 fc34187..0000000 --- a/lib/main.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// VARIABLES // - -var RE_UTF16_LOW_SURROGATE = /[\uDC00-\uDFFF]/; // TODO: replace with stdlib pkg -var RE_UTF16_HIGH_SURROGATE = /[\uD800-\uDBFF]/; // TODO: replace with stdlib pkg - - -// MAIN // - -/** -* Removes the last `n` Unicode code points of a string. -* -* @param {string} str - input string -* @param {NonNegativeInteger} n - number of Unicode code points to remove -* @returns {string} output string -* -* @example -* var out = removeLast( 'last man standing', 1 ); -* // returns 'last man standin' -* -* @example -* var out = removeLast( 'presidential election', 1 ); -* // returns 'presidential electio' -* -* @example -* var out = removeLast( 'JavaScript', 1 ); -* // returns 'JavaScrip' -* -* @example -* var out = removeLast( 'Hidden Treasures', 1 ); -* // returns 'Hidden Treasure' -*/ -function removeLast( str, n ) { - var len; - var ch1; - var ch2; - var cnt; - var i; - if ( n === 0 ) { - return str; - } - len = str.length; - cnt = 0; - - // Process the string one Unicode code unit at a time and count UTF-16 surrogate pairs as a single Unicode code point... - for ( i = len - 1; i >= 0; i-- ) { - ch1 = str[ i ]; - cnt += 1; - - // Check for a low UTF-16 surrogate... - if ( RE_UTF16_LOW_SURROGATE.test( ch1 ) ) { - // Check for an unpaired surrogate at the end of the input string... - if ( i === 0 ) { - // We found an unpaired surrogate... - break; - } - // Check whether the high surrogate is paired with a low surrogate... - ch2 = str[ i-1 ]; - if ( RE_UTF16_HIGH_SURROGATE.test( ch2 ) ) { - // We found a surrogate pair: - i -= 1; // bump the index to process the next code unit - } - } - // Check whether we've found the desired number of code points... - if ( cnt === n ) { - break; - } - } - return str.substring( 0, i ); -} - - -// EXPORTS // - -module.exports = removeLast; diff --git a/package.json b/package.json index 7d6f49d..f3c9a46 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,7 @@ "version": "0.2.1", "description": "Remove the last Unicode code point of a string.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "main": "./index.js", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,31 +12,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/error-tools-fmtprodmsg": "^0.2.1" - }, - "devDependencies": { - "@stdlib/assert-is-string": "^0.2.1", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.1" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdstring", @@ -81,4 +32,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/stats_browser.html b/stats_browser.html new file mode 100644 index 0000000..2c17dcc --- /dev/null +++ b/stats_browser.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/stats_node.html b/stats_node.html new file mode 100644 index 0000000..1e086d4 --- /dev/null +++ b/stats_node.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index a25545e..0000000 --- a/test/test.js +++ /dev/null @@ -1,108 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var removeLast = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof removeLast, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns an empty string if provided an empty string', function test( t ) { - t.strictEqual( removeLast( '', 1 ), '', 'returns expected value' ); - t.strictEqual( removeLast( '', 2 ), '', 'returns expected value' ); - t.strictEqual( removeLast( '', 3 ), '', 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns the input string if provided zero as the second argument', function test( t ) { - t.strictEqual( removeLast( 'hello world', 0 ), 'hello world', 'returns expected value' ); - t.end(); -}); - -tape( 'the function removes the last Unicode code point of a provided string (ascii)', function test( t ) { - var out; - - out = removeLast( 'hello world', 1 ); - t.strictEqual( out, 'hello worl', 'returns expected value' ); - - out = removeLast( '!!!', 1 ); - t.strictEqual( out, '!!', 'returns expected value' ); - - out = removeLast( 'Hello World', 1 ); - t.strictEqual( out, 'Hello Worl', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function removes the last Unicode code point of a provided string (Unicode)', function test( t ) { - var out; - - out = removeLast( 'अनुच्छेद', 1 ); - t.strictEqual( out, 'अनुच्छे', 'returns expected value' ); - - out = removeLast( '六书/六書', 1 ); - t.strictEqual( out, '六书/六', 'returns expected value' ); - - out = removeLast( '𐒻𐓟', 1 ); - t.strictEqual( out, '𐒻', 'returns expected value' ); - - out = removeLast( '𐒻𐓟', 1 ); - t.strictEqual( out, '𐒻', 'returns expected value' ); - - out = removeLast( '\uDC00', 1 ); - t.strictEqual( out, '', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports removing the last `n` Unicode code points of a provided string', function test( t ) { - var out; - - out = removeLast( 'hello world', 1 ); - t.strictEqual( out, 'hello worl', 'returns expected value' ); - - out = removeLast( 'hello world', 7 ); - t.strictEqual( out, 'hell', 'returns expected value' ); - - out = removeLast( '!!!', 1 ); - t.strictEqual( out, '!!', 'returns expected value' ); - - out = removeLast( '!!!', 2 ); - t.strictEqual( out, '!', 'returns expected value' ); - - out = removeLast( 'अनुच्छेद', 1 ); - t.strictEqual( out, 'अनुच्छे', 'returns expected value' ); - - out = removeLast( '六书/六書', 3 ); - t.strictEqual( out, '六书', 'returns expected value' ); - - out = removeLast( '𐒻𐓟𐓟', 2 ); - t.strictEqual( out, '𐒻', 'returns expected value' ); - - t.end(); -}); From c443252cdeeb38174e8728c73698844f9e9c8c4c Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 26 Jul 2024 19:03:12 +0000 Subject: [PATCH 64/92] Transform error messages --- package.json | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 736b216..9788559 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,9 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": {}, + "dependencies": { + "@stdlib/error-tools-fmtprodmsg": "^0.2.1" + }, "devDependencies": { "@stdlib/assert-is-string": "^0.2.1", "tape": "git+https://github.com/kgryte/tape.git#fix/globby", @@ -79,4 +81,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 1c109cdb998baaad77960b9b3cb998a067486d93 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 26 Jul 2024 19:04:43 +0000 Subject: [PATCH 65/92] Remove files --- browser.js | 3 - browser.js.map | 1 - index.js | 3 - index.js.map | 1 - stats_browser.html | 4842 -------------------------------------------- stats_node.html | 4842 -------------------------------------------- 6 files changed, 9692 deletions(-) delete mode 100644 browser.js delete mode 100644 browser.js.map delete mode 100644 index.js delete mode 100644 index.js.map delete mode 100644 stats_browser.html delete mode 100644 stats_node.html diff --git a/browser.js b/browser.js deleted file mode 100644 index f3a511a..0000000 --- a/browser.js +++ /dev/null @@ -1,3 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -var e,t;e=this,t=function(){"use strict";var e=/[\uDC00-\uDFFF]/,t=/[\uD800-\uDBFF]/;return function(n,f){var i,o,r,u;if(0===f)return n;for(r=0,u=n.length-1;u>=0;u--){if(i=n[u],r+=1,e.test(i)){if(0===u)break;o=n[u-1],t.test(o)&&(u-=1)}if(r===f)break}return n.substring(0,u)}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).removeLastCodePoint=t(); -//# sourceMappingURL=browser.js.map diff --git a/browser.js.map b/browser.js.map deleted file mode 100644 index 19908eb..0000000 --- a/browser.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"browser.js","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\nvar RE_UTF16_LOW_SURROGATE = /[\\uDC00-\\uDFFF]/; // TODO: replace with stdlib pkg\nvar RE_UTF16_HIGH_SURROGATE = /[\\uD800-\\uDBFF]/; // TODO: replace with stdlib pkg\n\n\n// MAIN //\n\n/**\n* Removes the last `n` Unicode code points of a string.\n*\n* @param {string} str - input string\n* @param {NonNegativeInteger} n - number of Unicode code points to remove\n* @returns {string} output string\n*\n* @example\n* var out = removeLast( 'last man standing', 1 );\n* // returns 'last man standin'\n*\n* @example\n* var out = removeLast( 'presidential election', 1 );\n* // returns 'presidential electio'\n*\n* @example\n* var out = removeLast( 'JavaScript', 1 );\n* // returns 'JavaScrip'\n*\n* @example\n* var out = removeLast( 'Hidden Treasures', 1 );\n* // returns 'Hidden Treasure'\n*/\nfunction removeLast( str, n ) {\n\tvar len;\n\tvar ch1;\n\tvar ch2;\n\tvar cnt;\n\tvar i;\n\tif ( n === 0 ) {\n\t\treturn str;\n\t}\n\tlen = str.length;\n\tcnt = 0;\n\n\t// Process the string one Unicode code unit at a time and count UTF-16 surrogate pairs as a single Unicode code point...\n\tfor ( i = len - 1; i >= 0; i-- ) {\n\t\tch1 = str[ i ];\n\t\tcnt += 1;\n\n\t\t// Check for a low UTF-16 surrogate...\n\t\tif ( RE_UTF16_LOW_SURROGATE.test( ch1 ) ) {\n\t\t\t// Check for an unpaired surrogate at the end of the input string...\n\t\t\tif ( i === 0 ) {\n\t\t\t\t// We found an unpaired surrogate...\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\t// Check whether the high surrogate is paired with a low surrogate...\n\t\t\tch2 = str[ i-1 ];\n\t\t\tif ( RE_UTF16_HIGH_SURROGATE.test( ch2 ) ) {\n\t\t\t\t// We found a surrogate pair:\n\t\t\t\ti -= 1; // bump the index to process the next code unit\n\t\t\t}\n\t\t}\n\t\t// Check whether we've found the desired number of code points...\n\t\tif ( cnt === n ) {\n\t\t\tbreak;\n\t\t}\n\t}\n\treturn str.substring( 0, i );\n}\n\n\n// EXPORTS //\n\nexport default removeLast;\n"],"names":["RE_UTF16_LOW_SURROGATE","RE_UTF16_HIGH_SURROGATE","str","n","ch1","ch2","cnt","i","length","test","substring"],"mappings":";yCAsBA,IAAIA,EAAyB,kBACzBC,EAA0B,yBA4B9B,SAAqBC,EAAKC,GACzB,IACIC,EACAC,EACAC,EACAC,EACJ,GAAW,IAANJ,EACJ,OAAOD,EAMR,IAHAI,EAAM,EAGAC,EAJAL,EAAIM,OAIM,EAAGD,GAAK,EAAGA,IAAM,CAKhC,GAJAH,EAAMF,EAAKK,GACXD,GAAO,EAGFN,EAAuBS,KAAML,GAAQ,CAEzC,GAAW,IAANG,EAEJ,MAGDF,EAAMH,EAAKK,EAAE,GACRN,EAAwBQ,KAAMJ,KAElCE,GAAK,EAEN,CAED,GAAKD,IAAQH,EACZ,KAED,CACD,OAAOD,EAAIQ,UAAW,EAAGH,EAC1B"} \ No newline at end of file diff --git a/index.js b/index.js deleted file mode 100644 index 4e500d1..0000000 --- a/index.js +++ /dev/null @@ -1,3 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -var e,t;e=this,t=function(){"use strict";var e=/[\uDC00-\uDFFF]/,t=/[\uD800-\uDBFF]/;return function(n,f){var i,o,r,u;if(0===f)return n;for(r=0,u=n.length-1;u>=0;u--){if(i=n[u],r+=1,e.test(i)){if(0===u)break;o=n[u-1],t.test(o)&&(u-=1)}if(r===f)break}return n.substring(0,u)}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).removeLastCodePoint=t(); -//# sourceMappingURL=index.js.map diff --git a/index.js.map b/index.js.map deleted file mode 100644 index d557af8..0000000 --- a/index.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.js","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\nvar RE_UTF16_LOW_SURROGATE = /[\\uDC00-\\uDFFF]/; // TODO: replace with stdlib pkg\nvar RE_UTF16_HIGH_SURROGATE = /[\\uD800-\\uDBFF]/; // TODO: replace with stdlib pkg\n\n\n// MAIN //\n\n/**\n* Removes the last `n` Unicode code points of a string.\n*\n* @param {string} str - input string\n* @param {NonNegativeInteger} n - number of Unicode code points to remove\n* @returns {string} output string\n*\n* @example\n* var out = removeLast( 'last man standing', 1 );\n* // returns 'last man standin'\n*\n* @example\n* var out = removeLast( 'presidential election', 1 );\n* // returns 'presidential electio'\n*\n* @example\n* var out = removeLast( 'JavaScript', 1 );\n* // returns 'JavaScrip'\n*\n* @example\n* var out = removeLast( 'Hidden Treasures', 1 );\n* // returns 'Hidden Treasure'\n*/\nfunction removeLast( str, n ) {\n\tvar len;\n\tvar ch1;\n\tvar ch2;\n\tvar cnt;\n\tvar i;\n\tif ( n === 0 ) {\n\t\treturn str;\n\t}\n\tlen = str.length;\n\tcnt = 0;\n\n\t// Process the string one Unicode code unit at a time and count UTF-16 surrogate pairs as a single Unicode code point...\n\tfor ( i = len - 1; i >= 0; i-- ) {\n\t\tch1 = str[ i ];\n\t\tcnt += 1;\n\n\t\t// Check for a low UTF-16 surrogate...\n\t\tif ( RE_UTF16_LOW_SURROGATE.test( ch1 ) ) {\n\t\t\t// Check for an unpaired surrogate at the end of the input string...\n\t\t\tif ( i === 0 ) {\n\t\t\t\t// We found an unpaired surrogate...\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\t// Check whether the high surrogate is paired with a low surrogate...\n\t\t\tch2 = str[ i-1 ];\n\t\t\tif ( RE_UTF16_HIGH_SURROGATE.test( ch2 ) ) {\n\t\t\t\t// We found a surrogate pair:\n\t\t\t\ti -= 1; // bump the index to process the next code unit\n\t\t\t}\n\t\t}\n\t\t// Check whether we've found the desired number of code points...\n\t\tif ( cnt === n ) {\n\t\t\tbreak;\n\t\t}\n\t}\n\treturn str.substring( 0, i );\n}\n\n\n// EXPORTS //\n\nexport default removeLast;\n"],"names":["RE_UTF16_LOW_SURROGATE","RE_UTF16_HIGH_SURROGATE","str","n","ch1","ch2","cnt","i","length","test","substring"],"mappings":";yCAsBA,IAAIA,EAAyB,kBACzBC,EAA0B,yBA4B9B,SAAqBC,EAAKC,GACzB,IACIC,EACAC,EACAC,EACAC,EACJ,GAAW,IAANJ,EACJ,OAAOD,EAMR,IAHAI,EAAM,EAGAC,EAJAL,EAAIM,OAIM,EAAGD,GAAK,EAAGA,IAAM,CAKhC,GAJAH,EAAMF,EAAKK,GACXD,GAAO,EAGFN,EAAuBS,KAAML,GAAQ,CAEzC,GAAW,IAANG,EAEJ,MAGDF,EAAMH,EAAKK,EAAE,GACRN,EAAwBQ,KAAMJ,KAElCE,GAAK,EAEN,CAED,GAAKD,IAAQH,EACZ,KAED,CACD,OAAOD,EAAIQ,UAAW,EAAGH,EAC1B"} \ No newline at end of file diff --git a/stats_browser.html b/stats_browser.html deleted file mode 100644 index 2c17dcc..0000000 --- a/stats_browser.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - diff --git a/stats_node.html b/stats_node.html deleted file mode 100644 index 1e086d4..0000000 --- a/stats_node.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From a6b12e0476fb2d4826ca759f82b92d201dd6162a Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 26 Jul 2024 19:04:56 +0000 Subject: [PATCH 66/92] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 66 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 794 ---- .github/workflows/publish.yml | 252 -- .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .gitignore | 188 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 99 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 52 +- SECURITY.md | 5 - benchmark/benchmark.js | 56 - branches.md | 56 - browser.js | 3 + browser.js.map | 1 + dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 29 - docs/types/index.d.ts | 53 - docs/types/test.ts | 57 - examples/index.js | 33 - index.js | 3 + index.js.map | 1 + lib/index.js | 43 - lib/main.js | 94 - package.json | 53 +- stats_browser.html | 4842 +++++++++++++++++++++ stats_node.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 108 - 45 files changed, 9728 insertions(+), 3923 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md create mode 100644 browser.js create mode 100644 browser.js.map 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/index.d.ts delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js create mode 100644 index.js create mode 100644 index.js.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats_browser.html create mode 100644 stats_node.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 52cd9c4..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/base/remove-last-code-point) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 533eeee..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/base/remove-last-code-point) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 2a724f2..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: '29 5 * * 0' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index f4575e9..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,794 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n +``` -```javascript -var removeLastCodePoint = require( '@stdlib/string-base-remove-last-code-point' ); +If no recognized module system is present, access bundle contents via the global scope: + +```html + ``` #### removeLastCodePoint( str, n ) @@ -91,8 +97,13 @@ out = removeLastCodePoint( 'foo bar', 10 ); -```javascript -var removeLastCodePoint = require( '@stdlib/string-base-remove-last-code-point' ); +```html + + + + + + + ```
diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index a39bd29..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,56 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var removeLast = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var values; - var out; - var i; - - values = [ - 'beep boop', - 'foo bar', - 'xyz abc', - '🐶🐮🐷🐰🐸' - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = removeLast( values[ i%values.length ], 1 ); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( !isString( out ) ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index f585c99..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/base/remove-last-code-point" -%% click B href "https://github.com/stdlib-js/string-base-remove-last-code-point/tree/main" -%% click C href "https://github.com/stdlib-js/string-base-remove-last-code-point/tree/production" -%% click D href "https://github.com/stdlib-js/string-base-remove-last-code-point/tree/esm" -%% click E href "https://github.com/stdlib-js/string-base-remove-last-code-point/tree/deno" -%% click F href "https://github.com/stdlib-js/string-base-remove-last-code-point/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/base/remove-last-code-point -[production-url]: https://github.com/stdlib-js/string-base-remove-last-code-point/tree/production -[deno-url]: https://github.com/stdlib-js/string-base-remove-last-code-point/tree/deno -[deno-readme]: https://github.com/stdlib-js/string-base-remove-last-code-point/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/string-base-remove-last-code-point/tree/umd -[umd-readme]: https://github.com/stdlib-js/string-base-remove-last-code-point/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/string-base-remove-last-code-point/tree/esm -[esm-readme]: https://github.com/stdlib-js/string-base-remove-last-code-point/blob/esm/README.md \ No newline at end of file diff --git a/browser.js b/browser.js new file mode 100644 index 0000000..f3a511a --- /dev/null +++ b/browser.js @@ -0,0 +1,3 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +var e,t;e=this,t=function(){"use strict";var e=/[\uDC00-\uDFFF]/,t=/[\uD800-\uDBFF]/;return function(n,f){var i,o,r,u;if(0===f)return n;for(r=0,u=n.length-1;u>=0;u--){if(i=n[u],r+=1,e.test(i)){if(0===u)break;o=n[u-1],t.test(o)&&(u-=1)}if(r===f)break}return n.substring(0,u)}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).removeLastCodePoint=t(); +//# sourceMappingURL=browser.js.map diff --git a/browser.js.map b/browser.js.map new file mode 100644 index 0000000..19908eb --- /dev/null +++ b/browser.js.map @@ -0,0 +1 @@ +{"version":3,"file":"browser.js","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\nvar RE_UTF16_LOW_SURROGATE = /[\\uDC00-\\uDFFF]/; // TODO: replace with stdlib pkg\nvar RE_UTF16_HIGH_SURROGATE = /[\\uD800-\\uDBFF]/; // TODO: replace with stdlib pkg\n\n\n// MAIN //\n\n/**\n* Removes the last `n` Unicode code points of a string.\n*\n* @param {string} str - input string\n* @param {NonNegativeInteger} n - number of Unicode code points to remove\n* @returns {string} output string\n*\n* @example\n* var out = removeLast( 'last man standing', 1 );\n* // returns 'last man standin'\n*\n* @example\n* var out = removeLast( 'presidential election', 1 );\n* // returns 'presidential electio'\n*\n* @example\n* var out = removeLast( 'JavaScript', 1 );\n* // returns 'JavaScrip'\n*\n* @example\n* var out = removeLast( 'Hidden Treasures', 1 );\n* // returns 'Hidden Treasure'\n*/\nfunction removeLast( str, n ) {\n\tvar len;\n\tvar ch1;\n\tvar ch2;\n\tvar cnt;\n\tvar i;\n\tif ( n === 0 ) {\n\t\treturn str;\n\t}\n\tlen = str.length;\n\tcnt = 0;\n\n\t// Process the string one Unicode code unit at a time and count UTF-16 surrogate pairs as a single Unicode code point...\n\tfor ( i = len - 1; i >= 0; i-- ) {\n\t\tch1 = str[ i ];\n\t\tcnt += 1;\n\n\t\t// Check for a low UTF-16 surrogate...\n\t\tif ( RE_UTF16_LOW_SURROGATE.test( ch1 ) ) {\n\t\t\t// Check for an unpaired surrogate at the end of the input string...\n\t\t\tif ( i === 0 ) {\n\t\t\t\t// We found an unpaired surrogate...\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\t// Check whether the high surrogate is paired with a low surrogate...\n\t\t\tch2 = str[ i-1 ];\n\t\t\tif ( RE_UTF16_HIGH_SURROGATE.test( ch2 ) ) {\n\t\t\t\t// We found a surrogate pair:\n\t\t\t\ti -= 1; // bump the index to process the next code unit\n\t\t\t}\n\t\t}\n\t\t// Check whether we've found the desired number of code points...\n\t\tif ( cnt === n ) {\n\t\t\tbreak;\n\t\t}\n\t}\n\treturn str.substring( 0, i );\n}\n\n\n// EXPORTS //\n\nexport default removeLast;\n"],"names":["RE_UTF16_LOW_SURROGATE","RE_UTF16_HIGH_SURROGATE","str","n","ch1","ch2","cnt","i","length","test","substring"],"mappings":";yCAsBA,IAAIA,EAAyB,kBACzBC,EAA0B,yBA4B9B,SAAqBC,EAAKC,GACzB,IACIC,EACAC,EACAC,EACAC,EACJ,GAAW,IAANJ,EACJ,OAAOD,EAMR,IAHAI,EAAM,EAGAC,EAJAL,EAAIM,OAIM,EAAGD,GAAK,EAAGA,IAAM,CAKhC,GAJAH,EAAMF,EAAKK,GACXD,GAAO,EAGFN,EAAuBS,KAAML,GAAQ,CAEzC,GAAW,IAANG,EAEJ,MAGDF,EAAMH,EAAKK,EAAE,GACRN,EAAwBQ,KAAMJ,KAElCE,GAAK,EAEN,CAED,GAAKD,IAAQH,EACZ,KAED,CACD,OAAOD,EAAIQ,UAAW,EAAGH,EAC1B"} \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index 8c96fd7..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import removeLast from '../docs/types/index'; -export = removeLast; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index e6b7220..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var s=function(e,t){return function(){return t||e((t={exports:{}}).exports,t),t.exports}};var f=s(function(D,n){ -var F=/[\uDC00-\uDFFF]/,c=/[\uD800-\uDBFF]/;function R(e,t){var i,u,v,a,r;if(t===0)return e;for(i=e.length,a=0,r=i-1;r>=0;r--){if(u=e[r],a+=1,F.test(u)){if(r===0)break;v=e[r-1],c.test(v)&&(r-=1)}if(a===t)break}return e.substring(0,r)}n.exports=R -});var _=f();module.exports=_; -/** @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 72561cf..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\nvar RE_UTF16_LOW_SURROGATE = /[\\uDC00-\\uDFFF]/; // TODO: replace with stdlib pkg\nvar RE_UTF16_HIGH_SURROGATE = /[\\uD800-\\uDBFF]/; // TODO: replace with stdlib pkg\n\n\n// MAIN //\n\n/**\n* Removes the last `n` Unicode code points of a string.\n*\n* @param {string} str - input string\n* @param {NonNegativeInteger} n - number of Unicode code points to remove\n* @returns {string} output string\n*\n* @example\n* var out = removeLast( 'last man standing', 1 );\n* // returns 'last man standin'\n*\n* @example\n* var out = removeLast( 'presidential election', 1 );\n* // returns 'presidential electio'\n*\n* @example\n* var out = removeLast( 'JavaScript', 1 );\n* // returns 'JavaScrip'\n*\n* @example\n* var out = removeLast( 'Hidden Treasures', 1 );\n* // returns 'Hidden Treasure'\n*/\nfunction removeLast( str, n ) {\n\tvar len;\n\tvar ch1;\n\tvar ch2;\n\tvar cnt;\n\tvar i;\n\tif ( n === 0 ) {\n\t\treturn str;\n\t}\n\tlen = str.length;\n\tcnt = 0;\n\n\t// Process the string one Unicode code unit at a time and count UTF-16 surrogate pairs as a single Unicode code point...\n\tfor ( i = len - 1; i >= 0; i-- ) {\n\t\tch1 = str[ i ];\n\t\tcnt += 1;\n\n\t\t// Check for a low UTF-16 surrogate...\n\t\tif ( RE_UTF16_LOW_SURROGATE.test( ch1 ) ) {\n\t\t\t// Check for an unpaired surrogate at the end of the input string...\n\t\t\tif ( i === 0 ) {\n\t\t\t\t// We found an unpaired surrogate...\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\t// Check whether the high surrogate is paired with a low surrogate...\n\t\t\tch2 = str[ i-1 ];\n\t\t\tif ( RE_UTF16_HIGH_SURROGATE.test( ch2 ) ) {\n\t\t\t\t// We found a surrogate pair:\n\t\t\t\ti -= 1; // bump the index to process the next code unit\n\t\t\t}\n\t\t}\n\t\t// Check whether we've found the desired number of code points...\n\t\tif ( cnt === n ) {\n\t\t\tbreak;\n\t\t}\n\t}\n\treturn str.substring( 0, i );\n}\n\n\n// EXPORTS //\n\nmodule.exports = removeLast;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Remove the last `n` Unicode code points of a string.\n*\n* @module @stdlib/string-base-remove-last-code-point\n*\n* @example\n* var removeLast = require( '@stdlib/string-base-remove-last-code-point' );\n*\n* var out = removeLast( 'last man standing', 1 );\n* // returns 'last man standin'\n*\n* out = removeLast( 'Hidden Treasures', 1 );\n* // returns 'Hidden Treasure';\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,EAAyB,kBACzBC,EAA0B,kBA4B9B,SAASC,EAAYC,EAAKC,EAAI,CAC7B,IAAIC,EACAC,EACAC,EACAC,EACAC,EACJ,GAAKL,IAAM,EACV,OAAOD,EAMR,IAJAE,EAAMF,EAAI,OACVK,EAAM,EAGAC,EAAIJ,EAAM,EAAGI,GAAK,EAAGA,IAAM,CAKhC,GAJAH,EAAMH,EAAKM,CAAE,EACbD,GAAO,EAGFR,EAAuB,KAAMM,CAAI,EAAI,CAEzC,GAAKG,IAAM,EAEV,MAGDF,EAAMJ,EAAKM,EAAE,CAAE,EACVR,EAAwB,KAAMM,CAAI,IAEtCE,GAAK,EAEP,CAEA,GAAKD,IAAQJ,EACZ,KAEF,CACA,OAAOD,EAAI,UAAW,EAAGM,CAAE,CAC5B,CAKAV,EAAO,QAAUG,ICxDjB,IAAIQ,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "RE_UTF16_LOW_SURROGATE", "RE_UTF16_HIGH_SURROGATE", "removeLast", "str", "n", "len", "ch1", "ch2", "cnt", "i", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index a08ea55..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,29 +0,0 @@ - -{{alias}}( str, n ) - Removes the last `n` Unicode code points of a string. - - Parameters - ---------- - str: string - Input string. - - n: integer - Number of Unicode code points to remove. - - Returns - ------- - out: string - Output string. - - Examples - -------- - > var out = {{alias}}( 'beep', 1 ) - 'bee' - > out = {{alias}}( 'Boop', 1 ) - 'Boo' - > out = {{alias}}( 'foo bar', 5 ) - 'fo' - - See Also - -------- - diff --git a/docs/types/index.d.ts b/docs/types/index.d.ts deleted file mode 100644 index 8a1c90b..0000000 --- a/docs/types/index.d.ts +++ /dev/null @@ -1,53 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 - -/** -* Removes the last `n` Unicode code points of a string. -* -* @param str - input string -* @param n - number of code points to remove -* @returns output string -* -* @example -* var out = removeLast( 'last man standing', 1 ); -* // returns 'last man standin' -* -* @example -* var out = removeLast( 'presidential election', 1 ); -* // returns 'presidential electio' -* -* @example -* var out = removeLast( 'JavaScript', 1 ); -* // returns 'JavaScrip' -* -* @example -* var out = removeLast( 'Hidden Treasures', 1 ); -* // returns 'Hidden Treasure' -* -* @example -* var out = removeLast( 'foo bar', 5 ); -* // returns 'fo' -*/ -declare function removeLast( str: string, n: number ): string; - - -// EXPORTS // - -export = removeLast; diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index fd426d2..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,57 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 removeLast = require( './index' ); - - -// TESTS // - -// The function returns a string... -{ - removeLast( 'abc', 1 ); // $ExpectType string -} - -// The compiler throws an error if the function is provided a value other than a string... -{ - removeLast( true, 1 ); // $ExpectError - removeLast( false, 1 ); // $ExpectError - removeLast( null, 1 ); // $ExpectError - removeLast( undefined, 1 ); // $ExpectError - removeLast( 5, 1 ); // $ExpectError - removeLast( [], 1 ); // $ExpectError - removeLast( {}, 1 ); // $ExpectError - removeLast( ( x: number ): number => x, 1 ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument that is not a number... -{ - removeLast( 'abc', true ); // $ExpectError - removeLast( 'abc', false ); // $ExpectError - removeLast( 'abc', null ); // $ExpectError - removeLast( 'abc', 'abc' ); // $ExpectError - removeLast( 'abc', [] ); // $ExpectError - removeLast( 'abc', {} ); // $ExpectError - removeLast( 'abc', ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - removeLast(); // $ExpectError - removeLast( 'abc' ); // $ExpectError - removeLast( 'abc', 1, 2 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 085633e..0000000 --- a/examples/index.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var removeLastCodePoint = require( './../lib' ); - -console.log( removeLastCodePoint( 'presidential election', 1 ) ); -// => 'presidential electio' - -console.log( removeLastCodePoint( 'JavaScript', 1 ) ); -// => 'JavaScrip' - -console.log( removeLastCodePoint( 'The Last of the Mohicans', 5 ) ); -// => 'The Last of the Moh' - -console.log( removeLastCodePoint( 'अनुच्छेद', 1 ) ); -// => 'अनुच्छे' diff --git a/index.js b/index.js new file mode 100644 index 0000000..4e500d1 --- /dev/null +++ b/index.js @@ -0,0 +1,3 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +var e,t;e=this,t=function(){"use strict";var e=/[\uDC00-\uDFFF]/,t=/[\uD800-\uDBFF]/;return function(n,f){var i,o,r,u;if(0===f)return n;for(r=0,u=n.length-1;u>=0;u--){if(i=n[u],r+=1,e.test(i)){if(0===u)break;o=n[u-1],t.test(o)&&(u-=1)}if(r===f)break}return n.substring(0,u)}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).removeLastCodePoint=t(); +//# sourceMappingURL=index.js.map diff --git a/index.js.map b/index.js.map new file mode 100644 index 0000000..d557af8 --- /dev/null +++ b/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\nvar RE_UTF16_LOW_SURROGATE = /[\\uDC00-\\uDFFF]/; // TODO: replace with stdlib pkg\nvar RE_UTF16_HIGH_SURROGATE = /[\\uD800-\\uDBFF]/; // TODO: replace with stdlib pkg\n\n\n// MAIN //\n\n/**\n* Removes the last `n` Unicode code points of a string.\n*\n* @param {string} str - input string\n* @param {NonNegativeInteger} n - number of Unicode code points to remove\n* @returns {string} output string\n*\n* @example\n* var out = removeLast( 'last man standing', 1 );\n* // returns 'last man standin'\n*\n* @example\n* var out = removeLast( 'presidential election', 1 );\n* // returns 'presidential electio'\n*\n* @example\n* var out = removeLast( 'JavaScript', 1 );\n* // returns 'JavaScrip'\n*\n* @example\n* var out = removeLast( 'Hidden Treasures', 1 );\n* // returns 'Hidden Treasure'\n*/\nfunction removeLast( str, n ) {\n\tvar len;\n\tvar ch1;\n\tvar ch2;\n\tvar cnt;\n\tvar i;\n\tif ( n === 0 ) {\n\t\treturn str;\n\t}\n\tlen = str.length;\n\tcnt = 0;\n\n\t// Process the string one Unicode code unit at a time and count UTF-16 surrogate pairs as a single Unicode code point...\n\tfor ( i = len - 1; i >= 0; i-- ) {\n\t\tch1 = str[ i ];\n\t\tcnt += 1;\n\n\t\t// Check for a low UTF-16 surrogate...\n\t\tif ( RE_UTF16_LOW_SURROGATE.test( ch1 ) ) {\n\t\t\t// Check for an unpaired surrogate at the end of the input string...\n\t\t\tif ( i === 0 ) {\n\t\t\t\t// We found an unpaired surrogate...\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\t// Check whether the high surrogate is paired with a low surrogate...\n\t\t\tch2 = str[ i-1 ];\n\t\t\tif ( RE_UTF16_HIGH_SURROGATE.test( ch2 ) ) {\n\t\t\t\t// We found a surrogate pair:\n\t\t\t\ti -= 1; // bump the index to process the next code unit\n\t\t\t}\n\t\t}\n\t\t// Check whether we've found the desired number of code points...\n\t\tif ( cnt === n ) {\n\t\t\tbreak;\n\t\t}\n\t}\n\treturn str.substring( 0, i );\n}\n\n\n// EXPORTS //\n\nexport default removeLast;\n"],"names":["RE_UTF16_LOW_SURROGATE","RE_UTF16_HIGH_SURROGATE","str","n","ch1","ch2","cnt","i","length","test","substring"],"mappings":";yCAsBA,IAAIA,EAAyB,kBACzBC,EAA0B,yBA4B9B,SAAqBC,EAAKC,GACzB,IACIC,EACAC,EACAC,EACAC,EACJ,GAAW,IAANJ,EACJ,OAAOD,EAMR,IAHAI,EAAM,EAGAC,EAJAL,EAAIM,OAIM,EAAGD,GAAK,EAAGA,IAAM,CAKhC,GAJAH,EAAMF,EAAKK,GACXD,GAAO,EAGFN,EAAuBS,KAAML,GAAQ,CAEzC,GAAW,IAANG,EAEJ,MAGDF,EAAMH,EAAKK,EAAE,GACRN,EAAwBQ,KAAMJ,KAElCE,GAAK,EAEN,CAED,GAAKD,IAAQH,EACZ,KAED,CACD,OAAOD,EAAIQ,UAAW,EAAGH,EAC1B"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 9860da0..0000000 --- a/lib/index.js +++ /dev/null @@ -1,43 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Remove the last `n` Unicode code points of a string. -* -* @module @stdlib/string-base-remove-last-code-point -* -* @example -* var removeLast = require( '@stdlib/string-base-remove-last-code-point' ); -* -* var out = removeLast( 'last man standing', 1 ); -* // returns 'last man standin' -* -* out = removeLast( 'Hidden Treasures', 1 ); -* // returns 'Hidden Treasure'; -*/ - -// 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 fc34187..0000000 --- a/lib/main.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// VARIABLES // - -var RE_UTF16_LOW_SURROGATE = /[\uDC00-\uDFFF]/; // TODO: replace with stdlib pkg -var RE_UTF16_HIGH_SURROGATE = /[\uD800-\uDBFF]/; // TODO: replace with stdlib pkg - - -// MAIN // - -/** -* Removes the last `n` Unicode code points of a string. -* -* @param {string} str - input string -* @param {NonNegativeInteger} n - number of Unicode code points to remove -* @returns {string} output string -* -* @example -* var out = removeLast( 'last man standing', 1 ); -* // returns 'last man standin' -* -* @example -* var out = removeLast( 'presidential election', 1 ); -* // returns 'presidential electio' -* -* @example -* var out = removeLast( 'JavaScript', 1 ); -* // returns 'JavaScrip' -* -* @example -* var out = removeLast( 'Hidden Treasures', 1 ); -* // returns 'Hidden Treasure' -*/ -function removeLast( str, n ) { - var len; - var ch1; - var ch2; - var cnt; - var i; - if ( n === 0 ) { - return str; - } - len = str.length; - cnt = 0; - - // Process the string one Unicode code unit at a time and count UTF-16 surrogate pairs as a single Unicode code point... - for ( i = len - 1; i >= 0; i-- ) { - ch1 = str[ i ]; - cnt += 1; - - // Check for a low UTF-16 surrogate... - if ( RE_UTF16_LOW_SURROGATE.test( ch1 ) ) { - // Check for an unpaired surrogate at the end of the input string... - if ( i === 0 ) { - // We found an unpaired surrogate... - break; - } - // Check whether the high surrogate is paired with a low surrogate... - ch2 = str[ i-1 ]; - if ( RE_UTF16_HIGH_SURROGATE.test( ch2 ) ) { - // We found a surrogate pair: - i -= 1; // bump the index to process the next code unit - } - } - // Check whether we've found the desired number of code points... - if ( cnt === n ) { - break; - } - } - return str.substring( 0, i ); -} - - -// EXPORTS // - -module.exports = removeLast; diff --git a/package.json b/package.json index 9788559..e1a7e6d 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,7 @@ "version": "0.2.2", "description": "Remove the last Unicode code point of a string.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "main": "./index.js", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,31 +12,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/error-tools-fmtprodmsg": "^0.2.1" - }, - "devDependencies": { - "@stdlib/assert-is-string": "^0.2.1", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.1" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdstring", @@ -81,4 +32,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/stats_browser.html b/stats_browser.html new file mode 100644 index 0000000..2c17dcc --- /dev/null +++ b/stats_browser.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/stats_node.html b/stats_node.html new file mode 100644 index 0000000..1e086d4 --- /dev/null +++ b/stats_node.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index a25545e..0000000 --- a/test/test.js +++ /dev/null @@ -1,108 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var removeLast = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof removeLast, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns an empty string if provided an empty string', function test( t ) { - t.strictEqual( removeLast( '', 1 ), '', 'returns expected value' ); - t.strictEqual( removeLast( '', 2 ), '', 'returns expected value' ); - t.strictEqual( removeLast( '', 3 ), '', 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns the input string if provided zero as the second argument', function test( t ) { - t.strictEqual( removeLast( 'hello world', 0 ), 'hello world', 'returns expected value' ); - t.end(); -}); - -tape( 'the function removes the last Unicode code point of a provided string (ascii)', function test( t ) { - var out; - - out = removeLast( 'hello world', 1 ); - t.strictEqual( out, 'hello worl', 'returns expected value' ); - - out = removeLast( '!!!', 1 ); - t.strictEqual( out, '!!', 'returns expected value' ); - - out = removeLast( 'Hello World', 1 ); - t.strictEqual( out, 'Hello Worl', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function removes the last Unicode code point of a provided string (Unicode)', function test( t ) { - var out; - - out = removeLast( 'अनुच्छेद', 1 ); - t.strictEqual( out, 'अनुच्छे', 'returns expected value' ); - - out = removeLast( '六书/六書', 1 ); - t.strictEqual( out, '六书/六', 'returns expected value' ); - - out = removeLast( '𐒻𐓟', 1 ); - t.strictEqual( out, '𐒻', 'returns expected value' ); - - out = removeLast( '𐒻𐓟', 1 ); - t.strictEqual( out, '𐒻', 'returns expected value' ); - - out = removeLast( '\uDC00', 1 ); - t.strictEqual( out, '', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports removing the last `n` Unicode code points of a provided string', function test( t ) { - var out; - - out = removeLast( 'hello world', 1 ); - t.strictEqual( out, 'hello worl', 'returns expected value' ); - - out = removeLast( 'hello world', 7 ); - t.strictEqual( out, 'hell', 'returns expected value' ); - - out = removeLast( '!!!', 1 ); - t.strictEqual( out, '!!', 'returns expected value' ); - - out = removeLast( '!!!', 2 ); - t.strictEqual( out, '!', 'returns expected value' ); - - out = removeLast( 'अनुच्छेद', 1 ); - t.strictEqual( out, 'अनुच्छे', 'returns expected value' ); - - out = removeLast( '六书/六書', 3 ); - t.strictEqual( out, '六书', 'returns expected value' ); - - out = removeLast( '𐒻𐓟𐓟', 2 ); - t.strictEqual( out, '𐒻', 'returns expected value' ); - - t.end(); -}); From ab7f84c58b26a5ef1564f6a4c9605e3884623624 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 26 Jul 2024 19:05:16 +0000 Subject: [PATCH 67/92] Update README.md for UMD bundle v0.2.2 --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 32c9fad..a574241 100644 --- a/README.md +++ b/README.md @@ -44,7 +44,7 @@ limitations under the License. To use in Observable, ```javascript -removeLastCodePoint = require( 'https://cdn.jsdelivr.net/gh/stdlib-js/string-base-remove-last-code-point@umd/browser.js' ) +removeLastCodePoint = require( 'https://cdn.jsdelivr.net/gh/stdlib-js/string-base-remove-last-code-point@v0.2.2-umd/browser.js' ) ``` To vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build: @@ -56,7 +56,7 @@ var removeLastCodePoint = require( 'path/to/vendor/umd/string-base-remove-last-c To include the bundle in a webpage, ```html - + ``` If no recognized module system is present, access bundle contents via the global scope: @@ -101,7 +101,7 @@ out = removeLastCodePoint( 'foo bar', 10 ); - + + ``` If no recognized module system is present, access bundle contents via the global scope: @@ -101,7 +106,7 @@ out = removeLastCodePoint( 'foo bar', 10 ); - + - - - - diff --git a/stats_node.html b/stats_node.html deleted file mode 100644 index 1e086d4..0000000 --- a/stats_node.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 2ae8112aea089bdcd85fa0694c475b1f4307a402 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Aug 2024 00:42:33 +0000 Subject: [PATCH 71/92] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 66 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 794 ---- .github/workflows/publish.yml | 252 -- .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .gitignore | 190 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 98 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 52 +- SECURITY.md | 5 - benchmark/benchmark.js | 56 - branches.md | 56 - browser.js | 3 + browser.js.map | 1 + dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 29 - docs/types/index.d.ts | 53 - docs/types/test.ts | 57 - examples/index.js | 33 - index.js | 3 + index.js.map | 1 + lib/index.js | 43 - lib/main.js | 94 - package.json | 53 +- stats_browser.html | 4842 +++++++++++++++++++++ stats_node.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 108 - 46 files changed, 9728 insertions(+), 3925 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md create mode 100644 browser.js create mode 100644 browser.js.map 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/index.d.ts delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js create mode 100644 index.js create mode 100644 index.js.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats_browser.html create mode 100644 stats_node.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 7944aa4..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-08-01T00:36:20.355Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 52cd9c4..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/base/remove-last-code-point) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 533eeee..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/base/remove-last-code-point) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 2a724f2..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: '29 5 * * 0' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index f4575e9..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,794 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n +``` -```javascript -var removeLastCodePoint = require( '@stdlib/string-base-remove-last-code-point' ); +If no recognized module system is present, access bundle contents via the global scope: + +```html + ``` #### removeLastCodePoint( str, n ) @@ -91,8 +97,13 @@ out = removeLastCodePoint( 'foo bar', 10 ); -```javascript -var removeLastCodePoint = require( '@stdlib/string-base-remove-last-code-point' ); +```html + + + + + + + ```
diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index a39bd29..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,56 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var removeLast = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var values; - var out; - var i; - - values = [ - 'beep boop', - 'foo bar', - 'xyz abc', - '🐶🐮🐷🐰🐸' - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = removeLast( values[ i%values.length ], 1 ); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( !isString( out ) ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index f585c99..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/base/remove-last-code-point" -%% click B href "https://github.com/stdlib-js/string-base-remove-last-code-point/tree/main" -%% click C href "https://github.com/stdlib-js/string-base-remove-last-code-point/tree/production" -%% click D href "https://github.com/stdlib-js/string-base-remove-last-code-point/tree/esm" -%% click E href "https://github.com/stdlib-js/string-base-remove-last-code-point/tree/deno" -%% click F href "https://github.com/stdlib-js/string-base-remove-last-code-point/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/base/remove-last-code-point -[production-url]: https://github.com/stdlib-js/string-base-remove-last-code-point/tree/production -[deno-url]: https://github.com/stdlib-js/string-base-remove-last-code-point/tree/deno -[deno-readme]: https://github.com/stdlib-js/string-base-remove-last-code-point/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/string-base-remove-last-code-point/tree/umd -[umd-readme]: https://github.com/stdlib-js/string-base-remove-last-code-point/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/string-base-remove-last-code-point/tree/esm -[esm-readme]: https://github.com/stdlib-js/string-base-remove-last-code-point/blob/esm/README.md \ No newline at end of file diff --git a/browser.js b/browser.js new file mode 100644 index 0000000..f3a511a --- /dev/null +++ b/browser.js @@ -0,0 +1,3 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +var e,t;e=this,t=function(){"use strict";var e=/[\uDC00-\uDFFF]/,t=/[\uD800-\uDBFF]/;return function(n,f){var i,o,r,u;if(0===f)return n;for(r=0,u=n.length-1;u>=0;u--){if(i=n[u],r+=1,e.test(i)){if(0===u)break;o=n[u-1],t.test(o)&&(u-=1)}if(r===f)break}return n.substring(0,u)}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).removeLastCodePoint=t(); +//# sourceMappingURL=browser.js.map diff --git a/browser.js.map b/browser.js.map new file mode 100644 index 0000000..19908eb --- /dev/null +++ b/browser.js.map @@ -0,0 +1 @@ +{"version":3,"file":"browser.js","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\nvar RE_UTF16_LOW_SURROGATE = /[\\uDC00-\\uDFFF]/; // TODO: replace with stdlib pkg\nvar RE_UTF16_HIGH_SURROGATE = /[\\uD800-\\uDBFF]/; // TODO: replace with stdlib pkg\n\n\n// MAIN //\n\n/**\n* Removes the last `n` Unicode code points of a string.\n*\n* @param {string} str - input string\n* @param {NonNegativeInteger} n - number of Unicode code points to remove\n* @returns {string} output string\n*\n* @example\n* var out = removeLast( 'last man standing', 1 );\n* // returns 'last man standin'\n*\n* @example\n* var out = removeLast( 'presidential election', 1 );\n* // returns 'presidential electio'\n*\n* @example\n* var out = removeLast( 'JavaScript', 1 );\n* // returns 'JavaScrip'\n*\n* @example\n* var out = removeLast( 'Hidden Treasures', 1 );\n* // returns 'Hidden Treasure'\n*/\nfunction removeLast( str, n ) {\n\tvar len;\n\tvar ch1;\n\tvar ch2;\n\tvar cnt;\n\tvar i;\n\tif ( n === 0 ) {\n\t\treturn str;\n\t}\n\tlen = str.length;\n\tcnt = 0;\n\n\t// Process the string one Unicode code unit at a time and count UTF-16 surrogate pairs as a single Unicode code point...\n\tfor ( i = len - 1; i >= 0; i-- ) {\n\t\tch1 = str[ i ];\n\t\tcnt += 1;\n\n\t\t// Check for a low UTF-16 surrogate...\n\t\tif ( RE_UTF16_LOW_SURROGATE.test( ch1 ) ) {\n\t\t\t// Check for an unpaired surrogate at the end of the input string...\n\t\t\tif ( i === 0 ) {\n\t\t\t\t// We found an unpaired surrogate...\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\t// Check whether the high surrogate is paired with a low surrogate...\n\t\t\tch2 = str[ i-1 ];\n\t\t\tif ( RE_UTF16_HIGH_SURROGATE.test( ch2 ) ) {\n\t\t\t\t// We found a surrogate pair:\n\t\t\t\ti -= 1; // bump the index to process the next code unit\n\t\t\t}\n\t\t}\n\t\t// Check whether we've found the desired number of code points...\n\t\tif ( cnt === n ) {\n\t\t\tbreak;\n\t\t}\n\t}\n\treturn str.substring( 0, i );\n}\n\n\n// EXPORTS //\n\nexport default removeLast;\n"],"names":["RE_UTF16_LOW_SURROGATE","RE_UTF16_HIGH_SURROGATE","str","n","ch1","ch2","cnt","i","length","test","substring"],"mappings":";yCAsBA,IAAIA,EAAyB,kBACzBC,EAA0B,yBA4B9B,SAAqBC,EAAKC,GACzB,IACIC,EACAC,EACAC,EACAC,EACJ,GAAW,IAANJ,EACJ,OAAOD,EAMR,IAHAI,EAAM,EAGAC,EAJAL,EAAIM,OAIM,EAAGD,GAAK,EAAGA,IAAM,CAKhC,GAJAH,EAAMF,EAAKK,GACXD,GAAO,EAGFN,EAAuBS,KAAML,GAAQ,CAEzC,GAAW,IAANG,EAEJ,MAGDF,EAAMH,EAAKK,EAAE,GACRN,EAAwBQ,KAAMJ,KAElCE,GAAK,EAEN,CAED,GAAKD,IAAQH,EACZ,KAED,CACD,OAAOD,EAAIQ,UAAW,EAAGH,EAC1B"} \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index 8c96fd7..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import removeLast from '../docs/types/index'; -export = removeLast; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index e6b7220..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var s=function(e,t){return function(){return t||e((t={exports:{}}).exports,t),t.exports}};var f=s(function(D,n){ -var F=/[\uDC00-\uDFFF]/,c=/[\uD800-\uDBFF]/;function R(e,t){var i,u,v,a,r;if(t===0)return e;for(i=e.length,a=0,r=i-1;r>=0;r--){if(u=e[r],a+=1,F.test(u)){if(r===0)break;v=e[r-1],c.test(v)&&(r-=1)}if(a===t)break}return e.substring(0,r)}n.exports=R -});var _=f();module.exports=_; -/** @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 72561cf..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\nvar RE_UTF16_LOW_SURROGATE = /[\\uDC00-\\uDFFF]/; // TODO: replace with stdlib pkg\nvar RE_UTF16_HIGH_SURROGATE = /[\\uD800-\\uDBFF]/; // TODO: replace with stdlib pkg\n\n\n// MAIN //\n\n/**\n* Removes the last `n` Unicode code points of a string.\n*\n* @param {string} str - input string\n* @param {NonNegativeInteger} n - number of Unicode code points to remove\n* @returns {string} output string\n*\n* @example\n* var out = removeLast( 'last man standing', 1 );\n* // returns 'last man standin'\n*\n* @example\n* var out = removeLast( 'presidential election', 1 );\n* // returns 'presidential electio'\n*\n* @example\n* var out = removeLast( 'JavaScript', 1 );\n* // returns 'JavaScrip'\n*\n* @example\n* var out = removeLast( 'Hidden Treasures', 1 );\n* // returns 'Hidden Treasure'\n*/\nfunction removeLast( str, n ) {\n\tvar len;\n\tvar ch1;\n\tvar ch2;\n\tvar cnt;\n\tvar i;\n\tif ( n === 0 ) {\n\t\treturn str;\n\t}\n\tlen = str.length;\n\tcnt = 0;\n\n\t// Process the string one Unicode code unit at a time and count UTF-16 surrogate pairs as a single Unicode code point...\n\tfor ( i = len - 1; i >= 0; i-- ) {\n\t\tch1 = str[ i ];\n\t\tcnt += 1;\n\n\t\t// Check for a low UTF-16 surrogate...\n\t\tif ( RE_UTF16_LOW_SURROGATE.test( ch1 ) ) {\n\t\t\t// Check for an unpaired surrogate at the end of the input string...\n\t\t\tif ( i === 0 ) {\n\t\t\t\t// We found an unpaired surrogate...\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\t// Check whether the high surrogate is paired with a low surrogate...\n\t\t\tch2 = str[ i-1 ];\n\t\t\tif ( RE_UTF16_HIGH_SURROGATE.test( ch2 ) ) {\n\t\t\t\t// We found a surrogate pair:\n\t\t\t\ti -= 1; // bump the index to process the next code unit\n\t\t\t}\n\t\t}\n\t\t// Check whether we've found the desired number of code points...\n\t\tif ( cnt === n ) {\n\t\t\tbreak;\n\t\t}\n\t}\n\treturn str.substring( 0, i );\n}\n\n\n// EXPORTS //\n\nmodule.exports = removeLast;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Remove the last `n` Unicode code points of a string.\n*\n* @module @stdlib/string-base-remove-last-code-point\n*\n* @example\n* var removeLast = require( '@stdlib/string-base-remove-last-code-point' );\n*\n* var out = removeLast( 'last man standing', 1 );\n* // returns 'last man standin'\n*\n* out = removeLast( 'Hidden Treasures', 1 );\n* // returns 'Hidden Treasure';\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,EAAyB,kBACzBC,EAA0B,kBA4B9B,SAASC,EAAYC,EAAKC,EAAI,CAC7B,IAAIC,EACAC,EACAC,EACAC,EACAC,EACJ,GAAKL,IAAM,EACV,OAAOD,EAMR,IAJAE,EAAMF,EAAI,OACVK,EAAM,EAGAC,EAAIJ,EAAM,EAAGI,GAAK,EAAGA,IAAM,CAKhC,GAJAH,EAAMH,EAAKM,CAAE,EACbD,GAAO,EAGFR,EAAuB,KAAMM,CAAI,EAAI,CAEzC,GAAKG,IAAM,EAEV,MAGDF,EAAMJ,EAAKM,EAAE,CAAE,EACVR,EAAwB,KAAMM,CAAI,IAEtCE,GAAK,EAEP,CAEA,GAAKD,IAAQJ,EACZ,KAEF,CACA,OAAOD,EAAI,UAAW,EAAGM,CAAE,CAC5B,CAKAV,EAAO,QAAUG,ICxDjB,IAAIQ,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "RE_UTF16_LOW_SURROGATE", "RE_UTF16_HIGH_SURROGATE", "removeLast", "str", "n", "len", "ch1", "ch2", "cnt", "i", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index a08ea55..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,29 +0,0 @@ - -{{alias}}( str, n ) - Removes the last `n` Unicode code points of a string. - - Parameters - ---------- - str: string - Input string. - - n: integer - Number of Unicode code points to remove. - - Returns - ------- - out: string - Output string. - - Examples - -------- - > var out = {{alias}}( 'beep', 1 ) - 'bee' - > out = {{alias}}( 'Boop', 1 ) - 'Boo' - > out = {{alias}}( 'foo bar', 5 ) - 'fo' - - See Also - -------- - diff --git a/docs/types/index.d.ts b/docs/types/index.d.ts deleted file mode 100644 index 8a1c90b..0000000 --- a/docs/types/index.d.ts +++ /dev/null @@ -1,53 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 - -/** -* Removes the last `n` Unicode code points of a string. -* -* @param str - input string -* @param n - number of code points to remove -* @returns output string -* -* @example -* var out = removeLast( 'last man standing', 1 ); -* // returns 'last man standin' -* -* @example -* var out = removeLast( 'presidential election', 1 ); -* // returns 'presidential electio' -* -* @example -* var out = removeLast( 'JavaScript', 1 ); -* // returns 'JavaScrip' -* -* @example -* var out = removeLast( 'Hidden Treasures', 1 ); -* // returns 'Hidden Treasure' -* -* @example -* var out = removeLast( 'foo bar', 5 ); -* // returns 'fo' -*/ -declare function removeLast( str: string, n: number ): string; - - -// EXPORTS // - -export = removeLast; diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index fd426d2..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,57 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 removeLast = require( './index' ); - - -// TESTS // - -// The function returns a string... -{ - removeLast( 'abc', 1 ); // $ExpectType string -} - -// The compiler throws an error if the function is provided a value other than a string... -{ - removeLast( true, 1 ); // $ExpectError - removeLast( false, 1 ); // $ExpectError - removeLast( null, 1 ); // $ExpectError - removeLast( undefined, 1 ); // $ExpectError - removeLast( 5, 1 ); // $ExpectError - removeLast( [], 1 ); // $ExpectError - removeLast( {}, 1 ); // $ExpectError - removeLast( ( x: number ): number => x, 1 ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument that is not a number... -{ - removeLast( 'abc', true ); // $ExpectError - removeLast( 'abc', false ); // $ExpectError - removeLast( 'abc', null ); // $ExpectError - removeLast( 'abc', 'abc' ); // $ExpectError - removeLast( 'abc', [] ); // $ExpectError - removeLast( 'abc', {} ); // $ExpectError - removeLast( 'abc', ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - removeLast(); // $ExpectError - removeLast( 'abc' ); // $ExpectError - removeLast( 'abc', 1, 2 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 085633e..0000000 --- a/examples/index.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var removeLastCodePoint = require( './../lib' ); - -console.log( removeLastCodePoint( 'presidential election', 1 ) ); -// => 'presidential electio' - -console.log( removeLastCodePoint( 'JavaScript', 1 ) ); -// => 'JavaScrip' - -console.log( removeLastCodePoint( 'The Last of the Mohicans', 5 ) ); -// => 'The Last of the Moh' - -console.log( removeLastCodePoint( 'अनुच्छेद', 1 ) ); -// => 'अनुच्छे' diff --git a/index.js b/index.js new file mode 100644 index 0000000..4e500d1 --- /dev/null +++ b/index.js @@ -0,0 +1,3 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +var e,t;e=this,t=function(){"use strict";var e=/[\uDC00-\uDFFF]/,t=/[\uD800-\uDBFF]/;return function(n,f){var i,o,r,u;if(0===f)return n;for(r=0,u=n.length-1;u>=0;u--){if(i=n[u],r+=1,e.test(i)){if(0===u)break;o=n[u-1],t.test(o)&&(u-=1)}if(r===f)break}return n.substring(0,u)}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).removeLastCodePoint=t(); +//# sourceMappingURL=index.js.map diff --git a/index.js.map b/index.js.map new file mode 100644 index 0000000..d557af8 --- /dev/null +++ b/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\nvar RE_UTF16_LOW_SURROGATE = /[\\uDC00-\\uDFFF]/; // TODO: replace with stdlib pkg\nvar RE_UTF16_HIGH_SURROGATE = /[\\uD800-\\uDBFF]/; // TODO: replace with stdlib pkg\n\n\n// MAIN //\n\n/**\n* Removes the last `n` Unicode code points of a string.\n*\n* @param {string} str - input string\n* @param {NonNegativeInteger} n - number of Unicode code points to remove\n* @returns {string} output string\n*\n* @example\n* var out = removeLast( 'last man standing', 1 );\n* // returns 'last man standin'\n*\n* @example\n* var out = removeLast( 'presidential election', 1 );\n* // returns 'presidential electio'\n*\n* @example\n* var out = removeLast( 'JavaScript', 1 );\n* // returns 'JavaScrip'\n*\n* @example\n* var out = removeLast( 'Hidden Treasures', 1 );\n* // returns 'Hidden Treasure'\n*/\nfunction removeLast( str, n ) {\n\tvar len;\n\tvar ch1;\n\tvar ch2;\n\tvar cnt;\n\tvar i;\n\tif ( n === 0 ) {\n\t\treturn str;\n\t}\n\tlen = str.length;\n\tcnt = 0;\n\n\t// Process the string one Unicode code unit at a time and count UTF-16 surrogate pairs as a single Unicode code point...\n\tfor ( i = len - 1; i >= 0; i-- ) {\n\t\tch1 = str[ i ];\n\t\tcnt += 1;\n\n\t\t// Check for a low UTF-16 surrogate...\n\t\tif ( RE_UTF16_LOW_SURROGATE.test( ch1 ) ) {\n\t\t\t// Check for an unpaired surrogate at the end of the input string...\n\t\t\tif ( i === 0 ) {\n\t\t\t\t// We found an unpaired surrogate...\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\t// Check whether the high surrogate is paired with a low surrogate...\n\t\t\tch2 = str[ i-1 ];\n\t\t\tif ( RE_UTF16_HIGH_SURROGATE.test( ch2 ) ) {\n\t\t\t\t// We found a surrogate pair:\n\t\t\t\ti -= 1; // bump the index to process the next code unit\n\t\t\t}\n\t\t}\n\t\t// Check whether we've found the desired number of code points...\n\t\tif ( cnt === n ) {\n\t\t\tbreak;\n\t\t}\n\t}\n\treturn str.substring( 0, i );\n}\n\n\n// EXPORTS //\n\nexport default removeLast;\n"],"names":["RE_UTF16_LOW_SURROGATE","RE_UTF16_HIGH_SURROGATE","str","n","ch1","ch2","cnt","i","length","test","substring"],"mappings":";yCAsBA,IAAIA,EAAyB,kBACzBC,EAA0B,yBA4B9B,SAAqBC,EAAKC,GACzB,IACIC,EACAC,EACAC,EACAC,EACJ,GAAW,IAANJ,EACJ,OAAOD,EAMR,IAHAI,EAAM,EAGAC,EAJAL,EAAIM,OAIM,EAAGD,GAAK,EAAGA,IAAM,CAKhC,GAJAH,EAAMF,EAAKK,GACXD,GAAO,EAGFN,EAAuBS,KAAML,GAAQ,CAEzC,GAAW,IAANG,EAEJ,MAGDF,EAAMH,EAAKK,EAAE,GACRN,EAAwBQ,KAAMJ,KAElCE,GAAK,EAEN,CAED,GAAKD,IAAQH,EACZ,KAED,CACD,OAAOD,EAAIQ,UAAW,EAAGH,EAC1B"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 9860da0..0000000 --- a/lib/index.js +++ /dev/null @@ -1,43 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Remove the last `n` Unicode code points of a string. -* -* @module @stdlib/string-base-remove-last-code-point -* -* @example -* var removeLast = require( '@stdlib/string-base-remove-last-code-point' ); -* -* var out = removeLast( 'last man standing', 1 ); -* // returns 'last man standin' -* -* out = removeLast( 'Hidden Treasures', 1 ); -* // returns 'Hidden Treasure'; -*/ - -// 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 fc34187..0000000 --- a/lib/main.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// VARIABLES // - -var RE_UTF16_LOW_SURROGATE = /[\uDC00-\uDFFF]/; // TODO: replace with stdlib pkg -var RE_UTF16_HIGH_SURROGATE = /[\uD800-\uDBFF]/; // TODO: replace with stdlib pkg - - -// MAIN // - -/** -* Removes the last `n` Unicode code points of a string. -* -* @param {string} str - input string -* @param {NonNegativeInteger} n - number of Unicode code points to remove -* @returns {string} output string -* -* @example -* var out = removeLast( 'last man standing', 1 ); -* // returns 'last man standin' -* -* @example -* var out = removeLast( 'presidential election', 1 ); -* // returns 'presidential electio' -* -* @example -* var out = removeLast( 'JavaScript', 1 ); -* // returns 'JavaScrip' -* -* @example -* var out = removeLast( 'Hidden Treasures', 1 ); -* // returns 'Hidden Treasure' -*/ -function removeLast( str, n ) { - var len; - var ch1; - var ch2; - var cnt; - var i; - if ( n === 0 ) { - return str; - } - len = str.length; - cnt = 0; - - // Process the string one Unicode code unit at a time and count UTF-16 surrogate pairs as a single Unicode code point... - for ( i = len - 1; i >= 0; i-- ) { - ch1 = str[ i ]; - cnt += 1; - - // Check for a low UTF-16 surrogate... - if ( RE_UTF16_LOW_SURROGATE.test( ch1 ) ) { - // Check for an unpaired surrogate at the end of the input string... - if ( i === 0 ) { - // We found an unpaired surrogate... - break; - } - // Check whether the high surrogate is paired with a low surrogate... - ch2 = str[ i-1 ]; - if ( RE_UTF16_HIGH_SURROGATE.test( ch2 ) ) { - // We found a surrogate pair: - i -= 1; // bump the index to process the next code unit - } - } - // Check whether we've found the desired number of code points... - if ( cnt === n ) { - break; - } - } - return str.substring( 0, i ); -} - - -// EXPORTS // - -module.exports = removeLast; diff --git a/package.json b/package.json index 8dd3c53..e1a7e6d 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,7 @@ "version": "0.2.2", "description": "Remove the last Unicode code point of a string.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "main": "./index.js", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,31 +12,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/assert-is-string": "^0.2.2", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdstring", @@ -81,4 +32,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/stats_browser.html b/stats_browser.html new file mode 100644 index 0000000..2c17dcc --- /dev/null +++ b/stats_browser.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/stats_node.html b/stats_node.html new file mode 100644 index 0000000..1e086d4 --- /dev/null +++ b/stats_node.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index a25545e..0000000 --- a/test/test.js +++ /dev/null @@ -1,108 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var removeLast = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof removeLast, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns an empty string if provided an empty string', function test( t ) { - t.strictEqual( removeLast( '', 1 ), '', 'returns expected value' ); - t.strictEqual( removeLast( '', 2 ), '', 'returns expected value' ); - t.strictEqual( removeLast( '', 3 ), '', 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns the input string if provided zero as the second argument', function test( t ) { - t.strictEqual( removeLast( 'hello world', 0 ), 'hello world', 'returns expected value' ); - t.end(); -}); - -tape( 'the function removes the last Unicode code point of a provided string (ascii)', function test( t ) { - var out; - - out = removeLast( 'hello world', 1 ); - t.strictEqual( out, 'hello worl', 'returns expected value' ); - - out = removeLast( '!!!', 1 ); - t.strictEqual( out, '!!', 'returns expected value' ); - - out = removeLast( 'Hello World', 1 ); - t.strictEqual( out, 'Hello Worl', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function removes the last Unicode code point of a provided string (Unicode)', function test( t ) { - var out; - - out = removeLast( 'अनुच्छेद', 1 ); - t.strictEqual( out, 'अनुच्छे', 'returns expected value' ); - - out = removeLast( '六书/六書', 1 ); - t.strictEqual( out, '六书/六', 'returns expected value' ); - - out = removeLast( '𐒻𐓟', 1 ); - t.strictEqual( out, '𐒻', 'returns expected value' ); - - out = removeLast( '𐒻𐓟', 1 ); - t.strictEqual( out, '𐒻', 'returns expected value' ); - - out = removeLast( '\uDC00', 1 ); - t.strictEqual( out, '', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports removing the last `n` Unicode code points of a provided string', function test( t ) { - var out; - - out = removeLast( 'hello world', 1 ); - t.strictEqual( out, 'hello worl', 'returns expected value' ); - - out = removeLast( 'hello world', 7 ); - t.strictEqual( out, 'hell', 'returns expected value' ); - - out = removeLast( '!!!', 1 ); - t.strictEqual( out, '!!', 'returns expected value' ); - - out = removeLast( '!!!', 2 ); - t.strictEqual( out, '!', 'returns expected value' ); - - out = removeLast( 'अनुच्छेद', 1 ); - t.strictEqual( out, 'अनुच्छे', 'returns expected value' ); - - out = removeLast( '六书/六書', 3 ); - t.strictEqual( out, '六书', 'returns expected value' ); - - out = removeLast( '𐒻𐓟𐓟', 2 ); - t.strictEqual( out, '𐒻', 'returns expected value' ); - - t.end(); -}); From 7bc7606a28297f849f6de7ceec459991aee1835c Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 3 Aug 2024 15:13:13 +0000 Subject: [PATCH 72/92] Transform error messages --- package.json | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index d1c7913..8dd3c53 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,9 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": {}, + "dependencies": { + "@stdlib/error-tools-fmtprodmsg": "^0.2.2" + }, "devDependencies": { "@stdlib/assert-is-string": "^0.2.2", "tape": "git+https://github.com/kgryte/tape.git#fix/globby", @@ -79,4 +81,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From bb453bbaa88844f97d03fb44bad3c475a2a241a5 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 3 Aug 2024 15:18:28 +0000 Subject: [PATCH 73/92] Remove files --- browser.js | 3 - browser.js.map | 1 - index.js | 3 - index.js.map | 1 - stats_browser.html | 4842 -------------------------------------------- stats_node.html | 4842 -------------------------------------------- 6 files changed, 9692 deletions(-) delete mode 100644 browser.js delete mode 100644 browser.js.map delete mode 100644 index.js delete mode 100644 index.js.map delete mode 100644 stats_browser.html delete mode 100644 stats_node.html diff --git a/browser.js b/browser.js deleted file mode 100644 index f3a511a..0000000 --- a/browser.js +++ /dev/null @@ -1,3 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -var e,t;e=this,t=function(){"use strict";var e=/[\uDC00-\uDFFF]/,t=/[\uD800-\uDBFF]/;return function(n,f){var i,o,r,u;if(0===f)return n;for(r=0,u=n.length-1;u>=0;u--){if(i=n[u],r+=1,e.test(i)){if(0===u)break;o=n[u-1],t.test(o)&&(u-=1)}if(r===f)break}return n.substring(0,u)}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).removeLastCodePoint=t(); -//# sourceMappingURL=browser.js.map diff --git a/browser.js.map b/browser.js.map deleted file mode 100644 index 19908eb..0000000 --- a/browser.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"browser.js","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\nvar RE_UTF16_LOW_SURROGATE = /[\\uDC00-\\uDFFF]/; // TODO: replace with stdlib pkg\nvar RE_UTF16_HIGH_SURROGATE = /[\\uD800-\\uDBFF]/; // TODO: replace with stdlib pkg\n\n\n// MAIN //\n\n/**\n* Removes the last `n` Unicode code points of a string.\n*\n* @param {string} str - input string\n* @param {NonNegativeInteger} n - number of Unicode code points to remove\n* @returns {string} output string\n*\n* @example\n* var out = removeLast( 'last man standing', 1 );\n* // returns 'last man standin'\n*\n* @example\n* var out = removeLast( 'presidential election', 1 );\n* // returns 'presidential electio'\n*\n* @example\n* var out = removeLast( 'JavaScript', 1 );\n* // returns 'JavaScrip'\n*\n* @example\n* var out = removeLast( 'Hidden Treasures', 1 );\n* // returns 'Hidden Treasure'\n*/\nfunction removeLast( str, n ) {\n\tvar len;\n\tvar ch1;\n\tvar ch2;\n\tvar cnt;\n\tvar i;\n\tif ( n === 0 ) {\n\t\treturn str;\n\t}\n\tlen = str.length;\n\tcnt = 0;\n\n\t// Process the string one Unicode code unit at a time and count UTF-16 surrogate pairs as a single Unicode code point...\n\tfor ( i = len - 1; i >= 0; i-- ) {\n\t\tch1 = str[ i ];\n\t\tcnt += 1;\n\n\t\t// Check for a low UTF-16 surrogate...\n\t\tif ( RE_UTF16_LOW_SURROGATE.test( ch1 ) ) {\n\t\t\t// Check for an unpaired surrogate at the end of the input string...\n\t\t\tif ( i === 0 ) {\n\t\t\t\t// We found an unpaired surrogate...\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\t// Check whether the high surrogate is paired with a low surrogate...\n\t\t\tch2 = str[ i-1 ];\n\t\t\tif ( RE_UTF16_HIGH_SURROGATE.test( ch2 ) ) {\n\t\t\t\t// We found a surrogate pair:\n\t\t\t\ti -= 1; // bump the index to process the next code unit\n\t\t\t}\n\t\t}\n\t\t// Check whether we've found the desired number of code points...\n\t\tif ( cnt === n ) {\n\t\t\tbreak;\n\t\t}\n\t}\n\treturn str.substring( 0, i );\n}\n\n\n// EXPORTS //\n\nexport default removeLast;\n"],"names":["RE_UTF16_LOW_SURROGATE","RE_UTF16_HIGH_SURROGATE","str","n","ch1","ch2","cnt","i","length","test","substring"],"mappings":";yCAsBA,IAAIA,EAAyB,kBACzBC,EAA0B,yBA4B9B,SAAqBC,EAAKC,GACzB,IACIC,EACAC,EACAC,EACAC,EACJ,GAAW,IAANJ,EACJ,OAAOD,EAMR,IAHAI,EAAM,EAGAC,EAJAL,EAAIM,OAIM,EAAGD,GAAK,EAAGA,IAAM,CAKhC,GAJAH,EAAMF,EAAKK,GACXD,GAAO,EAGFN,EAAuBS,KAAML,GAAQ,CAEzC,GAAW,IAANG,EAEJ,MAGDF,EAAMH,EAAKK,EAAE,GACRN,EAAwBQ,KAAMJ,KAElCE,GAAK,EAEN,CAED,GAAKD,IAAQH,EACZ,KAED,CACD,OAAOD,EAAIQ,UAAW,EAAGH,EAC1B"} \ No newline at end of file diff --git a/index.js b/index.js deleted file mode 100644 index 4e500d1..0000000 --- a/index.js +++ /dev/null @@ -1,3 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -var e,t;e=this,t=function(){"use strict";var e=/[\uDC00-\uDFFF]/,t=/[\uD800-\uDBFF]/;return function(n,f){var i,o,r,u;if(0===f)return n;for(r=0,u=n.length-1;u>=0;u--){if(i=n[u],r+=1,e.test(i)){if(0===u)break;o=n[u-1],t.test(o)&&(u-=1)}if(r===f)break}return n.substring(0,u)}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).removeLastCodePoint=t(); -//# sourceMappingURL=index.js.map diff --git a/index.js.map b/index.js.map deleted file mode 100644 index d557af8..0000000 --- a/index.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.js","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\nvar RE_UTF16_LOW_SURROGATE = /[\\uDC00-\\uDFFF]/; // TODO: replace with stdlib pkg\nvar RE_UTF16_HIGH_SURROGATE = /[\\uD800-\\uDBFF]/; // TODO: replace with stdlib pkg\n\n\n// MAIN //\n\n/**\n* Removes the last `n` Unicode code points of a string.\n*\n* @param {string} str - input string\n* @param {NonNegativeInteger} n - number of Unicode code points to remove\n* @returns {string} output string\n*\n* @example\n* var out = removeLast( 'last man standing', 1 );\n* // returns 'last man standin'\n*\n* @example\n* var out = removeLast( 'presidential election', 1 );\n* // returns 'presidential electio'\n*\n* @example\n* var out = removeLast( 'JavaScript', 1 );\n* // returns 'JavaScrip'\n*\n* @example\n* var out = removeLast( 'Hidden Treasures', 1 );\n* // returns 'Hidden Treasure'\n*/\nfunction removeLast( str, n ) {\n\tvar len;\n\tvar ch1;\n\tvar ch2;\n\tvar cnt;\n\tvar i;\n\tif ( n === 0 ) {\n\t\treturn str;\n\t}\n\tlen = str.length;\n\tcnt = 0;\n\n\t// Process the string one Unicode code unit at a time and count UTF-16 surrogate pairs as a single Unicode code point...\n\tfor ( i = len - 1; i >= 0; i-- ) {\n\t\tch1 = str[ i ];\n\t\tcnt += 1;\n\n\t\t// Check for a low UTF-16 surrogate...\n\t\tif ( RE_UTF16_LOW_SURROGATE.test( ch1 ) ) {\n\t\t\t// Check for an unpaired surrogate at the end of the input string...\n\t\t\tif ( i === 0 ) {\n\t\t\t\t// We found an unpaired surrogate...\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\t// Check whether the high surrogate is paired with a low surrogate...\n\t\t\tch2 = str[ i-1 ];\n\t\t\tif ( RE_UTF16_HIGH_SURROGATE.test( ch2 ) ) {\n\t\t\t\t// We found a surrogate pair:\n\t\t\t\ti -= 1; // bump the index to process the next code unit\n\t\t\t}\n\t\t}\n\t\t// Check whether we've found the desired number of code points...\n\t\tif ( cnt === n ) {\n\t\t\tbreak;\n\t\t}\n\t}\n\treturn str.substring( 0, i );\n}\n\n\n// EXPORTS //\n\nexport default removeLast;\n"],"names":["RE_UTF16_LOW_SURROGATE","RE_UTF16_HIGH_SURROGATE","str","n","ch1","ch2","cnt","i","length","test","substring"],"mappings":";yCAsBA,IAAIA,EAAyB,kBACzBC,EAA0B,yBA4B9B,SAAqBC,EAAKC,GACzB,IACIC,EACAC,EACAC,EACAC,EACJ,GAAW,IAANJ,EACJ,OAAOD,EAMR,IAHAI,EAAM,EAGAC,EAJAL,EAAIM,OAIM,EAAGD,GAAK,EAAGA,IAAM,CAKhC,GAJAH,EAAMF,EAAKK,GACXD,GAAO,EAGFN,EAAuBS,KAAML,GAAQ,CAEzC,GAAW,IAANG,EAEJ,MAGDF,EAAMH,EAAKK,EAAE,GACRN,EAAwBQ,KAAMJ,KAElCE,GAAK,EAEN,CAED,GAAKD,IAAQH,EACZ,KAED,CACD,OAAOD,EAAIQ,UAAW,EAAGH,EAC1B"} \ No newline at end of file diff --git a/stats_browser.html b/stats_browser.html deleted file mode 100644 index 2c17dcc..0000000 --- a/stats_browser.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - diff --git a/stats_node.html b/stats_node.html deleted file mode 100644 index 1e086d4..0000000 --- a/stats_node.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 94fa869511b12dd72f162c2554ee6340cfa04c10 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 3 Aug 2024 15:18:53 +0000 Subject: [PATCH 74/92] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 66 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 794 ---- .github/workflows/publish.yml | 252 -- .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .gitignore | 190 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 99 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 52 +- SECURITY.md | 5 - benchmark/benchmark.js | 56 - branches.md | 56 - browser.js | 3 + browser.js.map | 1 + dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 29 - docs/types/index.d.ts | 53 - docs/types/test.ts | 57 - examples/index.js | 33 - index.js | 3 + index.js.map | 1 + lib/index.js | 43 - lib/main.js | 94 - package.json | 53 +- stats_browser.html | 4842 +++++++++++++++++++++ stats_node.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 108 - 46 files changed, 9728 insertions(+), 3926 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md create mode 100644 browser.js create mode 100644 browser.js.map 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/index.d.ts delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js create mode 100644 index.js create mode 100644 index.js.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats_browser.html create mode 100644 stats_node.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 2a59c77..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-08-03T15:12:34.261Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 52cd9c4..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/base/remove-last-code-point) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 533eeee..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/base/remove-last-code-point) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 2a724f2..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: '29 5 * * 0' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index f4575e9..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,794 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n +``` -```javascript -var removeLastCodePoint = require( '@stdlib/string-base-remove-last-code-point' ); +If no recognized module system is present, access bundle contents via the global scope: + +```html + ``` #### removeLastCodePoint( str, n ) @@ -91,8 +97,13 @@ out = removeLastCodePoint( 'foo bar', 10 ); -```javascript -var removeLastCodePoint = require( '@stdlib/string-base-remove-last-code-point' ); +```html + + + + + + + ```
diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index a39bd29..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,56 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var removeLast = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var values; - var out; - var i; - - values = [ - 'beep boop', - 'foo bar', - 'xyz abc', - '🐶🐮🐷🐰🐸' - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = removeLast( values[ i%values.length ], 1 ); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( !isString( out ) ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index f585c99..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/base/remove-last-code-point" -%% click B href "https://github.com/stdlib-js/string-base-remove-last-code-point/tree/main" -%% click C href "https://github.com/stdlib-js/string-base-remove-last-code-point/tree/production" -%% click D href "https://github.com/stdlib-js/string-base-remove-last-code-point/tree/esm" -%% click E href "https://github.com/stdlib-js/string-base-remove-last-code-point/tree/deno" -%% click F href "https://github.com/stdlib-js/string-base-remove-last-code-point/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/base/remove-last-code-point -[production-url]: https://github.com/stdlib-js/string-base-remove-last-code-point/tree/production -[deno-url]: https://github.com/stdlib-js/string-base-remove-last-code-point/tree/deno -[deno-readme]: https://github.com/stdlib-js/string-base-remove-last-code-point/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/string-base-remove-last-code-point/tree/umd -[umd-readme]: https://github.com/stdlib-js/string-base-remove-last-code-point/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/string-base-remove-last-code-point/tree/esm -[esm-readme]: https://github.com/stdlib-js/string-base-remove-last-code-point/blob/esm/README.md \ No newline at end of file diff --git a/browser.js b/browser.js new file mode 100644 index 0000000..f3a511a --- /dev/null +++ b/browser.js @@ -0,0 +1,3 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +var e,t;e=this,t=function(){"use strict";var e=/[\uDC00-\uDFFF]/,t=/[\uD800-\uDBFF]/;return function(n,f){var i,o,r,u;if(0===f)return n;for(r=0,u=n.length-1;u>=0;u--){if(i=n[u],r+=1,e.test(i)){if(0===u)break;o=n[u-1],t.test(o)&&(u-=1)}if(r===f)break}return n.substring(0,u)}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).removeLastCodePoint=t(); +//# sourceMappingURL=browser.js.map diff --git a/browser.js.map b/browser.js.map new file mode 100644 index 0000000..19908eb --- /dev/null +++ b/browser.js.map @@ -0,0 +1 @@ +{"version":3,"file":"browser.js","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\nvar RE_UTF16_LOW_SURROGATE = /[\\uDC00-\\uDFFF]/; // TODO: replace with stdlib pkg\nvar RE_UTF16_HIGH_SURROGATE = /[\\uD800-\\uDBFF]/; // TODO: replace with stdlib pkg\n\n\n// MAIN //\n\n/**\n* Removes the last `n` Unicode code points of a string.\n*\n* @param {string} str - input string\n* @param {NonNegativeInteger} n - number of Unicode code points to remove\n* @returns {string} output string\n*\n* @example\n* var out = removeLast( 'last man standing', 1 );\n* // returns 'last man standin'\n*\n* @example\n* var out = removeLast( 'presidential election', 1 );\n* // returns 'presidential electio'\n*\n* @example\n* var out = removeLast( 'JavaScript', 1 );\n* // returns 'JavaScrip'\n*\n* @example\n* var out = removeLast( 'Hidden Treasures', 1 );\n* // returns 'Hidden Treasure'\n*/\nfunction removeLast( str, n ) {\n\tvar len;\n\tvar ch1;\n\tvar ch2;\n\tvar cnt;\n\tvar i;\n\tif ( n === 0 ) {\n\t\treturn str;\n\t}\n\tlen = str.length;\n\tcnt = 0;\n\n\t// Process the string one Unicode code unit at a time and count UTF-16 surrogate pairs as a single Unicode code point...\n\tfor ( i = len - 1; i >= 0; i-- ) {\n\t\tch1 = str[ i ];\n\t\tcnt += 1;\n\n\t\t// Check for a low UTF-16 surrogate...\n\t\tif ( RE_UTF16_LOW_SURROGATE.test( ch1 ) ) {\n\t\t\t// Check for an unpaired surrogate at the end of the input string...\n\t\t\tif ( i === 0 ) {\n\t\t\t\t// We found an unpaired surrogate...\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\t// Check whether the high surrogate is paired with a low surrogate...\n\t\t\tch2 = str[ i-1 ];\n\t\t\tif ( RE_UTF16_HIGH_SURROGATE.test( ch2 ) ) {\n\t\t\t\t// We found a surrogate pair:\n\t\t\t\ti -= 1; // bump the index to process the next code unit\n\t\t\t}\n\t\t}\n\t\t// Check whether we've found the desired number of code points...\n\t\tif ( cnt === n ) {\n\t\t\tbreak;\n\t\t}\n\t}\n\treturn str.substring( 0, i );\n}\n\n\n// EXPORTS //\n\nexport default removeLast;\n"],"names":["RE_UTF16_LOW_SURROGATE","RE_UTF16_HIGH_SURROGATE","str","n","ch1","ch2","cnt","i","length","test","substring"],"mappings":";yCAsBA,IAAIA,EAAyB,kBACzBC,EAA0B,yBA4B9B,SAAqBC,EAAKC,GACzB,IACIC,EACAC,EACAC,EACAC,EACJ,GAAW,IAANJ,EACJ,OAAOD,EAMR,IAHAI,EAAM,EAGAC,EAJAL,EAAIM,OAIM,EAAGD,GAAK,EAAGA,IAAM,CAKhC,GAJAH,EAAMF,EAAKK,GACXD,GAAO,EAGFN,EAAuBS,KAAML,GAAQ,CAEzC,GAAW,IAANG,EAEJ,MAGDF,EAAMH,EAAKK,EAAE,GACRN,EAAwBQ,KAAMJ,KAElCE,GAAK,EAEN,CAED,GAAKD,IAAQH,EACZ,KAED,CACD,OAAOD,EAAIQ,UAAW,EAAGH,EAC1B"} \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index 8c96fd7..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import removeLast from '../docs/types/index'; -export = removeLast; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index e6b7220..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var s=function(e,t){return function(){return t||e((t={exports:{}}).exports,t),t.exports}};var f=s(function(D,n){ -var F=/[\uDC00-\uDFFF]/,c=/[\uD800-\uDBFF]/;function R(e,t){var i,u,v,a,r;if(t===0)return e;for(i=e.length,a=0,r=i-1;r>=0;r--){if(u=e[r],a+=1,F.test(u)){if(r===0)break;v=e[r-1],c.test(v)&&(r-=1)}if(a===t)break}return e.substring(0,r)}n.exports=R -});var _=f();module.exports=_; -/** @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 72561cf..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\nvar RE_UTF16_LOW_SURROGATE = /[\\uDC00-\\uDFFF]/; // TODO: replace with stdlib pkg\nvar RE_UTF16_HIGH_SURROGATE = /[\\uD800-\\uDBFF]/; // TODO: replace with stdlib pkg\n\n\n// MAIN //\n\n/**\n* Removes the last `n` Unicode code points of a string.\n*\n* @param {string} str - input string\n* @param {NonNegativeInteger} n - number of Unicode code points to remove\n* @returns {string} output string\n*\n* @example\n* var out = removeLast( 'last man standing', 1 );\n* // returns 'last man standin'\n*\n* @example\n* var out = removeLast( 'presidential election', 1 );\n* // returns 'presidential electio'\n*\n* @example\n* var out = removeLast( 'JavaScript', 1 );\n* // returns 'JavaScrip'\n*\n* @example\n* var out = removeLast( 'Hidden Treasures', 1 );\n* // returns 'Hidden Treasure'\n*/\nfunction removeLast( str, n ) {\n\tvar len;\n\tvar ch1;\n\tvar ch2;\n\tvar cnt;\n\tvar i;\n\tif ( n === 0 ) {\n\t\treturn str;\n\t}\n\tlen = str.length;\n\tcnt = 0;\n\n\t// Process the string one Unicode code unit at a time and count UTF-16 surrogate pairs as a single Unicode code point...\n\tfor ( i = len - 1; i >= 0; i-- ) {\n\t\tch1 = str[ i ];\n\t\tcnt += 1;\n\n\t\t// Check for a low UTF-16 surrogate...\n\t\tif ( RE_UTF16_LOW_SURROGATE.test( ch1 ) ) {\n\t\t\t// Check for an unpaired surrogate at the end of the input string...\n\t\t\tif ( i === 0 ) {\n\t\t\t\t// We found an unpaired surrogate...\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\t// Check whether the high surrogate is paired with a low surrogate...\n\t\t\tch2 = str[ i-1 ];\n\t\t\tif ( RE_UTF16_HIGH_SURROGATE.test( ch2 ) ) {\n\t\t\t\t// We found a surrogate pair:\n\t\t\t\ti -= 1; // bump the index to process the next code unit\n\t\t\t}\n\t\t}\n\t\t// Check whether we've found the desired number of code points...\n\t\tif ( cnt === n ) {\n\t\t\tbreak;\n\t\t}\n\t}\n\treturn str.substring( 0, i );\n}\n\n\n// EXPORTS //\n\nmodule.exports = removeLast;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Remove the last `n` Unicode code points of a string.\n*\n* @module @stdlib/string-base-remove-last-code-point\n*\n* @example\n* var removeLast = require( '@stdlib/string-base-remove-last-code-point' );\n*\n* var out = removeLast( 'last man standing', 1 );\n* // returns 'last man standin'\n*\n* out = removeLast( 'Hidden Treasures', 1 );\n* // returns 'Hidden Treasure';\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,EAAyB,kBACzBC,EAA0B,kBA4B9B,SAASC,EAAYC,EAAKC,EAAI,CAC7B,IAAIC,EACAC,EACAC,EACAC,EACAC,EACJ,GAAKL,IAAM,EACV,OAAOD,EAMR,IAJAE,EAAMF,EAAI,OACVK,EAAM,EAGAC,EAAIJ,EAAM,EAAGI,GAAK,EAAGA,IAAM,CAKhC,GAJAH,EAAMH,EAAKM,CAAE,EACbD,GAAO,EAGFR,EAAuB,KAAMM,CAAI,EAAI,CAEzC,GAAKG,IAAM,EAEV,MAGDF,EAAMJ,EAAKM,EAAE,CAAE,EACVR,EAAwB,KAAMM,CAAI,IAEtCE,GAAK,EAEP,CAEA,GAAKD,IAAQJ,EACZ,KAEF,CACA,OAAOD,EAAI,UAAW,EAAGM,CAAE,CAC5B,CAKAV,EAAO,QAAUG,ICxDjB,IAAIQ,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "RE_UTF16_LOW_SURROGATE", "RE_UTF16_HIGH_SURROGATE", "removeLast", "str", "n", "len", "ch1", "ch2", "cnt", "i", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index a08ea55..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,29 +0,0 @@ - -{{alias}}( str, n ) - Removes the last `n` Unicode code points of a string. - - Parameters - ---------- - str: string - Input string. - - n: integer - Number of Unicode code points to remove. - - Returns - ------- - out: string - Output string. - - Examples - -------- - > var out = {{alias}}( 'beep', 1 ) - 'bee' - > out = {{alias}}( 'Boop', 1 ) - 'Boo' - > out = {{alias}}( 'foo bar', 5 ) - 'fo' - - See Also - -------- - diff --git a/docs/types/index.d.ts b/docs/types/index.d.ts deleted file mode 100644 index 8a1c90b..0000000 --- a/docs/types/index.d.ts +++ /dev/null @@ -1,53 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 - -/** -* Removes the last `n` Unicode code points of a string. -* -* @param str - input string -* @param n - number of code points to remove -* @returns output string -* -* @example -* var out = removeLast( 'last man standing', 1 ); -* // returns 'last man standin' -* -* @example -* var out = removeLast( 'presidential election', 1 ); -* // returns 'presidential electio' -* -* @example -* var out = removeLast( 'JavaScript', 1 ); -* // returns 'JavaScrip' -* -* @example -* var out = removeLast( 'Hidden Treasures', 1 ); -* // returns 'Hidden Treasure' -* -* @example -* var out = removeLast( 'foo bar', 5 ); -* // returns 'fo' -*/ -declare function removeLast( str: string, n: number ): string; - - -// EXPORTS // - -export = removeLast; diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index fd426d2..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,57 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 removeLast = require( './index' ); - - -// TESTS // - -// The function returns a string... -{ - removeLast( 'abc', 1 ); // $ExpectType string -} - -// The compiler throws an error if the function is provided a value other than a string... -{ - removeLast( true, 1 ); // $ExpectError - removeLast( false, 1 ); // $ExpectError - removeLast( null, 1 ); // $ExpectError - removeLast( undefined, 1 ); // $ExpectError - removeLast( 5, 1 ); // $ExpectError - removeLast( [], 1 ); // $ExpectError - removeLast( {}, 1 ); // $ExpectError - removeLast( ( x: number ): number => x, 1 ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument that is not a number... -{ - removeLast( 'abc', true ); // $ExpectError - removeLast( 'abc', false ); // $ExpectError - removeLast( 'abc', null ); // $ExpectError - removeLast( 'abc', 'abc' ); // $ExpectError - removeLast( 'abc', [] ); // $ExpectError - removeLast( 'abc', {} ); // $ExpectError - removeLast( 'abc', ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - removeLast(); // $ExpectError - removeLast( 'abc' ); // $ExpectError - removeLast( 'abc', 1, 2 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 085633e..0000000 --- a/examples/index.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var removeLastCodePoint = require( './../lib' ); - -console.log( removeLastCodePoint( 'presidential election', 1 ) ); -// => 'presidential electio' - -console.log( removeLastCodePoint( 'JavaScript', 1 ) ); -// => 'JavaScrip' - -console.log( removeLastCodePoint( 'The Last of the Mohicans', 5 ) ); -// => 'The Last of the Moh' - -console.log( removeLastCodePoint( 'अनुच्छेद', 1 ) ); -// => 'अनुच्छे' diff --git a/index.js b/index.js new file mode 100644 index 0000000..4e500d1 --- /dev/null +++ b/index.js @@ -0,0 +1,3 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +var e,t;e=this,t=function(){"use strict";var e=/[\uDC00-\uDFFF]/,t=/[\uD800-\uDBFF]/;return function(n,f){var i,o,r,u;if(0===f)return n;for(r=0,u=n.length-1;u>=0;u--){if(i=n[u],r+=1,e.test(i)){if(0===u)break;o=n[u-1],t.test(o)&&(u-=1)}if(r===f)break}return n.substring(0,u)}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).removeLastCodePoint=t(); +//# sourceMappingURL=index.js.map diff --git a/index.js.map b/index.js.map new file mode 100644 index 0000000..d557af8 --- /dev/null +++ b/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\nvar RE_UTF16_LOW_SURROGATE = /[\\uDC00-\\uDFFF]/; // TODO: replace with stdlib pkg\nvar RE_UTF16_HIGH_SURROGATE = /[\\uD800-\\uDBFF]/; // TODO: replace with stdlib pkg\n\n\n// MAIN //\n\n/**\n* Removes the last `n` Unicode code points of a string.\n*\n* @param {string} str - input string\n* @param {NonNegativeInteger} n - number of Unicode code points to remove\n* @returns {string} output string\n*\n* @example\n* var out = removeLast( 'last man standing', 1 );\n* // returns 'last man standin'\n*\n* @example\n* var out = removeLast( 'presidential election', 1 );\n* // returns 'presidential electio'\n*\n* @example\n* var out = removeLast( 'JavaScript', 1 );\n* // returns 'JavaScrip'\n*\n* @example\n* var out = removeLast( 'Hidden Treasures', 1 );\n* // returns 'Hidden Treasure'\n*/\nfunction removeLast( str, n ) {\n\tvar len;\n\tvar ch1;\n\tvar ch2;\n\tvar cnt;\n\tvar i;\n\tif ( n === 0 ) {\n\t\treturn str;\n\t}\n\tlen = str.length;\n\tcnt = 0;\n\n\t// Process the string one Unicode code unit at a time and count UTF-16 surrogate pairs as a single Unicode code point...\n\tfor ( i = len - 1; i >= 0; i-- ) {\n\t\tch1 = str[ i ];\n\t\tcnt += 1;\n\n\t\t// Check for a low UTF-16 surrogate...\n\t\tif ( RE_UTF16_LOW_SURROGATE.test( ch1 ) ) {\n\t\t\t// Check for an unpaired surrogate at the end of the input string...\n\t\t\tif ( i === 0 ) {\n\t\t\t\t// We found an unpaired surrogate...\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\t// Check whether the high surrogate is paired with a low surrogate...\n\t\t\tch2 = str[ i-1 ];\n\t\t\tif ( RE_UTF16_HIGH_SURROGATE.test( ch2 ) ) {\n\t\t\t\t// We found a surrogate pair:\n\t\t\t\ti -= 1; // bump the index to process the next code unit\n\t\t\t}\n\t\t}\n\t\t// Check whether we've found the desired number of code points...\n\t\tif ( cnt === n ) {\n\t\t\tbreak;\n\t\t}\n\t}\n\treturn str.substring( 0, i );\n}\n\n\n// EXPORTS //\n\nexport default removeLast;\n"],"names":["RE_UTF16_LOW_SURROGATE","RE_UTF16_HIGH_SURROGATE","str","n","ch1","ch2","cnt","i","length","test","substring"],"mappings":";yCAsBA,IAAIA,EAAyB,kBACzBC,EAA0B,yBA4B9B,SAAqBC,EAAKC,GACzB,IACIC,EACAC,EACAC,EACAC,EACJ,GAAW,IAANJ,EACJ,OAAOD,EAMR,IAHAI,EAAM,EAGAC,EAJAL,EAAIM,OAIM,EAAGD,GAAK,EAAGA,IAAM,CAKhC,GAJAH,EAAMF,EAAKK,GACXD,GAAO,EAGFN,EAAuBS,KAAML,GAAQ,CAEzC,GAAW,IAANG,EAEJ,MAGDF,EAAMH,EAAKK,EAAE,GACRN,EAAwBQ,KAAMJ,KAElCE,GAAK,EAEN,CAED,GAAKD,IAAQH,EACZ,KAED,CACD,OAAOD,EAAIQ,UAAW,EAAGH,EAC1B"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 9860da0..0000000 --- a/lib/index.js +++ /dev/null @@ -1,43 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Remove the last `n` Unicode code points of a string. -* -* @module @stdlib/string-base-remove-last-code-point -* -* @example -* var removeLast = require( '@stdlib/string-base-remove-last-code-point' ); -* -* var out = removeLast( 'last man standing', 1 ); -* // returns 'last man standin' -* -* out = removeLast( 'Hidden Treasures', 1 ); -* // returns 'Hidden Treasure'; -*/ - -// 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 fc34187..0000000 --- a/lib/main.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// VARIABLES // - -var RE_UTF16_LOW_SURROGATE = /[\uDC00-\uDFFF]/; // TODO: replace with stdlib pkg -var RE_UTF16_HIGH_SURROGATE = /[\uD800-\uDBFF]/; // TODO: replace with stdlib pkg - - -// MAIN // - -/** -* Removes the last `n` Unicode code points of a string. -* -* @param {string} str - input string -* @param {NonNegativeInteger} n - number of Unicode code points to remove -* @returns {string} output string -* -* @example -* var out = removeLast( 'last man standing', 1 ); -* // returns 'last man standin' -* -* @example -* var out = removeLast( 'presidential election', 1 ); -* // returns 'presidential electio' -* -* @example -* var out = removeLast( 'JavaScript', 1 ); -* // returns 'JavaScrip' -* -* @example -* var out = removeLast( 'Hidden Treasures', 1 ); -* // returns 'Hidden Treasure' -*/ -function removeLast( str, n ) { - var len; - var ch1; - var ch2; - var cnt; - var i; - if ( n === 0 ) { - return str; - } - len = str.length; - cnt = 0; - - // Process the string one Unicode code unit at a time and count UTF-16 surrogate pairs as a single Unicode code point... - for ( i = len - 1; i >= 0; i-- ) { - ch1 = str[ i ]; - cnt += 1; - - // Check for a low UTF-16 surrogate... - if ( RE_UTF16_LOW_SURROGATE.test( ch1 ) ) { - // Check for an unpaired surrogate at the end of the input string... - if ( i === 0 ) { - // We found an unpaired surrogate... - break; - } - // Check whether the high surrogate is paired with a low surrogate... - ch2 = str[ i-1 ]; - if ( RE_UTF16_HIGH_SURROGATE.test( ch2 ) ) { - // We found a surrogate pair: - i -= 1; // bump the index to process the next code unit - } - } - // Check whether we've found the desired number of code points... - if ( cnt === n ) { - break; - } - } - return str.substring( 0, i ); -} - - -// EXPORTS // - -module.exports = removeLast; diff --git a/package.json b/package.json index 8dd3c53..e1a7e6d 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,7 @@ "version": "0.2.2", "description": "Remove the last Unicode code point of a string.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "main": "./index.js", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,31 +12,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/assert-is-string": "^0.2.2", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdstring", @@ -81,4 +32,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/stats_browser.html b/stats_browser.html new file mode 100644 index 0000000..2c17dcc --- /dev/null +++ b/stats_browser.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/stats_node.html b/stats_node.html new file mode 100644 index 0000000..1e086d4 --- /dev/null +++ b/stats_node.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index a25545e..0000000 --- a/test/test.js +++ /dev/null @@ -1,108 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var removeLast = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof removeLast, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns an empty string if provided an empty string', function test( t ) { - t.strictEqual( removeLast( '', 1 ), '', 'returns expected value' ); - t.strictEqual( removeLast( '', 2 ), '', 'returns expected value' ); - t.strictEqual( removeLast( '', 3 ), '', 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns the input string if provided zero as the second argument', function test( t ) { - t.strictEqual( removeLast( 'hello world', 0 ), 'hello world', 'returns expected value' ); - t.end(); -}); - -tape( 'the function removes the last Unicode code point of a provided string (ascii)', function test( t ) { - var out; - - out = removeLast( 'hello world', 1 ); - t.strictEqual( out, 'hello worl', 'returns expected value' ); - - out = removeLast( '!!!', 1 ); - t.strictEqual( out, '!!', 'returns expected value' ); - - out = removeLast( 'Hello World', 1 ); - t.strictEqual( out, 'Hello Worl', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function removes the last Unicode code point of a provided string (Unicode)', function test( t ) { - var out; - - out = removeLast( 'अनुच्छेद', 1 ); - t.strictEqual( out, 'अनुच्छे', 'returns expected value' ); - - out = removeLast( '六书/六書', 1 ); - t.strictEqual( out, '六书/六', 'returns expected value' ); - - out = removeLast( '𐒻𐓟', 1 ); - t.strictEqual( out, '𐒻', 'returns expected value' ); - - out = removeLast( '𐒻𐓟', 1 ); - t.strictEqual( out, '𐒻', 'returns expected value' ); - - out = removeLast( '\uDC00', 1 ); - t.strictEqual( out, '', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports removing the last `n` Unicode code points of a provided string', function test( t ) { - var out; - - out = removeLast( 'hello world', 1 ); - t.strictEqual( out, 'hello worl', 'returns expected value' ); - - out = removeLast( 'hello world', 7 ); - t.strictEqual( out, 'hell', 'returns expected value' ); - - out = removeLast( '!!!', 1 ); - t.strictEqual( out, '!!', 'returns expected value' ); - - out = removeLast( '!!!', 2 ); - t.strictEqual( out, '!', 'returns expected value' ); - - out = removeLast( 'अनुच्छेद', 1 ); - t.strictEqual( out, 'अनुच्छे', 'returns expected value' ); - - out = removeLast( '六书/六書', 3 ); - t.strictEqual( out, '六书', 'returns expected value' ); - - out = removeLast( '𐒻𐓟𐓟', 2 ); - t.strictEqual( out, '𐒻', 'returns expected value' ); - - t.end(); -}); From 00431b85dce4c31b7ec7686d39dc035b88730486 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Sep 2024 00:43:05 +0000 Subject: [PATCH 75/92] Transform error messages --- package.json | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index d1c7913..8dd3c53 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,9 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": {}, + "dependencies": { + "@stdlib/error-tools-fmtprodmsg": "^0.2.2" + }, "devDependencies": { "@stdlib/assert-is-string": "^0.2.2", "tape": "git+https://github.com/kgryte/tape.git#fix/globby", @@ -79,4 +81,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 29df712b3561c857ce11c91b0d301aa9173a2c8f Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Sep 2024 00:49:52 +0000 Subject: [PATCH 76/92] Remove files --- browser.js | 3 - browser.js.map | 1 - index.js | 3 - index.js.map | 1 - stats_browser.html | 4842 -------------------------------------------- stats_node.html | 4842 -------------------------------------------- 6 files changed, 9692 deletions(-) delete mode 100644 browser.js delete mode 100644 browser.js.map delete mode 100644 index.js delete mode 100644 index.js.map delete mode 100644 stats_browser.html delete mode 100644 stats_node.html diff --git a/browser.js b/browser.js deleted file mode 100644 index f3a511a..0000000 --- a/browser.js +++ /dev/null @@ -1,3 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -var e,t;e=this,t=function(){"use strict";var e=/[\uDC00-\uDFFF]/,t=/[\uD800-\uDBFF]/;return function(n,f){var i,o,r,u;if(0===f)return n;for(r=0,u=n.length-1;u>=0;u--){if(i=n[u],r+=1,e.test(i)){if(0===u)break;o=n[u-1],t.test(o)&&(u-=1)}if(r===f)break}return n.substring(0,u)}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).removeLastCodePoint=t(); -//# sourceMappingURL=browser.js.map diff --git a/browser.js.map b/browser.js.map deleted file mode 100644 index 19908eb..0000000 --- a/browser.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"browser.js","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\nvar RE_UTF16_LOW_SURROGATE = /[\\uDC00-\\uDFFF]/; // TODO: replace with stdlib pkg\nvar RE_UTF16_HIGH_SURROGATE = /[\\uD800-\\uDBFF]/; // TODO: replace with stdlib pkg\n\n\n// MAIN //\n\n/**\n* Removes the last `n` Unicode code points of a string.\n*\n* @param {string} str - input string\n* @param {NonNegativeInteger} n - number of Unicode code points to remove\n* @returns {string} output string\n*\n* @example\n* var out = removeLast( 'last man standing', 1 );\n* // returns 'last man standin'\n*\n* @example\n* var out = removeLast( 'presidential election', 1 );\n* // returns 'presidential electio'\n*\n* @example\n* var out = removeLast( 'JavaScript', 1 );\n* // returns 'JavaScrip'\n*\n* @example\n* var out = removeLast( 'Hidden Treasures', 1 );\n* // returns 'Hidden Treasure'\n*/\nfunction removeLast( str, n ) {\n\tvar len;\n\tvar ch1;\n\tvar ch2;\n\tvar cnt;\n\tvar i;\n\tif ( n === 0 ) {\n\t\treturn str;\n\t}\n\tlen = str.length;\n\tcnt = 0;\n\n\t// Process the string one Unicode code unit at a time and count UTF-16 surrogate pairs as a single Unicode code point...\n\tfor ( i = len - 1; i >= 0; i-- ) {\n\t\tch1 = str[ i ];\n\t\tcnt += 1;\n\n\t\t// Check for a low UTF-16 surrogate...\n\t\tif ( RE_UTF16_LOW_SURROGATE.test( ch1 ) ) {\n\t\t\t// Check for an unpaired surrogate at the end of the input string...\n\t\t\tif ( i === 0 ) {\n\t\t\t\t// We found an unpaired surrogate...\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\t// Check whether the high surrogate is paired with a low surrogate...\n\t\t\tch2 = str[ i-1 ];\n\t\t\tif ( RE_UTF16_HIGH_SURROGATE.test( ch2 ) ) {\n\t\t\t\t// We found a surrogate pair:\n\t\t\t\ti -= 1; // bump the index to process the next code unit\n\t\t\t}\n\t\t}\n\t\t// Check whether we've found the desired number of code points...\n\t\tif ( cnt === n ) {\n\t\t\tbreak;\n\t\t}\n\t}\n\treturn str.substring( 0, i );\n}\n\n\n// EXPORTS //\n\nexport default removeLast;\n"],"names":["RE_UTF16_LOW_SURROGATE","RE_UTF16_HIGH_SURROGATE","str","n","ch1","ch2","cnt","i","length","test","substring"],"mappings":";yCAsBA,IAAIA,EAAyB,kBACzBC,EAA0B,yBA4B9B,SAAqBC,EAAKC,GACzB,IACIC,EACAC,EACAC,EACAC,EACJ,GAAW,IAANJ,EACJ,OAAOD,EAMR,IAHAI,EAAM,EAGAC,EAJAL,EAAIM,OAIM,EAAGD,GAAK,EAAGA,IAAM,CAKhC,GAJAH,EAAMF,EAAKK,GACXD,GAAO,EAGFN,EAAuBS,KAAML,GAAQ,CAEzC,GAAW,IAANG,EAEJ,MAGDF,EAAMH,EAAKK,EAAE,GACRN,EAAwBQ,KAAMJ,KAElCE,GAAK,EAEN,CAED,GAAKD,IAAQH,EACZ,KAED,CACD,OAAOD,EAAIQ,UAAW,EAAGH,EAC1B"} \ No newline at end of file diff --git a/index.js b/index.js deleted file mode 100644 index 4e500d1..0000000 --- a/index.js +++ /dev/null @@ -1,3 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -var e,t;e=this,t=function(){"use strict";var e=/[\uDC00-\uDFFF]/,t=/[\uD800-\uDBFF]/;return function(n,f){var i,o,r,u;if(0===f)return n;for(r=0,u=n.length-1;u>=0;u--){if(i=n[u],r+=1,e.test(i)){if(0===u)break;o=n[u-1],t.test(o)&&(u-=1)}if(r===f)break}return n.substring(0,u)}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).removeLastCodePoint=t(); -//# sourceMappingURL=index.js.map diff --git a/index.js.map b/index.js.map deleted file mode 100644 index d557af8..0000000 --- a/index.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.js","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\nvar RE_UTF16_LOW_SURROGATE = /[\\uDC00-\\uDFFF]/; // TODO: replace with stdlib pkg\nvar RE_UTF16_HIGH_SURROGATE = /[\\uD800-\\uDBFF]/; // TODO: replace with stdlib pkg\n\n\n// MAIN //\n\n/**\n* Removes the last `n` Unicode code points of a string.\n*\n* @param {string} str - input string\n* @param {NonNegativeInteger} n - number of Unicode code points to remove\n* @returns {string} output string\n*\n* @example\n* var out = removeLast( 'last man standing', 1 );\n* // returns 'last man standin'\n*\n* @example\n* var out = removeLast( 'presidential election', 1 );\n* // returns 'presidential electio'\n*\n* @example\n* var out = removeLast( 'JavaScript', 1 );\n* // returns 'JavaScrip'\n*\n* @example\n* var out = removeLast( 'Hidden Treasures', 1 );\n* // returns 'Hidden Treasure'\n*/\nfunction removeLast( str, n ) {\n\tvar len;\n\tvar ch1;\n\tvar ch2;\n\tvar cnt;\n\tvar i;\n\tif ( n === 0 ) {\n\t\treturn str;\n\t}\n\tlen = str.length;\n\tcnt = 0;\n\n\t// Process the string one Unicode code unit at a time and count UTF-16 surrogate pairs as a single Unicode code point...\n\tfor ( i = len - 1; i >= 0; i-- ) {\n\t\tch1 = str[ i ];\n\t\tcnt += 1;\n\n\t\t// Check for a low UTF-16 surrogate...\n\t\tif ( RE_UTF16_LOW_SURROGATE.test( ch1 ) ) {\n\t\t\t// Check for an unpaired surrogate at the end of the input string...\n\t\t\tif ( i === 0 ) {\n\t\t\t\t// We found an unpaired surrogate...\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\t// Check whether the high surrogate is paired with a low surrogate...\n\t\t\tch2 = str[ i-1 ];\n\t\t\tif ( RE_UTF16_HIGH_SURROGATE.test( ch2 ) ) {\n\t\t\t\t// We found a surrogate pair:\n\t\t\t\ti -= 1; // bump the index to process the next code unit\n\t\t\t}\n\t\t}\n\t\t// Check whether we've found the desired number of code points...\n\t\tif ( cnt === n ) {\n\t\t\tbreak;\n\t\t}\n\t}\n\treturn str.substring( 0, i );\n}\n\n\n// EXPORTS //\n\nexport default removeLast;\n"],"names":["RE_UTF16_LOW_SURROGATE","RE_UTF16_HIGH_SURROGATE","str","n","ch1","ch2","cnt","i","length","test","substring"],"mappings":";yCAsBA,IAAIA,EAAyB,kBACzBC,EAA0B,yBA4B9B,SAAqBC,EAAKC,GACzB,IACIC,EACAC,EACAC,EACAC,EACJ,GAAW,IAANJ,EACJ,OAAOD,EAMR,IAHAI,EAAM,EAGAC,EAJAL,EAAIM,OAIM,EAAGD,GAAK,EAAGA,IAAM,CAKhC,GAJAH,EAAMF,EAAKK,GACXD,GAAO,EAGFN,EAAuBS,KAAML,GAAQ,CAEzC,GAAW,IAANG,EAEJ,MAGDF,EAAMH,EAAKK,EAAE,GACRN,EAAwBQ,KAAMJ,KAElCE,GAAK,EAEN,CAED,GAAKD,IAAQH,EACZ,KAED,CACD,OAAOD,EAAIQ,UAAW,EAAGH,EAC1B"} \ No newline at end of file diff --git a/stats_browser.html b/stats_browser.html deleted file mode 100644 index 2c17dcc..0000000 --- a/stats_browser.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - diff --git a/stats_node.html b/stats_node.html deleted file mode 100644 index 1e086d4..0000000 --- a/stats_node.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From ba8b8c64b6becf15caa24eaae7eb41e50b1f0595 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Sep 2024 00:50:08 +0000 Subject: [PATCH 77/92] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 66 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 794 ---- .github/workflows/publish.yml | 252 -- .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .gitignore | 190 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 99 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 52 +- SECURITY.md | 5 - benchmark/benchmark.js | 56 - branches.md | 56 - browser.js | 3 + browser.js.map | 1 + dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 29 - docs/types/index.d.ts | 53 - docs/types/test.ts | 57 - examples/index.js | 33 - index.js | 3 + index.js.map | 1 + lib/index.js | 43 - lib/main.js | 94 - package.json | 53 +- stats_browser.html | 4842 +++++++++++++++++++++ stats_node.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 108 - 46 files changed, 9728 insertions(+), 3926 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md create mode 100644 browser.js create mode 100644 browser.js.map 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/index.d.ts delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js create mode 100644 index.js create mode 100644 index.js.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats_browser.html create mode 100644 stats_node.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 76292c6..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-09-01T00:42:29.665Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 52cd9c4..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/base/remove-last-code-point) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 533eeee..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/base/remove-last-code-point) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 2a724f2..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: '29 5 * * 0' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index f4575e9..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,794 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n +``` -```javascript -var removeLastCodePoint = require( '@stdlib/string-base-remove-last-code-point' ); +If no recognized module system is present, access bundle contents via the global scope: + +```html + ``` #### removeLastCodePoint( str, n ) @@ -91,8 +97,13 @@ out = removeLastCodePoint( 'foo bar', 10 ); -```javascript -var removeLastCodePoint = require( '@stdlib/string-base-remove-last-code-point' ); +```html + + + + + + + ```
diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index a39bd29..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,56 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var removeLast = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var values; - var out; - var i; - - values = [ - 'beep boop', - 'foo bar', - 'xyz abc', - '🐶🐮🐷🐰🐸' - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = removeLast( values[ i%values.length ], 1 ); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( !isString( out ) ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index f585c99..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/base/remove-last-code-point" -%% click B href "https://github.com/stdlib-js/string-base-remove-last-code-point/tree/main" -%% click C href "https://github.com/stdlib-js/string-base-remove-last-code-point/tree/production" -%% click D href "https://github.com/stdlib-js/string-base-remove-last-code-point/tree/esm" -%% click E href "https://github.com/stdlib-js/string-base-remove-last-code-point/tree/deno" -%% click F href "https://github.com/stdlib-js/string-base-remove-last-code-point/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/base/remove-last-code-point -[production-url]: https://github.com/stdlib-js/string-base-remove-last-code-point/tree/production -[deno-url]: https://github.com/stdlib-js/string-base-remove-last-code-point/tree/deno -[deno-readme]: https://github.com/stdlib-js/string-base-remove-last-code-point/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/string-base-remove-last-code-point/tree/umd -[umd-readme]: https://github.com/stdlib-js/string-base-remove-last-code-point/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/string-base-remove-last-code-point/tree/esm -[esm-readme]: https://github.com/stdlib-js/string-base-remove-last-code-point/blob/esm/README.md \ No newline at end of file diff --git a/browser.js b/browser.js new file mode 100644 index 0000000..f3a511a --- /dev/null +++ b/browser.js @@ -0,0 +1,3 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +var e,t;e=this,t=function(){"use strict";var e=/[\uDC00-\uDFFF]/,t=/[\uD800-\uDBFF]/;return function(n,f){var i,o,r,u;if(0===f)return n;for(r=0,u=n.length-1;u>=0;u--){if(i=n[u],r+=1,e.test(i)){if(0===u)break;o=n[u-1],t.test(o)&&(u-=1)}if(r===f)break}return n.substring(0,u)}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).removeLastCodePoint=t(); +//# sourceMappingURL=browser.js.map diff --git a/browser.js.map b/browser.js.map new file mode 100644 index 0000000..19908eb --- /dev/null +++ b/browser.js.map @@ -0,0 +1 @@ +{"version":3,"file":"browser.js","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\nvar RE_UTF16_LOW_SURROGATE = /[\\uDC00-\\uDFFF]/; // TODO: replace with stdlib pkg\nvar RE_UTF16_HIGH_SURROGATE = /[\\uD800-\\uDBFF]/; // TODO: replace with stdlib pkg\n\n\n// MAIN //\n\n/**\n* Removes the last `n` Unicode code points of a string.\n*\n* @param {string} str - input string\n* @param {NonNegativeInteger} n - number of Unicode code points to remove\n* @returns {string} output string\n*\n* @example\n* var out = removeLast( 'last man standing', 1 );\n* // returns 'last man standin'\n*\n* @example\n* var out = removeLast( 'presidential election', 1 );\n* // returns 'presidential electio'\n*\n* @example\n* var out = removeLast( 'JavaScript', 1 );\n* // returns 'JavaScrip'\n*\n* @example\n* var out = removeLast( 'Hidden Treasures', 1 );\n* // returns 'Hidden Treasure'\n*/\nfunction removeLast( str, n ) {\n\tvar len;\n\tvar ch1;\n\tvar ch2;\n\tvar cnt;\n\tvar i;\n\tif ( n === 0 ) {\n\t\treturn str;\n\t}\n\tlen = str.length;\n\tcnt = 0;\n\n\t// Process the string one Unicode code unit at a time and count UTF-16 surrogate pairs as a single Unicode code point...\n\tfor ( i = len - 1; i >= 0; i-- ) {\n\t\tch1 = str[ i ];\n\t\tcnt += 1;\n\n\t\t// Check for a low UTF-16 surrogate...\n\t\tif ( RE_UTF16_LOW_SURROGATE.test( ch1 ) ) {\n\t\t\t// Check for an unpaired surrogate at the end of the input string...\n\t\t\tif ( i === 0 ) {\n\t\t\t\t// We found an unpaired surrogate...\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\t// Check whether the high surrogate is paired with a low surrogate...\n\t\t\tch2 = str[ i-1 ];\n\t\t\tif ( RE_UTF16_HIGH_SURROGATE.test( ch2 ) ) {\n\t\t\t\t// We found a surrogate pair:\n\t\t\t\ti -= 1; // bump the index to process the next code unit\n\t\t\t}\n\t\t}\n\t\t// Check whether we've found the desired number of code points...\n\t\tif ( cnt === n ) {\n\t\t\tbreak;\n\t\t}\n\t}\n\treturn str.substring( 0, i );\n}\n\n\n// EXPORTS //\n\nexport default removeLast;\n"],"names":["RE_UTF16_LOW_SURROGATE","RE_UTF16_HIGH_SURROGATE","str","n","ch1","ch2","cnt","i","length","test","substring"],"mappings":";yCAsBA,IAAIA,EAAyB,kBACzBC,EAA0B,yBA4B9B,SAAqBC,EAAKC,GACzB,IACIC,EACAC,EACAC,EACAC,EACJ,GAAW,IAANJ,EACJ,OAAOD,EAMR,IAHAI,EAAM,EAGAC,EAJAL,EAAIM,OAIM,EAAGD,GAAK,EAAGA,IAAM,CAKhC,GAJAH,EAAMF,EAAKK,GACXD,GAAO,EAGFN,EAAuBS,KAAML,GAAQ,CAEzC,GAAW,IAANG,EAEJ,MAGDF,EAAMH,EAAKK,EAAE,GACRN,EAAwBQ,KAAMJ,KAElCE,GAAK,EAEN,CAED,GAAKD,IAAQH,EACZ,KAED,CACD,OAAOD,EAAIQ,UAAW,EAAGH,EAC1B"} \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index 8c96fd7..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import removeLast from '../docs/types/index'; -export = removeLast; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index e6b7220..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var s=function(e,t){return function(){return t||e((t={exports:{}}).exports,t),t.exports}};var f=s(function(D,n){ -var F=/[\uDC00-\uDFFF]/,c=/[\uD800-\uDBFF]/;function R(e,t){var i,u,v,a,r;if(t===0)return e;for(i=e.length,a=0,r=i-1;r>=0;r--){if(u=e[r],a+=1,F.test(u)){if(r===0)break;v=e[r-1],c.test(v)&&(r-=1)}if(a===t)break}return e.substring(0,r)}n.exports=R -});var _=f();module.exports=_; -/** @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 72561cf..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\nvar RE_UTF16_LOW_SURROGATE = /[\\uDC00-\\uDFFF]/; // TODO: replace with stdlib pkg\nvar RE_UTF16_HIGH_SURROGATE = /[\\uD800-\\uDBFF]/; // TODO: replace with stdlib pkg\n\n\n// MAIN //\n\n/**\n* Removes the last `n` Unicode code points of a string.\n*\n* @param {string} str - input string\n* @param {NonNegativeInteger} n - number of Unicode code points to remove\n* @returns {string} output string\n*\n* @example\n* var out = removeLast( 'last man standing', 1 );\n* // returns 'last man standin'\n*\n* @example\n* var out = removeLast( 'presidential election', 1 );\n* // returns 'presidential electio'\n*\n* @example\n* var out = removeLast( 'JavaScript', 1 );\n* // returns 'JavaScrip'\n*\n* @example\n* var out = removeLast( 'Hidden Treasures', 1 );\n* // returns 'Hidden Treasure'\n*/\nfunction removeLast( str, n ) {\n\tvar len;\n\tvar ch1;\n\tvar ch2;\n\tvar cnt;\n\tvar i;\n\tif ( n === 0 ) {\n\t\treturn str;\n\t}\n\tlen = str.length;\n\tcnt = 0;\n\n\t// Process the string one Unicode code unit at a time and count UTF-16 surrogate pairs as a single Unicode code point...\n\tfor ( i = len - 1; i >= 0; i-- ) {\n\t\tch1 = str[ i ];\n\t\tcnt += 1;\n\n\t\t// Check for a low UTF-16 surrogate...\n\t\tif ( RE_UTF16_LOW_SURROGATE.test( ch1 ) ) {\n\t\t\t// Check for an unpaired surrogate at the end of the input string...\n\t\t\tif ( i === 0 ) {\n\t\t\t\t// We found an unpaired surrogate...\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\t// Check whether the high surrogate is paired with a low surrogate...\n\t\t\tch2 = str[ i-1 ];\n\t\t\tif ( RE_UTF16_HIGH_SURROGATE.test( ch2 ) ) {\n\t\t\t\t// We found a surrogate pair:\n\t\t\t\ti -= 1; // bump the index to process the next code unit\n\t\t\t}\n\t\t}\n\t\t// Check whether we've found the desired number of code points...\n\t\tif ( cnt === n ) {\n\t\t\tbreak;\n\t\t}\n\t}\n\treturn str.substring( 0, i );\n}\n\n\n// EXPORTS //\n\nmodule.exports = removeLast;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Remove the last `n` Unicode code points of a string.\n*\n* @module @stdlib/string-base-remove-last-code-point\n*\n* @example\n* var removeLast = require( '@stdlib/string-base-remove-last-code-point' );\n*\n* var out = removeLast( 'last man standing', 1 );\n* // returns 'last man standin'\n*\n* out = removeLast( 'Hidden Treasures', 1 );\n* // returns 'Hidden Treasure';\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,EAAyB,kBACzBC,EAA0B,kBA4B9B,SAASC,EAAYC,EAAKC,EAAI,CAC7B,IAAIC,EACAC,EACAC,EACAC,EACAC,EACJ,GAAKL,IAAM,EACV,OAAOD,EAMR,IAJAE,EAAMF,EAAI,OACVK,EAAM,EAGAC,EAAIJ,EAAM,EAAGI,GAAK,EAAGA,IAAM,CAKhC,GAJAH,EAAMH,EAAKM,CAAE,EACbD,GAAO,EAGFR,EAAuB,KAAMM,CAAI,EAAI,CAEzC,GAAKG,IAAM,EAEV,MAGDF,EAAMJ,EAAKM,EAAE,CAAE,EACVR,EAAwB,KAAMM,CAAI,IAEtCE,GAAK,EAEP,CAEA,GAAKD,IAAQJ,EACZ,KAEF,CACA,OAAOD,EAAI,UAAW,EAAGM,CAAE,CAC5B,CAKAV,EAAO,QAAUG,ICxDjB,IAAIQ,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "RE_UTF16_LOW_SURROGATE", "RE_UTF16_HIGH_SURROGATE", "removeLast", "str", "n", "len", "ch1", "ch2", "cnt", "i", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index a08ea55..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,29 +0,0 @@ - -{{alias}}( str, n ) - Removes the last `n` Unicode code points of a string. - - Parameters - ---------- - str: string - Input string. - - n: integer - Number of Unicode code points to remove. - - Returns - ------- - out: string - Output string. - - Examples - -------- - > var out = {{alias}}( 'beep', 1 ) - 'bee' - > out = {{alias}}( 'Boop', 1 ) - 'Boo' - > out = {{alias}}( 'foo bar', 5 ) - 'fo' - - See Also - -------- - diff --git a/docs/types/index.d.ts b/docs/types/index.d.ts deleted file mode 100644 index 8a1c90b..0000000 --- a/docs/types/index.d.ts +++ /dev/null @@ -1,53 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 - -/** -* Removes the last `n` Unicode code points of a string. -* -* @param str - input string -* @param n - number of code points to remove -* @returns output string -* -* @example -* var out = removeLast( 'last man standing', 1 ); -* // returns 'last man standin' -* -* @example -* var out = removeLast( 'presidential election', 1 ); -* // returns 'presidential electio' -* -* @example -* var out = removeLast( 'JavaScript', 1 ); -* // returns 'JavaScrip' -* -* @example -* var out = removeLast( 'Hidden Treasures', 1 ); -* // returns 'Hidden Treasure' -* -* @example -* var out = removeLast( 'foo bar', 5 ); -* // returns 'fo' -*/ -declare function removeLast( str: string, n: number ): string; - - -// EXPORTS // - -export = removeLast; diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index fd426d2..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,57 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 removeLast = require( './index' ); - - -// TESTS // - -// The function returns a string... -{ - removeLast( 'abc', 1 ); // $ExpectType string -} - -// The compiler throws an error if the function is provided a value other than a string... -{ - removeLast( true, 1 ); // $ExpectError - removeLast( false, 1 ); // $ExpectError - removeLast( null, 1 ); // $ExpectError - removeLast( undefined, 1 ); // $ExpectError - removeLast( 5, 1 ); // $ExpectError - removeLast( [], 1 ); // $ExpectError - removeLast( {}, 1 ); // $ExpectError - removeLast( ( x: number ): number => x, 1 ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument that is not a number... -{ - removeLast( 'abc', true ); // $ExpectError - removeLast( 'abc', false ); // $ExpectError - removeLast( 'abc', null ); // $ExpectError - removeLast( 'abc', 'abc' ); // $ExpectError - removeLast( 'abc', [] ); // $ExpectError - removeLast( 'abc', {} ); // $ExpectError - removeLast( 'abc', ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - removeLast(); // $ExpectError - removeLast( 'abc' ); // $ExpectError - removeLast( 'abc', 1, 2 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 085633e..0000000 --- a/examples/index.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var removeLastCodePoint = require( './../lib' ); - -console.log( removeLastCodePoint( 'presidential election', 1 ) ); -// => 'presidential electio' - -console.log( removeLastCodePoint( 'JavaScript', 1 ) ); -// => 'JavaScrip' - -console.log( removeLastCodePoint( 'The Last of the Mohicans', 5 ) ); -// => 'The Last of the Moh' - -console.log( removeLastCodePoint( 'अनुच्छेद', 1 ) ); -// => 'अनुच्छे' diff --git a/index.js b/index.js new file mode 100644 index 0000000..4e500d1 --- /dev/null +++ b/index.js @@ -0,0 +1,3 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +var e,t;e=this,t=function(){"use strict";var e=/[\uDC00-\uDFFF]/,t=/[\uD800-\uDBFF]/;return function(n,f){var i,o,r,u;if(0===f)return n;for(r=0,u=n.length-1;u>=0;u--){if(i=n[u],r+=1,e.test(i)){if(0===u)break;o=n[u-1],t.test(o)&&(u-=1)}if(r===f)break}return n.substring(0,u)}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).removeLastCodePoint=t(); +//# sourceMappingURL=index.js.map diff --git a/index.js.map b/index.js.map new file mode 100644 index 0000000..d557af8 --- /dev/null +++ b/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\nvar RE_UTF16_LOW_SURROGATE = /[\\uDC00-\\uDFFF]/; // TODO: replace with stdlib pkg\nvar RE_UTF16_HIGH_SURROGATE = /[\\uD800-\\uDBFF]/; // TODO: replace with stdlib pkg\n\n\n// MAIN //\n\n/**\n* Removes the last `n` Unicode code points of a string.\n*\n* @param {string} str - input string\n* @param {NonNegativeInteger} n - number of Unicode code points to remove\n* @returns {string} output string\n*\n* @example\n* var out = removeLast( 'last man standing', 1 );\n* // returns 'last man standin'\n*\n* @example\n* var out = removeLast( 'presidential election', 1 );\n* // returns 'presidential electio'\n*\n* @example\n* var out = removeLast( 'JavaScript', 1 );\n* // returns 'JavaScrip'\n*\n* @example\n* var out = removeLast( 'Hidden Treasures', 1 );\n* // returns 'Hidden Treasure'\n*/\nfunction removeLast( str, n ) {\n\tvar len;\n\tvar ch1;\n\tvar ch2;\n\tvar cnt;\n\tvar i;\n\tif ( n === 0 ) {\n\t\treturn str;\n\t}\n\tlen = str.length;\n\tcnt = 0;\n\n\t// Process the string one Unicode code unit at a time and count UTF-16 surrogate pairs as a single Unicode code point...\n\tfor ( i = len - 1; i >= 0; i-- ) {\n\t\tch1 = str[ i ];\n\t\tcnt += 1;\n\n\t\t// Check for a low UTF-16 surrogate...\n\t\tif ( RE_UTF16_LOW_SURROGATE.test( ch1 ) ) {\n\t\t\t// Check for an unpaired surrogate at the end of the input string...\n\t\t\tif ( i === 0 ) {\n\t\t\t\t// We found an unpaired surrogate...\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\t// Check whether the high surrogate is paired with a low surrogate...\n\t\t\tch2 = str[ i-1 ];\n\t\t\tif ( RE_UTF16_HIGH_SURROGATE.test( ch2 ) ) {\n\t\t\t\t// We found a surrogate pair:\n\t\t\t\ti -= 1; // bump the index to process the next code unit\n\t\t\t}\n\t\t}\n\t\t// Check whether we've found the desired number of code points...\n\t\tif ( cnt === n ) {\n\t\t\tbreak;\n\t\t}\n\t}\n\treturn str.substring( 0, i );\n}\n\n\n// EXPORTS //\n\nexport default removeLast;\n"],"names":["RE_UTF16_LOW_SURROGATE","RE_UTF16_HIGH_SURROGATE","str","n","ch1","ch2","cnt","i","length","test","substring"],"mappings":";yCAsBA,IAAIA,EAAyB,kBACzBC,EAA0B,yBA4B9B,SAAqBC,EAAKC,GACzB,IACIC,EACAC,EACAC,EACAC,EACJ,GAAW,IAANJ,EACJ,OAAOD,EAMR,IAHAI,EAAM,EAGAC,EAJAL,EAAIM,OAIM,EAAGD,GAAK,EAAGA,IAAM,CAKhC,GAJAH,EAAMF,EAAKK,GACXD,GAAO,EAGFN,EAAuBS,KAAML,GAAQ,CAEzC,GAAW,IAANG,EAEJ,MAGDF,EAAMH,EAAKK,EAAE,GACRN,EAAwBQ,KAAMJ,KAElCE,GAAK,EAEN,CAED,GAAKD,IAAQH,EACZ,KAED,CACD,OAAOD,EAAIQ,UAAW,EAAGH,EAC1B"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 9860da0..0000000 --- a/lib/index.js +++ /dev/null @@ -1,43 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Remove the last `n` Unicode code points of a string. -* -* @module @stdlib/string-base-remove-last-code-point -* -* @example -* var removeLast = require( '@stdlib/string-base-remove-last-code-point' ); -* -* var out = removeLast( 'last man standing', 1 ); -* // returns 'last man standin' -* -* out = removeLast( 'Hidden Treasures', 1 ); -* // returns 'Hidden Treasure'; -*/ - -// 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 fc34187..0000000 --- a/lib/main.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// VARIABLES // - -var RE_UTF16_LOW_SURROGATE = /[\uDC00-\uDFFF]/; // TODO: replace with stdlib pkg -var RE_UTF16_HIGH_SURROGATE = /[\uD800-\uDBFF]/; // TODO: replace with stdlib pkg - - -// MAIN // - -/** -* Removes the last `n` Unicode code points of a string. -* -* @param {string} str - input string -* @param {NonNegativeInteger} n - number of Unicode code points to remove -* @returns {string} output string -* -* @example -* var out = removeLast( 'last man standing', 1 ); -* // returns 'last man standin' -* -* @example -* var out = removeLast( 'presidential election', 1 ); -* // returns 'presidential electio' -* -* @example -* var out = removeLast( 'JavaScript', 1 ); -* // returns 'JavaScrip' -* -* @example -* var out = removeLast( 'Hidden Treasures', 1 ); -* // returns 'Hidden Treasure' -*/ -function removeLast( str, n ) { - var len; - var ch1; - var ch2; - var cnt; - var i; - if ( n === 0 ) { - return str; - } - len = str.length; - cnt = 0; - - // Process the string one Unicode code unit at a time and count UTF-16 surrogate pairs as a single Unicode code point... - for ( i = len - 1; i >= 0; i-- ) { - ch1 = str[ i ]; - cnt += 1; - - // Check for a low UTF-16 surrogate... - if ( RE_UTF16_LOW_SURROGATE.test( ch1 ) ) { - // Check for an unpaired surrogate at the end of the input string... - if ( i === 0 ) { - // We found an unpaired surrogate... - break; - } - // Check whether the high surrogate is paired with a low surrogate... - ch2 = str[ i-1 ]; - if ( RE_UTF16_HIGH_SURROGATE.test( ch2 ) ) { - // We found a surrogate pair: - i -= 1; // bump the index to process the next code unit - } - } - // Check whether we've found the desired number of code points... - if ( cnt === n ) { - break; - } - } - return str.substring( 0, i ); -} - - -// EXPORTS // - -module.exports = removeLast; diff --git a/package.json b/package.json index 8dd3c53..e1a7e6d 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,7 @@ "version": "0.2.2", "description": "Remove the last Unicode code point of a string.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "main": "./index.js", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,31 +12,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/assert-is-string": "^0.2.2", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdstring", @@ -81,4 +32,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/stats_browser.html b/stats_browser.html new file mode 100644 index 0000000..2c17dcc --- /dev/null +++ b/stats_browser.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/stats_node.html b/stats_node.html new file mode 100644 index 0000000..1e086d4 --- /dev/null +++ b/stats_node.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index a25545e..0000000 --- a/test/test.js +++ /dev/null @@ -1,108 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var removeLast = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof removeLast, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns an empty string if provided an empty string', function test( t ) { - t.strictEqual( removeLast( '', 1 ), '', 'returns expected value' ); - t.strictEqual( removeLast( '', 2 ), '', 'returns expected value' ); - t.strictEqual( removeLast( '', 3 ), '', 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns the input string if provided zero as the second argument', function test( t ) { - t.strictEqual( removeLast( 'hello world', 0 ), 'hello world', 'returns expected value' ); - t.end(); -}); - -tape( 'the function removes the last Unicode code point of a provided string (ascii)', function test( t ) { - var out; - - out = removeLast( 'hello world', 1 ); - t.strictEqual( out, 'hello worl', 'returns expected value' ); - - out = removeLast( '!!!', 1 ); - t.strictEqual( out, '!!', 'returns expected value' ); - - out = removeLast( 'Hello World', 1 ); - t.strictEqual( out, 'Hello Worl', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function removes the last Unicode code point of a provided string (Unicode)', function test( t ) { - var out; - - out = removeLast( 'अनुच्छेद', 1 ); - t.strictEqual( out, 'अनुच्छे', 'returns expected value' ); - - out = removeLast( '六书/六書', 1 ); - t.strictEqual( out, '六书/六', 'returns expected value' ); - - out = removeLast( '𐒻𐓟', 1 ); - t.strictEqual( out, '𐒻', 'returns expected value' ); - - out = removeLast( '𐒻𐓟', 1 ); - t.strictEqual( out, '𐒻', 'returns expected value' ); - - out = removeLast( '\uDC00', 1 ); - t.strictEqual( out, '', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports removing the last `n` Unicode code points of a provided string', function test( t ) { - var out; - - out = removeLast( 'hello world', 1 ); - t.strictEqual( out, 'hello worl', 'returns expected value' ); - - out = removeLast( 'hello world', 7 ); - t.strictEqual( out, 'hell', 'returns expected value' ); - - out = removeLast( '!!!', 1 ); - t.strictEqual( out, '!!', 'returns expected value' ); - - out = removeLast( '!!!', 2 ); - t.strictEqual( out, '!', 'returns expected value' ); - - out = removeLast( 'अनुच्छेद', 1 ); - t.strictEqual( out, 'अनुच्छे', 'returns expected value' ); - - out = removeLast( '六书/六書', 3 ); - t.strictEqual( out, '六书', 'returns expected value' ); - - out = removeLast( '𐒻𐓟𐓟', 2 ); - t.strictEqual( out, '𐒻', 'returns expected value' ); - - t.end(); -}); From 849356d60c8ba3397dc15942aab27c65887dcfd5 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 1 Oct 2024 00:43:02 +0000 Subject: [PATCH 78/92] Transform error messages --- package.json | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index d1c7913..8dd3c53 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,9 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": {}, + "dependencies": { + "@stdlib/error-tools-fmtprodmsg": "^0.2.2" + }, "devDependencies": { "@stdlib/assert-is-string": "^0.2.2", "tape": "git+https://github.com/kgryte/tape.git#fix/globby", @@ -79,4 +81,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From cb09456a47c786f9b0ec7a8405f7ebe3b3397b3d Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 1 Oct 2024 00:48:49 +0000 Subject: [PATCH 79/92] Remove files --- browser.js | 3 - browser.js.map | 1 - index.js | 3 - index.js.map | 1 - stats_browser.html | 4842 -------------------------------------------- stats_node.html | 4842 -------------------------------------------- 6 files changed, 9692 deletions(-) delete mode 100644 browser.js delete mode 100644 browser.js.map delete mode 100644 index.js delete mode 100644 index.js.map delete mode 100644 stats_browser.html delete mode 100644 stats_node.html diff --git a/browser.js b/browser.js deleted file mode 100644 index f3a511a..0000000 --- a/browser.js +++ /dev/null @@ -1,3 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -var e,t;e=this,t=function(){"use strict";var e=/[\uDC00-\uDFFF]/,t=/[\uD800-\uDBFF]/;return function(n,f){var i,o,r,u;if(0===f)return n;for(r=0,u=n.length-1;u>=0;u--){if(i=n[u],r+=1,e.test(i)){if(0===u)break;o=n[u-1],t.test(o)&&(u-=1)}if(r===f)break}return n.substring(0,u)}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).removeLastCodePoint=t(); -//# sourceMappingURL=browser.js.map diff --git a/browser.js.map b/browser.js.map deleted file mode 100644 index 19908eb..0000000 --- a/browser.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"browser.js","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\nvar RE_UTF16_LOW_SURROGATE = /[\\uDC00-\\uDFFF]/; // TODO: replace with stdlib pkg\nvar RE_UTF16_HIGH_SURROGATE = /[\\uD800-\\uDBFF]/; // TODO: replace with stdlib pkg\n\n\n// MAIN //\n\n/**\n* Removes the last `n` Unicode code points of a string.\n*\n* @param {string} str - input string\n* @param {NonNegativeInteger} n - number of Unicode code points to remove\n* @returns {string} output string\n*\n* @example\n* var out = removeLast( 'last man standing', 1 );\n* // returns 'last man standin'\n*\n* @example\n* var out = removeLast( 'presidential election', 1 );\n* // returns 'presidential electio'\n*\n* @example\n* var out = removeLast( 'JavaScript', 1 );\n* // returns 'JavaScrip'\n*\n* @example\n* var out = removeLast( 'Hidden Treasures', 1 );\n* // returns 'Hidden Treasure'\n*/\nfunction removeLast( str, n ) {\n\tvar len;\n\tvar ch1;\n\tvar ch2;\n\tvar cnt;\n\tvar i;\n\tif ( n === 0 ) {\n\t\treturn str;\n\t}\n\tlen = str.length;\n\tcnt = 0;\n\n\t// Process the string one Unicode code unit at a time and count UTF-16 surrogate pairs as a single Unicode code point...\n\tfor ( i = len - 1; i >= 0; i-- ) {\n\t\tch1 = str[ i ];\n\t\tcnt += 1;\n\n\t\t// Check for a low UTF-16 surrogate...\n\t\tif ( RE_UTF16_LOW_SURROGATE.test( ch1 ) ) {\n\t\t\t// Check for an unpaired surrogate at the end of the input string...\n\t\t\tif ( i === 0 ) {\n\t\t\t\t// We found an unpaired surrogate...\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\t// Check whether the high surrogate is paired with a low surrogate...\n\t\t\tch2 = str[ i-1 ];\n\t\t\tif ( RE_UTF16_HIGH_SURROGATE.test( ch2 ) ) {\n\t\t\t\t// We found a surrogate pair:\n\t\t\t\ti -= 1; // bump the index to process the next code unit\n\t\t\t}\n\t\t}\n\t\t// Check whether we've found the desired number of code points...\n\t\tif ( cnt === n ) {\n\t\t\tbreak;\n\t\t}\n\t}\n\treturn str.substring( 0, i );\n}\n\n\n// EXPORTS //\n\nexport default removeLast;\n"],"names":["RE_UTF16_LOW_SURROGATE","RE_UTF16_HIGH_SURROGATE","str","n","ch1","ch2","cnt","i","length","test","substring"],"mappings":";yCAsBA,IAAIA,EAAyB,kBACzBC,EAA0B,yBA4B9B,SAAqBC,EAAKC,GACzB,IACIC,EACAC,EACAC,EACAC,EACJ,GAAW,IAANJ,EACJ,OAAOD,EAMR,IAHAI,EAAM,EAGAC,EAJAL,EAAIM,OAIM,EAAGD,GAAK,EAAGA,IAAM,CAKhC,GAJAH,EAAMF,EAAKK,GACXD,GAAO,EAGFN,EAAuBS,KAAML,GAAQ,CAEzC,GAAW,IAANG,EAEJ,MAGDF,EAAMH,EAAKK,EAAE,GACRN,EAAwBQ,KAAMJ,KAElCE,GAAK,EAEN,CAED,GAAKD,IAAQH,EACZ,KAED,CACD,OAAOD,EAAIQ,UAAW,EAAGH,EAC1B"} \ No newline at end of file diff --git a/index.js b/index.js deleted file mode 100644 index 4e500d1..0000000 --- a/index.js +++ /dev/null @@ -1,3 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -var e,t;e=this,t=function(){"use strict";var e=/[\uDC00-\uDFFF]/,t=/[\uD800-\uDBFF]/;return function(n,f){var i,o,r,u;if(0===f)return n;for(r=0,u=n.length-1;u>=0;u--){if(i=n[u],r+=1,e.test(i)){if(0===u)break;o=n[u-1],t.test(o)&&(u-=1)}if(r===f)break}return n.substring(0,u)}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).removeLastCodePoint=t(); -//# sourceMappingURL=index.js.map diff --git a/index.js.map b/index.js.map deleted file mode 100644 index d557af8..0000000 --- a/index.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.js","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\nvar RE_UTF16_LOW_SURROGATE = /[\\uDC00-\\uDFFF]/; // TODO: replace with stdlib pkg\nvar RE_UTF16_HIGH_SURROGATE = /[\\uD800-\\uDBFF]/; // TODO: replace with stdlib pkg\n\n\n// MAIN //\n\n/**\n* Removes the last `n` Unicode code points of a string.\n*\n* @param {string} str - input string\n* @param {NonNegativeInteger} n - number of Unicode code points to remove\n* @returns {string} output string\n*\n* @example\n* var out = removeLast( 'last man standing', 1 );\n* // returns 'last man standin'\n*\n* @example\n* var out = removeLast( 'presidential election', 1 );\n* // returns 'presidential electio'\n*\n* @example\n* var out = removeLast( 'JavaScript', 1 );\n* // returns 'JavaScrip'\n*\n* @example\n* var out = removeLast( 'Hidden Treasures', 1 );\n* // returns 'Hidden Treasure'\n*/\nfunction removeLast( str, n ) {\n\tvar len;\n\tvar ch1;\n\tvar ch2;\n\tvar cnt;\n\tvar i;\n\tif ( n === 0 ) {\n\t\treturn str;\n\t}\n\tlen = str.length;\n\tcnt = 0;\n\n\t// Process the string one Unicode code unit at a time and count UTF-16 surrogate pairs as a single Unicode code point...\n\tfor ( i = len - 1; i >= 0; i-- ) {\n\t\tch1 = str[ i ];\n\t\tcnt += 1;\n\n\t\t// Check for a low UTF-16 surrogate...\n\t\tif ( RE_UTF16_LOW_SURROGATE.test( ch1 ) ) {\n\t\t\t// Check for an unpaired surrogate at the end of the input string...\n\t\t\tif ( i === 0 ) {\n\t\t\t\t// We found an unpaired surrogate...\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\t// Check whether the high surrogate is paired with a low surrogate...\n\t\t\tch2 = str[ i-1 ];\n\t\t\tif ( RE_UTF16_HIGH_SURROGATE.test( ch2 ) ) {\n\t\t\t\t// We found a surrogate pair:\n\t\t\t\ti -= 1; // bump the index to process the next code unit\n\t\t\t}\n\t\t}\n\t\t// Check whether we've found the desired number of code points...\n\t\tif ( cnt === n ) {\n\t\t\tbreak;\n\t\t}\n\t}\n\treturn str.substring( 0, i );\n}\n\n\n// EXPORTS //\n\nexport default removeLast;\n"],"names":["RE_UTF16_LOW_SURROGATE","RE_UTF16_HIGH_SURROGATE","str","n","ch1","ch2","cnt","i","length","test","substring"],"mappings":";yCAsBA,IAAIA,EAAyB,kBACzBC,EAA0B,yBA4B9B,SAAqBC,EAAKC,GACzB,IACIC,EACAC,EACAC,EACAC,EACJ,GAAW,IAANJ,EACJ,OAAOD,EAMR,IAHAI,EAAM,EAGAC,EAJAL,EAAIM,OAIM,EAAGD,GAAK,EAAGA,IAAM,CAKhC,GAJAH,EAAMF,EAAKK,GACXD,GAAO,EAGFN,EAAuBS,KAAML,GAAQ,CAEzC,GAAW,IAANG,EAEJ,MAGDF,EAAMH,EAAKK,EAAE,GACRN,EAAwBQ,KAAMJ,KAElCE,GAAK,EAEN,CAED,GAAKD,IAAQH,EACZ,KAED,CACD,OAAOD,EAAIQ,UAAW,EAAGH,EAC1B"} \ No newline at end of file diff --git a/stats_browser.html b/stats_browser.html deleted file mode 100644 index 2c17dcc..0000000 --- a/stats_browser.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - diff --git a/stats_node.html b/stats_node.html deleted file mode 100644 index 1e086d4..0000000 --- a/stats_node.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From aef6ec62f55d669f207dc13a77ffdf1b38f07281 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 1 Oct 2024 00:49:01 +0000 Subject: [PATCH 80/92] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 66 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 794 ---- .github/workflows/publish.yml | 252 -- .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .gitignore | 190 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 99 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 52 +- SECURITY.md | 5 - benchmark/benchmark.js | 56 - branches.md | 56 - browser.js | 3 + browser.js.map | 1 + dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 29 - docs/types/index.d.ts | 53 - docs/types/test.ts | 57 - examples/index.js | 33 - index.js | 3 + index.js.map | 1 + lib/index.js | 43 - lib/main.js | 94 - package.json | 53 +- stats_browser.html | 4842 +++++++++++++++++++++ stats_node.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 108 - 46 files changed, 9728 insertions(+), 3926 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md create mode 100644 browser.js create mode 100644 browser.js.map 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/index.d.ts delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js create mode 100644 index.js create mode 100644 index.js.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats_browser.html create mode 100644 stats_node.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 743748f..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-10-01T00:42:22.761Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 52cd9c4..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/base/remove-last-code-point) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 533eeee..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/base/remove-last-code-point) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 2a724f2..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: '29 5 * * 0' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index f4575e9..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,794 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n +``` -```javascript -var removeLastCodePoint = require( '@stdlib/string-base-remove-last-code-point' ); +If no recognized module system is present, access bundle contents via the global scope: + +```html + ``` #### removeLastCodePoint( str, n ) @@ -91,8 +97,13 @@ out = removeLastCodePoint( 'foo bar', 10 ); -```javascript -var removeLastCodePoint = require( '@stdlib/string-base-remove-last-code-point' ); +```html + + + + + + + ```
diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index a39bd29..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,56 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var removeLast = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var values; - var out; - var i; - - values = [ - 'beep boop', - 'foo bar', - 'xyz abc', - '🐶🐮🐷🐰🐸' - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = removeLast( values[ i%values.length ], 1 ); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( !isString( out ) ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index f585c99..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/base/remove-last-code-point" -%% click B href "https://github.com/stdlib-js/string-base-remove-last-code-point/tree/main" -%% click C href "https://github.com/stdlib-js/string-base-remove-last-code-point/tree/production" -%% click D href "https://github.com/stdlib-js/string-base-remove-last-code-point/tree/esm" -%% click E href "https://github.com/stdlib-js/string-base-remove-last-code-point/tree/deno" -%% click F href "https://github.com/stdlib-js/string-base-remove-last-code-point/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/base/remove-last-code-point -[production-url]: https://github.com/stdlib-js/string-base-remove-last-code-point/tree/production -[deno-url]: https://github.com/stdlib-js/string-base-remove-last-code-point/tree/deno -[deno-readme]: https://github.com/stdlib-js/string-base-remove-last-code-point/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/string-base-remove-last-code-point/tree/umd -[umd-readme]: https://github.com/stdlib-js/string-base-remove-last-code-point/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/string-base-remove-last-code-point/tree/esm -[esm-readme]: https://github.com/stdlib-js/string-base-remove-last-code-point/blob/esm/README.md \ No newline at end of file diff --git a/browser.js b/browser.js new file mode 100644 index 0000000..f3a511a --- /dev/null +++ b/browser.js @@ -0,0 +1,3 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +var e,t;e=this,t=function(){"use strict";var e=/[\uDC00-\uDFFF]/,t=/[\uD800-\uDBFF]/;return function(n,f){var i,o,r,u;if(0===f)return n;for(r=0,u=n.length-1;u>=0;u--){if(i=n[u],r+=1,e.test(i)){if(0===u)break;o=n[u-1],t.test(o)&&(u-=1)}if(r===f)break}return n.substring(0,u)}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).removeLastCodePoint=t(); +//# sourceMappingURL=browser.js.map diff --git a/browser.js.map b/browser.js.map new file mode 100644 index 0000000..19908eb --- /dev/null +++ b/browser.js.map @@ -0,0 +1 @@ +{"version":3,"file":"browser.js","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\nvar RE_UTF16_LOW_SURROGATE = /[\\uDC00-\\uDFFF]/; // TODO: replace with stdlib pkg\nvar RE_UTF16_HIGH_SURROGATE = /[\\uD800-\\uDBFF]/; // TODO: replace with stdlib pkg\n\n\n// MAIN //\n\n/**\n* Removes the last `n` Unicode code points of a string.\n*\n* @param {string} str - input string\n* @param {NonNegativeInteger} n - number of Unicode code points to remove\n* @returns {string} output string\n*\n* @example\n* var out = removeLast( 'last man standing', 1 );\n* // returns 'last man standin'\n*\n* @example\n* var out = removeLast( 'presidential election', 1 );\n* // returns 'presidential electio'\n*\n* @example\n* var out = removeLast( 'JavaScript', 1 );\n* // returns 'JavaScrip'\n*\n* @example\n* var out = removeLast( 'Hidden Treasures', 1 );\n* // returns 'Hidden Treasure'\n*/\nfunction removeLast( str, n ) {\n\tvar len;\n\tvar ch1;\n\tvar ch2;\n\tvar cnt;\n\tvar i;\n\tif ( n === 0 ) {\n\t\treturn str;\n\t}\n\tlen = str.length;\n\tcnt = 0;\n\n\t// Process the string one Unicode code unit at a time and count UTF-16 surrogate pairs as a single Unicode code point...\n\tfor ( i = len - 1; i >= 0; i-- ) {\n\t\tch1 = str[ i ];\n\t\tcnt += 1;\n\n\t\t// Check for a low UTF-16 surrogate...\n\t\tif ( RE_UTF16_LOW_SURROGATE.test( ch1 ) ) {\n\t\t\t// Check for an unpaired surrogate at the end of the input string...\n\t\t\tif ( i === 0 ) {\n\t\t\t\t// We found an unpaired surrogate...\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\t// Check whether the high surrogate is paired with a low surrogate...\n\t\t\tch2 = str[ i-1 ];\n\t\t\tif ( RE_UTF16_HIGH_SURROGATE.test( ch2 ) ) {\n\t\t\t\t// We found a surrogate pair:\n\t\t\t\ti -= 1; // bump the index to process the next code unit\n\t\t\t}\n\t\t}\n\t\t// Check whether we've found the desired number of code points...\n\t\tif ( cnt === n ) {\n\t\t\tbreak;\n\t\t}\n\t}\n\treturn str.substring( 0, i );\n}\n\n\n// EXPORTS //\n\nexport default removeLast;\n"],"names":["RE_UTF16_LOW_SURROGATE","RE_UTF16_HIGH_SURROGATE","str","n","ch1","ch2","cnt","i","length","test","substring"],"mappings":";yCAsBA,IAAIA,EAAyB,kBACzBC,EAA0B,yBA4B9B,SAAqBC,EAAKC,GACzB,IACIC,EACAC,EACAC,EACAC,EACJ,GAAW,IAANJ,EACJ,OAAOD,EAMR,IAHAI,EAAM,EAGAC,EAJAL,EAAIM,OAIM,EAAGD,GAAK,EAAGA,IAAM,CAKhC,GAJAH,EAAMF,EAAKK,GACXD,GAAO,EAGFN,EAAuBS,KAAML,GAAQ,CAEzC,GAAW,IAANG,EAEJ,MAGDF,EAAMH,EAAKK,EAAE,GACRN,EAAwBQ,KAAMJ,KAElCE,GAAK,EAEN,CAED,GAAKD,IAAQH,EACZ,KAED,CACD,OAAOD,EAAIQ,UAAW,EAAGH,EAC1B"} \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index 8c96fd7..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import removeLast from '../docs/types/index'; -export = removeLast; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index e6b7220..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var s=function(e,t){return function(){return t||e((t={exports:{}}).exports,t),t.exports}};var f=s(function(D,n){ -var F=/[\uDC00-\uDFFF]/,c=/[\uD800-\uDBFF]/;function R(e,t){var i,u,v,a,r;if(t===0)return e;for(i=e.length,a=0,r=i-1;r>=0;r--){if(u=e[r],a+=1,F.test(u)){if(r===0)break;v=e[r-1],c.test(v)&&(r-=1)}if(a===t)break}return e.substring(0,r)}n.exports=R -});var _=f();module.exports=_; -/** @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 72561cf..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\nvar RE_UTF16_LOW_SURROGATE = /[\\uDC00-\\uDFFF]/; // TODO: replace with stdlib pkg\nvar RE_UTF16_HIGH_SURROGATE = /[\\uD800-\\uDBFF]/; // TODO: replace with stdlib pkg\n\n\n// MAIN //\n\n/**\n* Removes the last `n` Unicode code points of a string.\n*\n* @param {string} str - input string\n* @param {NonNegativeInteger} n - number of Unicode code points to remove\n* @returns {string} output string\n*\n* @example\n* var out = removeLast( 'last man standing', 1 );\n* // returns 'last man standin'\n*\n* @example\n* var out = removeLast( 'presidential election', 1 );\n* // returns 'presidential electio'\n*\n* @example\n* var out = removeLast( 'JavaScript', 1 );\n* // returns 'JavaScrip'\n*\n* @example\n* var out = removeLast( 'Hidden Treasures', 1 );\n* // returns 'Hidden Treasure'\n*/\nfunction removeLast( str, n ) {\n\tvar len;\n\tvar ch1;\n\tvar ch2;\n\tvar cnt;\n\tvar i;\n\tif ( n === 0 ) {\n\t\treturn str;\n\t}\n\tlen = str.length;\n\tcnt = 0;\n\n\t// Process the string one Unicode code unit at a time and count UTF-16 surrogate pairs as a single Unicode code point...\n\tfor ( i = len - 1; i >= 0; i-- ) {\n\t\tch1 = str[ i ];\n\t\tcnt += 1;\n\n\t\t// Check for a low UTF-16 surrogate...\n\t\tif ( RE_UTF16_LOW_SURROGATE.test( ch1 ) ) {\n\t\t\t// Check for an unpaired surrogate at the end of the input string...\n\t\t\tif ( i === 0 ) {\n\t\t\t\t// We found an unpaired surrogate...\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\t// Check whether the high surrogate is paired with a low surrogate...\n\t\t\tch2 = str[ i-1 ];\n\t\t\tif ( RE_UTF16_HIGH_SURROGATE.test( ch2 ) ) {\n\t\t\t\t// We found a surrogate pair:\n\t\t\t\ti -= 1; // bump the index to process the next code unit\n\t\t\t}\n\t\t}\n\t\t// Check whether we've found the desired number of code points...\n\t\tif ( cnt === n ) {\n\t\t\tbreak;\n\t\t}\n\t}\n\treturn str.substring( 0, i );\n}\n\n\n// EXPORTS //\n\nmodule.exports = removeLast;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Remove the last `n` Unicode code points of a string.\n*\n* @module @stdlib/string-base-remove-last-code-point\n*\n* @example\n* var removeLast = require( '@stdlib/string-base-remove-last-code-point' );\n*\n* var out = removeLast( 'last man standing', 1 );\n* // returns 'last man standin'\n*\n* out = removeLast( 'Hidden Treasures', 1 );\n* // returns 'Hidden Treasure';\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,EAAyB,kBACzBC,EAA0B,kBA4B9B,SAASC,EAAYC,EAAKC,EAAI,CAC7B,IAAIC,EACAC,EACAC,EACAC,EACAC,EACJ,GAAKL,IAAM,EACV,OAAOD,EAMR,IAJAE,EAAMF,EAAI,OACVK,EAAM,EAGAC,EAAIJ,EAAM,EAAGI,GAAK,EAAGA,IAAM,CAKhC,GAJAH,EAAMH,EAAKM,CAAE,EACbD,GAAO,EAGFR,EAAuB,KAAMM,CAAI,EAAI,CAEzC,GAAKG,IAAM,EAEV,MAGDF,EAAMJ,EAAKM,EAAE,CAAE,EACVR,EAAwB,KAAMM,CAAI,IAEtCE,GAAK,EAEP,CAEA,GAAKD,IAAQJ,EACZ,KAEF,CACA,OAAOD,EAAI,UAAW,EAAGM,CAAE,CAC5B,CAKAV,EAAO,QAAUG,ICxDjB,IAAIQ,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "RE_UTF16_LOW_SURROGATE", "RE_UTF16_HIGH_SURROGATE", "removeLast", "str", "n", "len", "ch1", "ch2", "cnt", "i", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index a08ea55..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,29 +0,0 @@ - -{{alias}}( str, n ) - Removes the last `n` Unicode code points of a string. - - Parameters - ---------- - str: string - Input string. - - n: integer - Number of Unicode code points to remove. - - Returns - ------- - out: string - Output string. - - Examples - -------- - > var out = {{alias}}( 'beep', 1 ) - 'bee' - > out = {{alias}}( 'Boop', 1 ) - 'Boo' - > out = {{alias}}( 'foo bar', 5 ) - 'fo' - - See Also - -------- - diff --git a/docs/types/index.d.ts b/docs/types/index.d.ts deleted file mode 100644 index 8a1c90b..0000000 --- a/docs/types/index.d.ts +++ /dev/null @@ -1,53 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 - -/** -* Removes the last `n` Unicode code points of a string. -* -* @param str - input string -* @param n - number of code points to remove -* @returns output string -* -* @example -* var out = removeLast( 'last man standing', 1 ); -* // returns 'last man standin' -* -* @example -* var out = removeLast( 'presidential election', 1 ); -* // returns 'presidential electio' -* -* @example -* var out = removeLast( 'JavaScript', 1 ); -* // returns 'JavaScrip' -* -* @example -* var out = removeLast( 'Hidden Treasures', 1 ); -* // returns 'Hidden Treasure' -* -* @example -* var out = removeLast( 'foo bar', 5 ); -* // returns 'fo' -*/ -declare function removeLast( str: string, n: number ): string; - - -// EXPORTS // - -export = removeLast; diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index fd426d2..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,57 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 removeLast = require( './index' ); - - -// TESTS // - -// The function returns a string... -{ - removeLast( 'abc', 1 ); // $ExpectType string -} - -// The compiler throws an error if the function is provided a value other than a string... -{ - removeLast( true, 1 ); // $ExpectError - removeLast( false, 1 ); // $ExpectError - removeLast( null, 1 ); // $ExpectError - removeLast( undefined, 1 ); // $ExpectError - removeLast( 5, 1 ); // $ExpectError - removeLast( [], 1 ); // $ExpectError - removeLast( {}, 1 ); // $ExpectError - removeLast( ( x: number ): number => x, 1 ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument that is not a number... -{ - removeLast( 'abc', true ); // $ExpectError - removeLast( 'abc', false ); // $ExpectError - removeLast( 'abc', null ); // $ExpectError - removeLast( 'abc', 'abc' ); // $ExpectError - removeLast( 'abc', [] ); // $ExpectError - removeLast( 'abc', {} ); // $ExpectError - removeLast( 'abc', ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - removeLast(); // $ExpectError - removeLast( 'abc' ); // $ExpectError - removeLast( 'abc', 1, 2 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 085633e..0000000 --- a/examples/index.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var removeLastCodePoint = require( './../lib' ); - -console.log( removeLastCodePoint( 'presidential election', 1 ) ); -// => 'presidential electio' - -console.log( removeLastCodePoint( 'JavaScript', 1 ) ); -// => 'JavaScrip' - -console.log( removeLastCodePoint( 'The Last of the Mohicans', 5 ) ); -// => 'The Last of the Moh' - -console.log( removeLastCodePoint( 'अनुच्छेद', 1 ) ); -// => 'अनुच्छे' diff --git a/index.js b/index.js new file mode 100644 index 0000000..4e500d1 --- /dev/null +++ b/index.js @@ -0,0 +1,3 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +var e,t;e=this,t=function(){"use strict";var e=/[\uDC00-\uDFFF]/,t=/[\uD800-\uDBFF]/;return function(n,f){var i,o,r,u;if(0===f)return n;for(r=0,u=n.length-1;u>=0;u--){if(i=n[u],r+=1,e.test(i)){if(0===u)break;o=n[u-1],t.test(o)&&(u-=1)}if(r===f)break}return n.substring(0,u)}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).removeLastCodePoint=t(); +//# sourceMappingURL=index.js.map diff --git a/index.js.map b/index.js.map new file mode 100644 index 0000000..d557af8 --- /dev/null +++ b/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\nvar RE_UTF16_LOW_SURROGATE = /[\\uDC00-\\uDFFF]/; // TODO: replace with stdlib pkg\nvar RE_UTF16_HIGH_SURROGATE = /[\\uD800-\\uDBFF]/; // TODO: replace with stdlib pkg\n\n\n// MAIN //\n\n/**\n* Removes the last `n` Unicode code points of a string.\n*\n* @param {string} str - input string\n* @param {NonNegativeInteger} n - number of Unicode code points to remove\n* @returns {string} output string\n*\n* @example\n* var out = removeLast( 'last man standing', 1 );\n* // returns 'last man standin'\n*\n* @example\n* var out = removeLast( 'presidential election', 1 );\n* // returns 'presidential electio'\n*\n* @example\n* var out = removeLast( 'JavaScript', 1 );\n* // returns 'JavaScrip'\n*\n* @example\n* var out = removeLast( 'Hidden Treasures', 1 );\n* // returns 'Hidden Treasure'\n*/\nfunction removeLast( str, n ) {\n\tvar len;\n\tvar ch1;\n\tvar ch2;\n\tvar cnt;\n\tvar i;\n\tif ( n === 0 ) {\n\t\treturn str;\n\t}\n\tlen = str.length;\n\tcnt = 0;\n\n\t// Process the string one Unicode code unit at a time and count UTF-16 surrogate pairs as a single Unicode code point...\n\tfor ( i = len - 1; i >= 0; i-- ) {\n\t\tch1 = str[ i ];\n\t\tcnt += 1;\n\n\t\t// Check for a low UTF-16 surrogate...\n\t\tif ( RE_UTF16_LOW_SURROGATE.test( ch1 ) ) {\n\t\t\t// Check for an unpaired surrogate at the end of the input string...\n\t\t\tif ( i === 0 ) {\n\t\t\t\t// We found an unpaired surrogate...\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\t// Check whether the high surrogate is paired with a low surrogate...\n\t\t\tch2 = str[ i-1 ];\n\t\t\tif ( RE_UTF16_HIGH_SURROGATE.test( ch2 ) ) {\n\t\t\t\t// We found a surrogate pair:\n\t\t\t\ti -= 1; // bump the index to process the next code unit\n\t\t\t}\n\t\t}\n\t\t// Check whether we've found the desired number of code points...\n\t\tif ( cnt === n ) {\n\t\t\tbreak;\n\t\t}\n\t}\n\treturn str.substring( 0, i );\n}\n\n\n// EXPORTS //\n\nexport default removeLast;\n"],"names":["RE_UTF16_LOW_SURROGATE","RE_UTF16_HIGH_SURROGATE","str","n","ch1","ch2","cnt","i","length","test","substring"],"mappings":";yCAsBA,IAAIA,EAAyB,kBACzBC,EAA0B,yBA4B9B,SAAqBC,EAAKC,GACzB,IACIC,EACAC,EACAC,EACAC,EACJ,GAAW,IAANJ,EACJ,OAAOD,EAMR,IAHAI,EAAM,EAGAC,EAJAL,EAAIM,OAIM,EAAGD,GAAK,EAAGA,IAAM,CAKhC,GAJAH,EAAMF,EAAKK,GACXD,GAAO,EAGFN,EAAuBS,KAAML,GAAQ,CAEzC,GAAW,IAANG,EAEJ,MAGDF,EAAMH,EAAKK,EAAE,GACRN,EAAwBQ,KAAMJ,KAElCE,GAAK,EAEN,CAED,GAAKD,IAAQH,EACZ,KAED,CACD,OAAOD,EAAIQ,UAAW,EAAGH,EAC1B"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 9860da0..0000000 --- a/lib/index.js +++ /dev/null @@ -1,43 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Remove the last `n` Unicode code points of a string. -* -* @module @stdlib/string-base-remove-last-code-point -* -* @example -* var removeLast = require( '@stdlib/string-base-remove-last-code-point' ); -* -* var out = removeLast( 'last man standing', 1 ); -* // returns 'last man standin' -* -* out = removeLast( 'Hidden Treasures', 1 ); -* // returns 'Hidden Treasure'; -*/ - -// 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 fc34187..0000000 --- a/lib/main.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// VARIABLES // - -var RE_UTF16_LOW_SURROGATE = /[\uDC00-\uDFFF]/; // TODO: replace with stdlib pkg -var RE_UTF16_HIGH_SURROGATE = /[\uD800-\uDBFF]/; // TODO: replace with stdlib pkg - - -// MAIN // - -/** -* Removes the last `n` Unicode code points of a string. -* -* @param {string} str - input string -* @param {NonNegativeInteger} n - number of Unicode code points to remove -* @returns {string} output string -* -* @example -* var out = removeLast( 'last man standing', 1 ); -* // returns 'last man standin' -* -* @example -* var out = removeLast( 'presidential election', 1 ); -* // returns 'presidential electio' -* -* @example -* var out = removeLast( 'JavaScript', 1 ); -* // returns 'JavaScrip' -* -* @example -* var out = removeLast( 'Hidden Treasures', 1 ); -* // returns 'Hidden Treasure' -*/ -function removeLast( str, n ) { - var len; - var ch1; - var ch2; - var cnt; - var i; - if ( n === 0 ) { - return str; - } - len = str.length; - cnt = 0; - - // Process the string one Unicode code unit at a time and count UTF-16 surrogate pairs as a single Unicode code point... - for ( i = len - 1; i >= 0; i-- ) { - ch1 = str[ i ]; - cnt += 1; - - // Check for a low UTF-16 surrogate... - if ( RE_UTF16_LOW_SURROGATE.test( ch1 ) ) { - // Check for an unpaired surrogate at the end of the input string... - if ( i === 0 ) { - // We found an unpaired surrogate... - break; - } - // Check whether the high surrogate is paired with a low surrogate... - ch2 = str[ i-1 ]; - if ( RE_UTF16_HIGH_SURROGATE.test( ch2 ) ) { - // We found a surrogate pair: - i -= 1; // bump the index to process the next code unit - } - } - // Check whether we've found the desired number of code points... - if ( cnt === n ) { - break; - } - } - return str.substring( 0, i ); -} - - -// EXPORTS // - -module.exports = removeLast; diff --git a/package.json b/package.json index 8dd3c53..e1a7e6d 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,7 @@ "version": "0.2.2", "description": "Remove the last Unicode code point of a string.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "main": "./index.js", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,31 +12,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/assert-is-string": "^0.2.2", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdstring", @@ -81,4 +32,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/stats_browser.html b/stats_browser.html new file mode 100644 index 0000000..2c17dcc --- /dev/null +++ b/stats_browser.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/stats_node.html b/stats_node.html new file mode 100644 index 0000000..1e086d4 --- /dev/null +++ b/stats_node.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index a25545e..0000000 --- a/test/test.js +++ /dev/null @@ -1,108 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var removeLast = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof removeLast, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns an empty string if provided an empty string', function test( t ) { - t.strictEqual( removeLast( '', 1 ), '', 'returns expected value' ); - t.strictEqual( removeLast( '', 2 ), '', 'returns expected value' ); - t.strictEqual( removeLast( '', 3 ), '', 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns the input string if provided zero as the second argument', function test( t ) { - t.strictEqual( removeLast( 'hello world', 0 ), 'hello world', 'returns expected value' ); - t.end(); -}); - -tape( 'the function removes the last Unicode code point of a provided string (ascii)', function test( t ) { - var out; - - out = removeLast( 'hello world', 1 ); - t.strictEqual( out, 'hello worl', 'returns expected value' ); - - out = removeLast( '!!!', 1 ); - t.strictEqual( out, '!!', 'returns expected value' ); - - out = removeLast( 'Hello World', 1 ); - t.strictEqual( out, 'Hello Worl', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function removes the last Unicode code point of a provided string (Unicode)', function test( t ) { - var out; - - out = removeLast( 'अनुच्छेद', 1 ); - t.strictEqual( out, 'अनुच्छे', 'returns expected value' ); - - out = removeLast( '六书/六書', 1 ); - t.strictEqual( out, '六书/六', 'returns expected value' ); - - out = removeLast( '𐒻𐓟', 1 ); - t.strictEqual( out, '𐒻', 'returns expected value' ); - - out = removeLast( '𐒻𐓟', 1 ); - t.strictEqual( out, '𐒻', 'returns expected value' ); - - out = removeLast( '\uDC00', 1 ); - t.strictEqual( out, '', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports removing the last `n` Unicode code points of a provided string', function test( t ) { - var out; - - out = removeLast( 'hello world', 1 ); - t.strictEqual( out, 'hello worl', 'returns expected value' ); - - out = removeLast( 'hello world', 7 ); - t.strictEqual( out, 'hell', 'returns expected value' ); - - out = removeLast( '!!!', 1 ); - t.strictEqual( out, '!!', 'returns expected value' ); - - out = removeLast( '!!!', 2 ); - t.strictEqual( out, '!', 'returns expected value' ); - - out = removeLast( 'अनुच्छेद', 1 ); - t.strictEqual( out, 'अनुच्छे', 'returns expected value' ); - - out = removeLast( '六书/六書', 3 ); - t.strictEqual( out, '六书', 'returns expected value' ); - - out = removeLast( '𐒻𐓟𐓟', 2 ); - t.strictEqual( out, '𐒻', 'returns expected value' ); - - t.end(); -}); From c345299339003d9ae9b3fa71459fcc8e736e6581 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Nov 2024 00:43:21 +0000 Subject: [PATCH 81/92] Transform error messages --- package.json | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index d1c7913..8dd3c53 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,9 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": {}, + "dependencies": { + "@stdlib/error-tools-fmtprodmsg": "^0.2.2" + }, "devDependencies": { "@stdlib/assert-is-string": "^0.2.2", "tape": "git+https://github.com/kgryte/tape.git#fix/globby", @@ -79,4 +81,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 4199f9b25650b8bd42595555685c9793c6125173 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Nov 2024 00:48:18 +0000 Subject: [PATCH 82/92] Remove files --- browser.js | 3 - browser.js.map | 1 - index.js | 3 - index.js.map | 1 - stats_browser.html | 4842 -------------------------------------------- stats_node.html | 4842 -------------------------------------------- 6 files changed, 9692 deletions(-) delete mode 100644 browser.js delete mode 100644 browser.js.map delete mode 100644 index.js delete mode 100644 index.js.map delete mode 100644 stats_browser.html delete mode 100644 stats_node.html diff --git a/browser.js b/browser.js deleted file mode 100644 index f3a511a..0000000 --- a/browser.js +++ /dev/null @@ -1,3 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -var e,t;e=this,t=function(){"use strict";var e=/[\uDC00-\uDFFF]/,t=/[\uD800-\uDBFF]/;return function(n,f){var i,o,r,u;if(0===f)return n;for(r=0,u=n.length-1;u>=0;u--){if(i=n[u],r+=1,e.test(i)){if(0===u)break;o=n[u-1],t.test(o)&&(u-=1)}if(r===f)break}return n.substring(0,u)}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).removeLastCodePoint=t(); -//# sourceMappingURL=browser.js.map diff --git a/browser.js.map b/browser.js.map deleted file mode 100644 index 19908eb..0000000 --- a/browser.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"browser.js","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\nvar RE_UTF16_LOW_SURROGATE = /[\\uDC00-\\uDFFF]/; // TODO: replace with stdlib pkg\nvar RE_UTF16_HIGH_SURROGATE = /[\\uD800-\\uDBFF]/; // TODO: replace with stdlib pkg\n\n\n// MAIN //\n\n/**\n* Removes the last `n` Unicode code points of a string.\n*\n* @param {string} str - input string\n* @param {NonNegativeInteger} n - number of Unicode code points to remove\n* @returns {string} output string\n*\n* @example\n* var out = removeLast( 'last man standing', 1 );\n* // returns 'last man standin'\n*\n* @example\n* var out = removeLast( 'presidential election', 1 );\n* // returns 'presidential electio'\n*\n* @example\n* var out = removeLast( 'JavaScript', 1 );\n* // returns 'JavaScrip'\n*\n* @example\n* var out = removeLast( 'Hidden Treasures', 1 );\n* // returns 'Hidden Treasure'\n*/\nfunction removeLast( str, n ) {\n\tvar len;\n\tvar ch1;\n\tvar ch2;\n\tvar cnt;\n\tvar i;\n\tif ( n === 0 ) {\n\t\treturn str;\n\t}\n\tlen = str.length;\n\tcnt = 0;\n\n\t// Process the string one Unicode code unit at a time and count UTF-16 surrogate pairs as a single Unicode code point...\n\tfor ( i = len - 1; i >= 0; i-- ) {\n\t\tch1 = str[ i ];\n\t\tcnt += 1;\n\n\t\t// Check for a low UTF-16 surrogate...\n\t\tif ( RE_UTF16_LOW_SURROGATE.test( ch1 ) ) {\n\t\t\t// Check for an unpaired surrogate at the end of the input string...\n\t\t\tif ( i === 0 ) {\n\t\t\t\t// We found an unpaired surrogate...\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\t// Check whether the high surrogate is paired with a low surrogate...\n\t\t\tch2 = str[ i-1 ];\n\t\t\tif ( RE_UTF16_HIGH_SURROGATE.test( ch2 ) ) {\n\t\t\t\t// We found a surrogate pair:\n\t\t\t\ti -= 1; // bump the index to process the next code unit\n\t\t\t}\n\t\t}\n\t\t// Check whether we've found the desired number of code points...\n\t\tif ( cnt === n ) {\n\t\t\tbreak;\n\t\t}\n\t}\n\treturn str.substring( 0, i );\n}\n\n\n// EXPORTS //\n\nexport default removeLast;\n"],"names":["RE_UTF16_LOW_SURROGATE","RE_UTF16_HIGH_SURROGATE","str","n","ch1","ch2","cnt","i","length","test","substring"],"mappings":";yCAsBA,IAAIA,EAAyB,kBACzBC,EAA0B,yBA4B9B,SAAqBC,EAAKC,GACzB,IACIC,EACAC,EACAC,EACAC,EACJ,GAAW,IAANJ,EACJ,OAAOD,EAMR,IAHAI,EAAM,EAGAC,EAJAL,EAAIM,OAIM,EAAGD,GAAK,EAAGA,IAAM,CAKhC,GAJAH,EAAMF,EAAKK,GACXD,GAAO,EAGFN,EAAuBS,KAAML,GAAQ,CAEzC,GAAW,IAANG,EAEJ,MAGDF,EAAMH,EAAKK,EAAE,GACRN,EAAwBQ,KAAMJ,KAElCE,GAAK,EAEN,CAED,GAAKD,IAAQH,EACZ,KAED,CACD,OAAOD,EAAIQ,UAAW,EAAGH,EAC1B"} \ No newline at end of file diff --git a/index.js b/index.js deleted file mode 100644 index 4e500d1..0000000 --- a/index.js +++ /dev/null @@ -1,3 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -var e,t;e=this,t=function(){"use strict";var e=/[\uDC00-\uDFFF]/,t=/[\uD800-\uDBFF]/;return function(n,f){var i,o,r,u;if(0===f)return n;for(r=0,u=n.length-1;u>=0;u--){if(i=n[u],r+=1,e.test(i)){if(0===u)break;o=n[u-1],t.test(o)&&(u-=1)}if(r===f)break}return n.substring(0,u)}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).removeLastCodePoint=t(); -//# sourceMappingURL=index.js.map diff --git a/index.js.map b/index.js.map deleted file mode 100644 index d557af8..0000000 --- a/index.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.js","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\nvar RE_UTF16_LOW_SURROGATE = /[\\uDC00-\\uDFFF]/; // TODO: replace with stdlib pkg\nvar RE_UTF16_HIGH_SURROGATE = /[\\uD800-\\uDBFF]/; // TODO: replace with stdlib pkg\n\n\n// MAIN //\n\n/**\n* Removes the last `n` Unicode code points of a string.\n*\n* @param {string} str - input string\n* @param {NonNegativeInteger} n - number of Unicode code points to remove\n* @returns {string} output string\n*\n* @example\n* var out = removeLast( 'last man standing', 1 );\n* // returns 'last man standin'\n*\n* @example\n* var out = removeLast( 'presidential election', 1 );\n* // returns 'presidential electio'\n*\n* @example\n* var out = removeLast( 'JavaScript', 1 );\n* // returns 'JavaScrip'\n*\n* @example\n* var out = removeLast( 'Hidden Treasures', 1 );\n* // returns 'Hidden Treasure'\n*/\nfunction removeLast( str, n ) {\n\tvar len;\n\tvar ch1;\n\tvar ch2;\n\tvar cnt;\n\tvar i;\n\tif ( n === 0 ) {\n\t\treturn str;\n\t}\n\tlen = str.length;\n\tcnt = 0;\n\n\t// Process the string one Unicode code unit at a time and count UTF-16 surrogate pairs as a single Unicode code point...\n\tfor ( i = len - 1; i >= 0; i-- ) {\n\t\tch1 = str[ i ];\n\t\tcnt += 1;\n\n\t\t// Check for a low UTF-16 surrogate...\n\t\tif ( RE_UTF16_LOW_SURROGATE.test( ch1 ) ) {\n\t\t\t// Check for an unpaired surrogate at the end of the input string...\n\t\t\tif ( i === 0 ) {\n\t\t\t\t// We found an unpaired surrogate...\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\t// Check whether the high surrogate is paired with a low surrogate...\n\t\t\tch2 = str[ i-1 ];\n\t\t\tif ( RE_UTF16_HIGH_SURROGATE.test( ch2 ) ) {\n\t\t\t\t// We found a surrogate pair:\n\t\t\t\ti -= 1; // bump the index to process the next code unit\n\t\t\t}\n\t\t}\n\t\t// Check whether we've found the desired number of code points...\n\t\tif ( cnt === n ) {\n\t\t\tbreak;\n\t\t}\n\t}\n\treturn str.substring( 0, i );\n}\n\n\n// EXPORTS //\n\nexport default removeLast;\n"],"names":["RE_UTF16_LOW_SURROGATE","RE_UTF16_HIGH_SURROGATE","str","n","ch1","ch2","cnt","i","length","test","substring"],"mappings":";yCAsBA,IAAIA,EAAyB,kBACzBC,EAA0B,yBA4B9B,SAAqBC,EAAKC,GACzB,IACIC,EACAC,EACAC,EACAC,EACJ,GAAW,IAANJ,EACJ,OAAOD,EAMR,IAHAI,EAAM,EAGAC,EAJAL,EAAIM,OAIM,EAAGD,GAAK,EAAGA,IAAM,CAKhC,GAJAH,EAAMF,EAAKK,GACXD,GAAO,EAGFN,EAAuBS,KAAML,GAAQ,CAEzC,GAAW,IAANG,EAEJ,MAGDF,EAAMH,EAAKK,EAAE,GACRN,EAAwBQ,KAAMJ,KAElCE,GAAK,EAEN,CAED,GAAKD,IAAQH,EACZ,KAED,CACD,OAAOD,EAAIQ,UAAW,EAAGH,EAC1B"} \ No newline at end of file diff --git a/stats_browser.html b/stats_browser.html deleted file mode 100644 index 2c17dcc..0000000 --- a/stats_browser.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - diff --git a/stats_node.html b/stats_node.html deleted file mode 100644 index 1e086d4..0000000 --- a/stats_node.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 272ecc0ac23b0997250ec74bb7b5019c6f0d63a3 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Nov 2024 00:48:31 +0000 Subject: [PATCH 83/92] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 66 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 794 ---- .github/workflows/publish.yml | 252 -- .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .gitignore | 190 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 99 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 52 +- SECURITY.md | 5 - benchmark/benchmark.js | 56 - branches.md | 56 - browser.js | 3 + browser.js.map | 1 + dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 29 - docs/types/index.d.ts | 53 - docs/types/test.ts | 57 - examples/index.js | 33 - index.js | 3 + index.js.map | 1 + lib/index.js | 43 - lib/main.js | 94 - package.json | 53 +- stats_browser.html | 4842 +++++++++++++++++++++ stats_node.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 108 - 46 files changed, 9728 insertions(+), 3926 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md create mode 100644 browser.js create mode 100644 browser.js.map 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/index.d.ts delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js create mode 100644 index.js create mode 100644 index.js.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats_browser.html create mode 100644 stats_node.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 0f977b7..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-11-01T00:42:47.231Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 52cd9c4..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/base/remove-last-code-point) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 533eeee..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/base/remove-last-code-point) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 2a724f2..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: '29 5 * * 0' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index f4575e9..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,794 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n +``` -```javascript -var removeLastCodePoint = require( '@stdlib/string-base-remove-last-code-point' ); +If no recognized module system is present, access bundle contents via the global scope: + +```html + ``` #### removeLastCodePoint( str, n ) @@ -91,8 +97,13 @@ out = removeLastCodePoint( 'foo bar', 10 ); -```javascript -var removeLastCodePoint = require( '@stdlib/string-base-remove-last-code-point' ); +```html + + + + + + + ```
diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index a39bd29..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,56 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var removeLast = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var values; - var out; - var i; - - values = [ - 'beep boop', - 'foo bar', - 'xyz abc', - '🐶🐮🐷🐰🐸' - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = removeLast( values[ i%values.length ], 1 ); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( !isString( out ) ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index f585c99..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/base/remove-last-code-point" -%% click B href "https://github.com/stdlib-js/string-base-remove-last-code-point/tree/main" -%% click C href "https://github.com/stdlib-js/string-base-remove-last-code-point/tree/production" -%% click D href "https://github.com/stdlib-js/string-base-remove-last-code-point/tree/esm" -%% click E href "https://github.com/stdlib-js/string-base-remove-last-code-point/tree/deno" -%% click F href "https://github.com/stdlib-js/string-base-remove-last-code-point/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/base/remove-last-code-point -[production-url]: https://github.com/stdlib-js/string-base-remove-last-code-point/tree/production -[deno-url]: https://github.com/stdlib-js/string-base-remove-last-code-point/tree/deno -[deno-readme]: https://github.com/stdlib-js/string-base-remove-last-code-point/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/string-base-remove-last-code-point/tree/umd -[umd-readme]: https://github.com/stdlib-js/string-base-remove-last-code-point/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/string-base-remove-last-code-point/tree/esm -[esm-readme]: https://github.com/stdlib-js/string-base-remove-last-code-point/blob/esm/README.md \ No newline at end of file diff --git a/browser.js b/browser.js new file mode 100644 index 0000000..f3a511a --- /dev/null +++ b/browser.js @@ -0,0 +1,3 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +var e,t;e=this,t=function(){"use strict";var e=/[\uDC00-\uDFFF]/,t=/[\uD800-\uDBFF]/;return function(n,f){var i,o,r,u;if(0===f)return n;for(r=0,u=n.length-1;u>=0;u--){if(i=n[u],r+=1,e.test(i)){if(0===u)break;o=n[u-1],t.test(o)&&(u-=1)}if(r===f)break}return n.substring(0,u)}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).removeLastCodePoint=t(); +//# sourceMappingURL=browser.js.map diff --git a/browser.js.map b/browser.js.map new file mode 100644 index 0000000..19908eb --- /dev/null +++ b/browser.js.map @@ -0,0 +1 @@ +{"version":3,"file":"browser.js","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\nvar RE_UTF16_LOW_SURROGATE = /[\\uDC00-\\uDFFF]/; // TODO: replace with stdlib pkg\nvar RE_UTF16_HIGH_SURROGATE = /[\\uD800-\\uDBFF]/; // TODO: replace with stdlib pkg\n\n\n// MAIN //\n\n/**\n* Removes the last `n` Unicode code points of a string.\n*\n* @param {string} str - input string\n* @param {NonNegativeInteger} n - number of Unicode code points to remove\n* @returns {string} output string\n*\n* @example\n* var out = removeLast( 'last man standing', 1 );\n* // returns 'last man standin'\n*\n* @example\n* var out = removeLast( 'presidential election', 1 );\n* // returns 'presidential electio'\n*\n* @example\n* var out = removeLast( 'JavaScript', 1 );\n* // returns 'JavaScrip'\n*\n* @example\n* var out = removeLast( 'Hidden Treasures', 1 );\n* // returns 'Hidden Treasure'\n*/\nfunction removeLast( str, n ) {\n\tvar len;\n\tvar ch1;\n\tvar ch2;\n\tvar cnt;\n\tvar i;\n\tif ( n === 0 ) {\n\t\treturn str;\n\t}\n\tlen = str.length;\n\tcnt = 0;\n\n\t// Process the string one Unicode code unit at a time and count UTF-16 surrogate pairs as a single Unicode code point...\n\tfor ( i = len - 1; i >= 0; i-- ) {\n\t\tch1 = str[ i ];\n\t\tcnt += 1;\n\n\t\t// Check for a low UTF-16 surrogate...\n\t\tif ( RE_UTF16_LOW_SURROGATE.test( ch1 ) ) {\n\t\t\t// Check for an unpaired surrogate at the end of the input string...\n\t\t\tif ( i === 0 ) {\n\t\t\t\t// We found an unpaired surrogate...\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\t// Check whether the high surrogate is paired with a low surrogate...\n\t\t\tch2 = str[ i-1 ];\n\t\t\tif ( RE_UTF16_HIGH_SURROGATE.test( ch2 ) ) {\n\t\t\t\t// We found a surrogate pair:\n\t\t\t\ti -= 1; // bump the index to process the next code unit\n\t\t\t}\n\t\t}\n\t\t// Check whether we've found the desired number of code points...\n\t\tif ( cnt === n ) {\n\t\t\tbreak;\n\t\t}\n\t}\n\treturn str.substring( 0, i );\n}\n\n\n// EXPORTS //\n\nexport default removeLast;\n"],"names":["RE_UTF16_LOW_SURROGATE","RE_UTF16_HIGH_SURROGATE","str","n","ch1","ch2","cnt","i","length","test","substring"],"mappings":";yCAsBA,IAAIA,EAAyB,kBACzBC,EAA0B,yBA4B9B,SAAqBC,EAAKC,GACzB,IACIC,EACAC,EACAC,EACAC,EACJ,GAAW,IAANJ,EACJ,OAAOD,EAMR,IAHAI,EAAM,EAGAC,EAJAL,EAAIM,OAIM,EAAGD,GAAK,EAAGA,IAAM,CAKhC,GAJAH,EAAMF,EAAKK,GACXD,GAAO,EAGFN,EAAuBS,KAAML,GAAQ,CAEzC,GAAW,IAANG,EAEJ,MAGDF,EAAMH,EAAKK,EAAE,GACRN,EAAwBQ,KAAMJ,KAElCE,GAAK,EAEN,CAED,GAAKD,IAAQH,EACZ,KAED,CACD,OAAOD,EAAIQ,UAAW,EAAGH,EAC1B"} \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index 8c96fd7..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import removeLast from '../docs/types/index'; -export = removeLast; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index e6b7220..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var s=function(e,t){return function(){return t||e((t={exports:{}}).exports,t),t.exports}};var f=s(function(D,n){ -var F=/[\uDC00-\uDFFF]/,c=/[\uD800-\uDBFF]/;function R(e,t){var i,u,v,a,r;if(t===0)return e;for(i=e.length,a=0,r=i-1;r>=0;r--){if(u=e[r],a+=1,F.test(u)){if(r===0)break;v=e[r-1],c.test(v)&&(r-=1)}if(a===t)break}return e.substring(0,r)}n.exports=R -});var _=f();module.exports=_; -/** @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 72561cf..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\nvar RE_UTF16_LOW_SURROGATE = /[\\uDC00-\\uDFFF]/; // TODO: replace with stdlib pkg\nvar RE_UTF16_HIGH_SURROGATE = /[\\uD800-\\uDBFF]/; // TODO: replace with stdlib pkg\n\n\n// MAIN //\n\n/**\n* Removes the last `n` Unicode code points of a string.\n*\n* @param {string} str - input string\n* @param {NonNegativeInteger} n - number of Unicode code points to remove\n* @returns {string} output string\n*\n* @example\n* var out = removeLast( 'last man standing', 1 );\n* // returns 'last man standin'\n*\n* @example\n* var out = removeLast( 'presidential election', 1 );\n* // returns 'presidential electio'\n*\n* @example\n* var out = removeLast( 'JavaScript', 1 );\n* // returns 'JavaScrip'\n*\n* @example\n* var out = removeLast( 'Hidden Treasures', 1 );\n* // returns 'Hidden Treasure'\n*/\nfunction removeLast( str, n ) {\n\tvar len;\n\tvar ch1;\n\tvar ch2;\n\tvar cnt;\n\tvar i;\n\tif ( n === 0 ) {\n\t\treturn str;\n\t}\n\tlen = str.length;\n\tcnt = 0;\n\n\t// Process the string one Unicode code unit at a time and count UTF-16 surrogate pairs as a single Unicode code point...\n\tfor ( i = len - 1; i >= 0; i-- ) {\n\t\tch1 = str[ i ];\n\t\tcnt += 1;\n\n\t\t// Check for a low UTF-16 surrogate...\n\t\tif ( RE_UTF16_LOW_SURROGATE.test( ch1 ) ) {\n\t\t\t// Check for an unpaired surrogate at the end of the input string...\n\t\t\tif ( i === 0 ) {\n\t\t\t\t// We found an unpaired surrogate...\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\t// Check whether the high surrogate is paired with a low surrogate...\n\t\t\tch2 = str[ i-1 ];\n\t\t\tif ( RE_UTF16_HIGH_SURROGATE.test( ch2 ) ) {\n\t\t\t\t// We found a surrogate pair:\n\t\t\t\ti -= 1; // bump the index to process the next code unit\n\t\t\t}\n\t\t}\n\t\t// Check whether we've found the desired number of code points...\n\t\tif ( cnt === n ) {\n\t\t\tbreak;\n\t\t}\n\t}\n\treturn str.substring( 0, i );\n}\n\n\n// EXPORTS //\n\nmodule.exports = removeLast;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Remove the last `n` Unicode code points of a string.\n*\n* @module @stdlib/string-base-remove-last-code-point\n*\n* @example\n* var removeLast = require( '@stdlib/string-base-remove-last-code-point' );\n*\n* var out = removeLast( 'last man standing', 1 );\n* // returns 'last man standin'\n*\n* out = removeLast( 'Hidden Treasures', 1 );\n* // returns 'Hidden Treasure';\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,EAAyB,kBACzBC,EAA0B,kBA4B9B,SAASC,EAAYC,EAAKC,EAAI,CAC7B,IAAIC,EACAC,EACAC,EACAC,EACAC,EACJ,GAAKL,IAAM,EACV,OAAOD,EAMR,IAJAE,EAAMF,EAAI,OACVK,EAAM,EAGAC,EAAIJ,EAAM,EAAGI,GAAK,EAAGA,IAAM,CAKhC,GAJAH,EAAMH,EAAKM,CAAE,EACbD,GAAO,EAGFR,EAAuB,KAAMM,CAAI,EAAI,CAEzC,GAAKG,IAAM,EAEV,MAGDF,EAAMJ,EAAKM,EAAE,CAAE,EACVR,EAAwB,KAAMM,CAAI,IAEtCE,GAAK,EAEP,CAEA,GAAKD,IAAQJ,EACZ,KAEF,CACA,OAAOD,EAAI,UAAW,EAAGM,CAAE,CAC5B,CAKAV,EAAO,QAAUG,ICxDjB,IAAIQ,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "RE_UTF16_LOW_SURROGATE", "RE_UTF16_HIGH_SURROGATE", "removeLast", "str", "n", "len", "ch1", "ch2", "cnt", "i", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index a08ea55..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,29 +0,0 @@ - -{{alias}}( str, n ) - Removes the last `n` Unicode code points of a string. - - Parameters - ---------- - str: string - Input string. - - n: integer - Number of Unicode code points to remove. - - Returns - ------- - out: string - Output string. - - Examples - -------- - > var out = {{alias}}( 'beep', 1 ) - 'bee' - > out = {{alias}}( 'Boop', 1 ) - 'Boo' - > out = {{alias}}( 'foo bar', 5 ) - 'fo' - - See Also - -------- - diff --git a/docs/types/index.d.ts b/docs/types/index.d.ts deleted file mode 100644 index 8a1c90b..0000000 --- a/docs/types/index.d.ts +++ /dev/null @@ -1,53 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 - -/** -* Removes the last `n` Unicode code points of a string. -* -* @param str - input string -* @param n - number of code points to remove -* @returns output string -* -* @example -* var out = removeLast( 'last man standing', 1 ); -* // returns 'last man standin' -* -* @example -* var out = removeLast( 'presidential election', 1 ); -* // returns 'presidential electio' -* -* @example -* var out = removeLast( 'JavaScript', 1 ); -* // returns 'JavaScrip' -* -* @example -* var out = removeLast( 'Hidden Treasures', 1 ); -* // returns 'Hidden Treasure' -* -* @example -* var out = removeLast( 'foo bar', 5 ); -* // returns 'fo' -*/ -declare function removeLast( str: string, n: number ): string; - - -// EXPORTS // - -export = removeLast; diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index fd426d2..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,57 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 removeLast = require( './index' ); - - -// TESTS // - -// The function returns a string... -{ - removeLast( 'abc', 1 ); // $ExpectType string -} - -// The compiler throws an error if the function is provided a value other than a string... -{ - removeLast( true, 1 ); // $ExpectError - removeLast( false, 1 ); // $ExpectError - removeLast( null, 1 ); // $ExpectError - removeLast( undefined, 1 ); // $ExpectError - removeLast( 5, 1 ); // $ExpectError - removeLast( [], 1 ); // $ExpectError - removeLast( {}, 1 ); // $ExpectError - removeLast( ( x: number ): number => x, 1 ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument that is not a number... -{ - removeLast( 'abc', true ); // $ExpectError - removeLast( 'abc', false ); // $ExpectError - removeLast( 'abc', null ); // $ExpectError - removeLast( 'abc', 'abc' ); // $ExpectError - removeLast( 'abc', [] ); // $ExpectError - removeLast( 'abc', {} ); // $ExpectError - removeLast( 'abc', ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - removeLast(); // $ExpectError - removeLast( 'abc' ); // $ExpectError - removeLast( 'abc', 1, 2 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 085633e..0000000 --- a/examples/index.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var removeLastCodePoint = require( './../lib' ); - -console.log( removeLastCodePoint( 'presidential election', 1 ) ); -// => 'presidential electio' - -console.log( removeLastCodePoint( 'JavaScript', 1 ) ); -// => 'JavaScrip' - -console.log( removeLastCodePoint( 'The Last of the Mohicans', 5 ) ); -// => 'The Last of the Moh' - -console.log( removeLastCodePoint( 'अनुच्छेद', 1 ) ); -// => 'अनुच्छे' diff --git a/index.js b/index.js new file mode 100644 index 0000000..4e500d1 --- /dev/null +++ b/index.js @@ -0,0 +1,3 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +var e,t;e=this,t=function(){"use strict";var e=/[\uDC00-\uDFFF]/,t=/[\uD800-\uDBFF]/;return function(n,f){var i,o,r,u;if(0===f)return n;for(r=0,u=n.length-1;u>=0;u--){if(i=n[u],r+=1,e.test(i)){if(0===u)break;o=n[u-1],t.test(o)&&(u-=1)}if(r===f)break}return n.substring(0,u)}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).removeLastCodePoint=t(); +//# sourceMappingURL=index.js.map diff --git a/index.js.map b/index.js.map new file mode 100644 index 0000000..d557af8 --- /dev/null +++ b/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\nvar RE_UTF16_LOW_SURROGATE = /[\\uDC00-\\uDFFF]/; // TODO: replace with stdlib pkg\nvar RE_UTF16_HIGH_SURROGATE = /[\\uD800-\\uDBFF]/; // TODO: replace with stdlib pkg\n\n\n// MAIN //\n\n/**\n* Removes the last `n` Unicode code points of a string.\n*\n* @param {string} str - input string\n* @param {NonNegativeInteger} n - number of Unicode code points to remove\n* @returns {string} output string\n*\n* @example\n* var out = removeLast( 'last man standing', 1 );\n* // returns 'last man standin'\n*\n* @example\n* var out = removeLast( 'presidential election', 1 );\n* // returns 'presidential electio'\n*\n* @example\n* var out = removeLast( 'JavaScript', 1 );\n* // returns 'JavaScrip'\n*\n* @example\n* var out = removeLast( 'Hidden Treasures', 1 );\n* // returns 'Hidden Treasure'\n*/\nfunction removeLast( str, n ) {\n\tvar len;\n\tvar ch1;\n\tvar ch2;\n\tvar cnt;\n\tvar i;\n\tif ( n === 0 ) {\n\t\treturn str;\n\t}\n\tlen = str.length;\n\tcnt = 0;\n\n\t// Process the string one Unicode code unit at a time and count UTF-16 surrogate pairs as a single Unicode code point...\n\tfor ( i = len - 1; i >= 0; i-- ) {\n\t\tch1 = str[ i ];\n\t\tcnt += 1;\n\n\t\t// Check for a low UTF-16 surrogate...\n\t\tif ( RE_UTF16_LOW_SURROGATE.test( ch1 ) ) {\n\t\t\t// Check for an unpaired surrogate at the end of the input string...\n\t\t\tif ( i === 0 ) {\n\t\t\t\t// We found an unpaired surrogate...\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\t// Check whether the high surrogate is paired with a low surrogate...\n\t\t\tch2 = str[ i-1 ];\n\t\t\tif ( RE_UTF16_HIGH_SURROGATE.test( ch2 ) ) {\n\t\t\t\t// We found a surrogate pair:\n\t\t\t\ti -= 1; // bump the index to process the next code unit\n\t\t\t}\n\t\t}\n\t\t// Check whether we've found the desired number of code points...\n\t\tif ( cnt === n ) {\n\t\t\tbreak;\n\t\t}\n\t}\n\treturn str.substring( 0, i );\n}\n\n\n// EXPORTS //\n\nexport default removeLast;\n"],"names":["RE_UTF16_LOW_SURROGATE","RE_UTF16_HIGH_SURROGATE","str","n","ch1","ch2","cnt","i","length","test","substring"],"mappings":";yCAsBA,IAAIA,EAAyB,kBACzBC,EAA0B,yBA4B9B,SAAqBC,EAAKC,GACzB,IACIC,EACAC,EACAC,EACAC,EACJ,GAAW,IAANJ,EACJ,OAAOD,EAMR,IAHAI,EAAM,EAGAC,EAJAL,EAAIM,OAIM,EAAGD,GAAK,EAAGA,IAAM,CAKhC,GAJAH,EAAMF,EAAKK,GACXD,GAAO,EAGFN,EAAuBS,KAAML,GAAQ,CAEzC,GAAW,IAANG,EAEJ,MAGDF,EAAMH,EAAKK,EAAE,GACRN,EAAwBQ,KAAMJ,KAElCE,GAAK,EAEN,CAED,GAAKD,IAAQH,EACZ,KAED,CACD,OAAOD,EAAIQ,UAAW,EAAGH,EAC1B"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 9860da0..0000000 --- a/lib/index.js +++ /dev/null @@ -1,43 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Remove the last `n` Unicode code points of a string. -* -* @module @stdlib/string-base-remove-last-code-point -* -* @example -* var removeLast = require( '@stdlib/string-base-remove-last-code-point' ); -* -* var out = removeLast( 'last man standing', 1 ); -* // returns 'last man standin' -* -* out = removeLast( 'Hidden Treasures', 1 ); -* // returns 'Hidden Treasure'; -*/ - -// 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 fc34187..0000000 --- a/lib/main.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// VARIABLES // - -var RE_UTF16_LOW_SURROGATE = /[\uDC00-\uDFFF]/; // TODO: replace with stdlib pkg -var RE_UTF16_HIGH_SURROGATE = /[\uD800-\uDBFF]/; // TODO: replace with stdlib pkg - - -// MAIN // - -/** -* Removes the last `n` Unicode code points of a string. -* -* @param {string} str - input string -* @param {NonNegativeInteger} n - number of Unicode code points to remove -* @returns {string} output string -* -* @example -* var out = removeLast( 'last man standing', 1 ); -* // returns 'last man standin' -* -* @example -* var out = removeLast( 'presidential election', 1 ); -* // returns 'presidential electio' -* -* @example -* var out = removeLast( 'JavaScript', 1 ); -* // returns 'JavaScrip' -* -* @example -* var out = removeLast( 'Hidden Treasures', 1 ); -* // returns 'Hidden Treasure' -*/ -function removeLast( str, n ) { - var len; - var ch1; - var ch2; - var cnt; - var i; - if ( n === 0 ) { - return str; - } - len = str.length; - cnt = 0; - - // Process the string one Unicode code unit at a time and count UTF-16 surrogate pairs as a single Unicode code point... - for ( i = len - 1; i >= 0; i-- ) { - ch1 = str[ i ]; - cnt += 1; - - // Check for a low UTF-16 surrogate... - if ( RE_UTF16_LOW_SURROGATE.test( ch1 ) ) { - // Check for an unpaired surrogate at the end of the input string... - if ( i === 0 ) { - // We found an unpaired surrogate... - break; - } - // Check whether the high surrogate is paired with a low surrogate... - ch2 = str[ i-1 ]; - if ( RE_UTF16_HIGH_SURROGATE.test( ch2 ) ) { - // We found a surrogate pair: - i -= 1; // bump the index to process the next code unit - } - } - // Check whether we've found the desired number of code points... - if ( cnt === n ) { - break; - } - } - return str.substring( 0, i ); -} - - -// EXPORTS // - -module.exports = removeLast; diff --git a/package.json b/package.json index 8dd3c53..e1a7e6d 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,7 @@ "version": "0.2.2", "description": "Remove the last Unicode code point of a string.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "main": "./index.js", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,31 +12,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/assert-is-string": "^0.2.2", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdstring", @@ -81,4 +32,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/stats_browser.html b/stats_browser.html new file mode 100644 index 0000000..2c17dcc --- /dev/null +++ b/stats_browser.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/stats_node.html b/stats_node.html new file mode 100644 index 0000000..1e086d4 --- /dev/null +++ b/stats_node.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index a25545e..0000000 --- a/test/test.js +++ /dev/null @@ -1,108 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var removeLast = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof removeLast, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns an empty string if provided an empty string', function test( t ) { - t.strictEqual( removeLast( '', 1 ), '', 'returns expected value' ); - t.strictEqual( removeLast( '', 2 ), '', 'returns expected value' ); - t.strictEqual( removeLast( '', 3 ), '', 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns the input string if provided zero as the second argument', function test( t ) { - t.strictEqual( removeLast( 'hello world', 0 ), 'hello world', 'returns expected value' ); - t.end(); -}); - -tape( 'the function removes the last Unicode code point of a provided string (ascii)', function test( t ) { - var out; - - out = removeLast( 'hello world', 1 ); - t.strictEqual( out, 'hello worl', 'returns expected value' ); - - out = removeLast( '!!!', 1 ); - t.strictEqual( out, '!!', 'returns expected value' ); - - out = removeLast( 'Hello World', 1 ); - t.strictEqual( out, 'Hello Worl', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function removes the last Unicode code point of a provided string (Unicode)', function test( t ) { - var out; - - out = removeLast( 'अनुच्छेद', 1 ); - t.strictEqual( out, 'अनुच्छे', 'returns expected value' ); - - out = removeLast( '六书/六書', 1 ); - t.strictEqual( out, '六书/六', 'returns expected value' ); - - out = removeLast( '𐒻𐓟', 1 ); - t.strictEqual( out, '𐒻', 'returns expected value' ); - - out = removeLast( '𐒻𐓟', 1 ); - t.strictEqual( out, '𐒻', 'returns expected value' ); - - out = removeLast( '\uDC00', 1 ); - t.strictEqual( out, '', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports removing the last `n` Unicode code points of a provided string', function test( t ) { - var out; - - out = removeLast( 'hello world', 1 ); - t.strictEqual( out, 'hello worl', 'returns expected value' ); - - out = removeLast( 'hello world', 7 ); - t.strictEqual( out, 'hell', 'returns expected value' ); - - out = removeLast( '!!!', 1 ); - t.strictEqual( out, '!!', 'returns expected value' ); - - out = removeLast( '!!!', 2 ); - t.strictEqual( out, '!', 'returns expected value' ); - - out = removeLast( 'अनुच्छेद', 1 ); - t.strictEqual( out, 'अनुच्छे', 'returns expected value' ); - - out = removeLast( '六书/六書', 3 ); - t.strictEqual( out, '六书', 'returns expected value' ); - - out = removeLast( '𐒻𐓟𐓟', 2 ); - t.strictEqual( out, '𐒻', 'returns expected value' ); - - t.end(); -}); From 62d3e4d7d6c4e7268c532da0b17e3d2e1e0d5639 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Dec 2024 00:50:04 +0000 Subject: [PATCH 84/92] Transform error messages --- package.json | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index d1c7913..8dd3c53 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,9 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": {}, + "dependencies": { + "@stdlib/error-tools-fmtprodmsg": "^0.2.2" + }, "devDependencies": { "@stdlib/assert-is-string": "^0.2.2", "tape": "git+https://github.com/kgryte/tape.git#fix/globby", @@ -79,4 +81,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 80b0972de93887187247d624b1a2a6bf09a77779 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Dec 2024 00:55:50 +0000 Subject: [PATCH 85/92] Remove files --- browser.js | 3 - browser.js.map | 1 - index.js | 3 - index.js.map | 1 - stats_browser.html | 4842 -------------------------------------------- stats_node.html | 4842 -------------------------------------------- 6 files changed, 9692 deletions(-) delete mode 100644 browser.js delete mode 100644 browser.js.map delete mode 100644 index.js delete mode 100644 index.js.map delete mode 100644 stats_browser.html delete mode 100644 stats_node.html diff --git a/browser.js b/browser.js deleted file mode 100644 index f3a511a..0000000 --- a/browser.js +++ /dev/null @@ -1,3 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -var e,t;e=this,t=function(){"use strict";var e=/[\uDC00-\uDFFF]/,t=/[\uD800-\uDBFF]/;return function(n,f){var i,o,r,u;if(0===f)return n;for(r=0,u=n.length-1;u>=0;u--){if(i=n[u],r+=1,e.test(i)){if(0===u)break;o=n[u-1],t.test(o)&&(u-=1)}if(r===f)break}return n.substring(0,u)}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).removeLastCodePoint=t(); -//# sourceMappingURL=browser.js.map diff --git a/browser.js.map b/browser.js.map deleted file mode 100644 index 19908eb..0000000 --- a/browser.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"browser.js","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\nvar RE_UTF16_LOW_SURROGATE = /[\\uDC00-\\uDFFF]/; // TODO: replace with stdlib pkg\nvar RE_UTF16_HIGH_SURROGATE = /[\\uD800-\\uDBFF]/; // TODO: replace with stdlib pkg\n\n\n// MAIN //\n\n/**\n* Removes the last `n` Unicode code points of a string.\n*\n* @param {string} str - input string\n* @param {NonNegativeInteger} n - number of Unicode code points to remove\n* @returns {string} output string\n*\n* @example\n* var out = removeLast( 'last man standing', 1 );\n* // returns 'last man standin'\n*\n* @example\n* var out = removeLast( 'presidential election', 1 );\n* // returns 'presidential electio'\n*\n* @example\n* var out = removeLast( 'JavaScript', 1 );\n* // returns 'JavaScrip'\n*\n* @example\n* var out = removeLast( 'Hidden Treasures', 1 );\n* // returns 'Hidden Treasure'\n*/\nfunction removeLast( str, n ) {\n\tvar len;\n\tvar ch1;\n\tvar ch2;\n\tvar cnt;\n\tvar i;\n\tif ( n === 0 ) {\n\t\treturn str;\n\t}\n\tlen = str.length;\n\tcnt = 0;\n\n\t// Process the string one Unicode code unit at a time and count UTF-16 surrogate pairs as a single Unicode code point...\n\tfor ( i = len - 1; i >= 0; i-- ) {\n\t\tch1 = str[ i ];\n\t\tcnt += 1;\n\n\t\t// Check for a low UTF-16 surrogate...\n\t\tif ( RE_UTF16_LOW_SURROGATE.test( ch1 ) ) {\n\t\t\t// Check for an unpaired surrogate at the end of the input string...\n\t\t\tif ( i === 0 ) {\n\t\t\t\t// We found an unpaired surrogate...\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\t// Check whether the high surrogate is paired with a low surrogate...\n\t\t\tch2 = str[ i-1 ];\n\t\t\tif ( RE_UTF16_HIGH_SURROGATE.test( ch2 ) ) {\n\t\t\t\t// We found a surrogate pair:\n\t\t\t\ti -= 1; // bump the index to process the next code unit\n\t\t\t}\n\t\t}\n\t\t// Check whether we've found the desired number of code points...\n\t\tif ( cnt === n ) {\n\t\t\tbreak;\n\t\t}\n\t}\n\treturn str.substring( 0, i );\n}\n\n\n// EXPORTS //\n\nexport default removeLast;\n"],"names":["RE_UTF16_LOW_SURROGATE","RE_UTF16_HIGH_SURROGATE","str","n","ch1","ch2","cnt","i","length","test","substring"],"mappings":";yCAsBA,IAAIA,EAAyB,kBACzBC,EAA0B,yBA4B9B,SAAqBC,EAAKC,GACzB,IACIC,EACAC,EACAC,EACAC,EACJ,GAAW,IAANJ,EACJ,OAAOD,EAMR,IAHAI,EAAM,EAGAC,EAJAL,EAAIM,OAIM,EAAGD,GAAK,EAAGA,IAAM,CAKhC,GAJAH,EAAMF,EAAKK,GACXD,GAAO,EAGFN,EAAuBS,KAAML,GAAQ,CAEzC,GAAW,IAANG,EAEJ,MAGDF,EAAMH,EAAKK,EAAE,GACRN,EAAwBQ,KAAMJ,KAElCE,GAAK,EAEN,CAED,GAAKD,IAAQH,EACZ,KAED,CACD,OAAOD,EAAIQ,UAAW,EAAGH,EAC1B"} \ No newline at end of file diff --git a/index.js b/index.js deleted file mode 100644 index 4e500d1..0000000 --- a/index.js +++ /dev/null @@ -1,3 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -var e,t;e=this,t=function(){"use strict";var e=/[\uDC00-\uDFFF]/,t=/[\uD800-\uDBFF]/;return function(n,f){var i,o,r,u;if(0===f)return n;for(r=0,u=n.length-1;u>=0;u--){if(i=n[u],r+=1,e.test(i)){if(0===u)break;o=n[u-1],t.test(o)&&(u-=1)}if(r===f)break}return n.substring(0,u)}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).removeLastCodePoint=t(); -//# sourceMappingURL=index.js.map diff --git a/index.js.map b/index.js.map deleted file mode 100644 index d557af8..0000000 --- a/index.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.js","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\nvar RE_UTF16_LOW_SURROGATE = /[\\uDC00-\\uDFFF]/; // TODO: replace with stdlib pkg\nvar RE_UTF16_HIGH_SURROGATE = /[\\uD800-\\uDBFF]/; // TODO: replace with stdlib pkg\n\n\n// MAIN //\n\n/**\n* Removes the last `n` Unicode code points of a string.\n*\n* @param {string} str - input string\n* @param {NonNegativeInteger} n - number of Unicode code points to remove\n* @returns {string} output string\n*\n* @example\n* var out = removeLast( 'last man standing', 1 );\n* // returns 'last man standin'\n*\n* @example\n* var out = removeLast( 'presidential election', 1 );\n* // returns 'presidential electio'\n*\n* @example\n* var out = removeLast( 'JavaScript', 1 );\n* // returns 'JavaScrip'\n*\n* @example\n* var out = removeLast( 'Hidden Treasures', 1 );\n* // returns 'Hidden Treasure'\n*/\nfunction removeLast( str, n ) {\n\tvar len;\n\tvar ch1;\n\tvar ch2;\n\tvar cnt;\n\tvar i;\n\tif ( n === 0 ) {\n\t\treturn str;\n\t}\n\tlen = str.length;\n\tcnt = 0;\n\n\t// Process the string one Unicode code unit at a time and count UTF-16 surrogate pairs as a single Unicode code point...\n\tfor ( i = len - 1; i >= 0; i-- ) {\n\t\tch1 = str[ i ];\n\t\tcnt += 1;\n\n\t\t// Check for a low UTF-16 surrogate...\n\t\tif ( RE_UTF16_LOW_SURROGATE.test( ch1 ) ) {\n\t\t\t// Check for an unpaired surrogate at the end of the input string...\n\t\t\tif ( i === 0 ) {\n\t\t\t\t// We found an unpaired surrogate...\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\t// Check whether the high surrogate is paired with a low surrogate...\n\t\t\tch2 = str[ i-1 ];\n\t\t\tif ( RE_UTF16_HIGH_SURROGATE.test( ch2 ) ) {\n\t\t\t\t// We found a surrogate pair:\n\t\t\t\ti -= 1; // bump the index to process the next code unit\n\t\t\t}\n\t\t}\n\t\t// Check whether we've found the desired number of code points...\n\t\tif ( cnt === n ) {\n\t\t\tbreak;\n\t\t}\n\t}\n\treturn str.substring( 0, i );\n}\n\n\n// EXPORTS //\n\nexport default removeLast;\n"],"names":["RE_UTF16_LOW_SURROGATE","RE_UTF16_HIGH_SURROGATE","str","n","ch1","ch2","cnt","i","length","test","substring"],"mappings":";yCAsBA,IAAIA,EAAyB,kBACzBC,EAA0B,yBA4B9B,SAAqBC,EAAKC,GACzB,IACIC,EACAC,EACAC,EACAC,EACJ,GAAW,IAANJ,EACJ,OAAOD,EAMR,IAHAI,EAAM,EAGAC,EAJAL,EAAIM,OAIM,EAAGD,GAAK,EAAGA,IAAM,CAKhC,GAJAH,EAAMF,EAAKK,GACXD,GAAO,EAGFN,EAAuBS,KAAML,GAAQ,CAEzC,GAAW,IAANG,EAEJ,MAGDF,EAAMH,EAAKK,EAAE,GACRN,EAAwBQ,KAAMJ,KAElCE,GAAK,EAEN,CAED,GAAKD,IAAQH,EACZ,KAED,CACD,OAAOD,EAAIQ,UAAW,EAAGH,EAC1B"} \ No newline at end of file diff --git a/stats_browser.html b/stats_browser.html deleted file mode 100644 index 2c17dcc..0000000 --- a/stats_browser.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - diff --git a/stats_node.html b/stats_node.html deleted file mode 100644 index 1e086d4..0000000 --- a/stats_node.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From c742a71e18a3f465ac2671886532936451f7485a Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Dec 2024 00:56:09 +0000 Subject: [PATCH 86/92] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 66 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 794 --- .github/workflows/publish.yml | 252 - .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .github/workflows/test_published_package.yml | 105 - .gitignore | 190 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 99 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 52 +- SECURITY.md | 5 - benchmark/benchmark.js | 56 - branches.md | 56 - browser.js | 3 + browser.js.map | 1 + dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 29 - docs/types/index.d.ts | 53 - docs/types/test.ts | 57 - examples/index.js | 33 - index.js | 3 + index.js.map | 1 + lib/index.js | 43 - lib/main.js | 94 - package.json | 53 +- stats_browser.html | 4842 ++++++++++++++++++ stats_node.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 108 - 47 files changed, 9728 insertions(+), 4031 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .github/workflows/test_published_package.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md create mode 100644 browser.js create mode 100644 browser.js.map 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/index.d.ts delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js create mode 100644 index.js create mode 100644 index.js.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats_browser.html create mode 100644 stats_node.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 438b950..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-12-01T00:49:18.848Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 52cd9c4..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/base/remove-last-code-point) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 533eeee..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/base/remove-last-code-point) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 2a724f2..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: '29 5 * * 0' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index f4575e9..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,794 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n +``` -```javascript -var removeLastCodePoint = require( '@stdlib/string-base-remove-last-code-point' ); +If no recognized module system is present, access bundle contents via the global scope: + +```html + ``` #### removeLastCodePoint( str, n ) @@ -91,8 +97,13 @@ out = removeLastCodePoint( 'foo bar', 10 ); -```javascript -var removeLastCodePoint = require( '@stdlib/string-base-remove-last-code-point' ); +```html + + + + + + + ```
diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index a39bd29..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,56 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var removeLast = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var values; - var out; - var i; - - values = [ - 'beep boop', - 'foo bar', - 'xyz abc', - '🐶🐮🐷🐰🐸' - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = removeLast( values[ i%values.length ], 1 ); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( !isString( out ) ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index f585c99..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/base/remove-last-code-point" -%% click B href "https://github.com/stdlib-js/string-base-remove-last-code-point/tree/main" -%% click C href "https://github.com/stdlib-js/string-base-remove-last-code-point/tree/production" -%% click D href "https://github.com/stdlib-js/string-base-remove-last-code-point/tree/esm" -%% click E href "https://github.com/stdlib-js/string-base-remove-last-code-point/tree/deno" -%% click F href "https://github.com/stdlib-js/string-base-remove-last-code-point/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/base/remove-last-code-point -[production-url]: https://github.com/stdlib-js/string-base-remove-last-code-point/tree/production -[deno-url]: https://github.com/stdlib-js/string-base-remove-last-code-point/tree/deno -[deno-readme]: https://github.com/stdlib-js/string-base-remove-last-code-point/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/string-base-remove-last-code-point/tree/umd -[umd-readme]: https://github.com/stdlib-js/string-base-remove-last-code-point/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/string-base-remove-last-code-point/tree/esm -[esm-readme]: https://github.com/stdlib-js/string-base-remove-last-code-point/blob/esm/README.md \ No newline at end of file diff --git a/browser.js b/browser.js new file mode 100644 index 0000000..f3a511a --- /dev/null +++ b/browser.js @@ -0,0 +1,3 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +var e,t;e=this,t=function(){"use strict";var e=/[\uDC00-\uDFFF]/,t=/[\uD800-\uDBFF]/;return function(n,f){var i,o,r,u;if(0===f)return n;for(r=0,u=n.length-1;u>=0;u--){if(i=n[u],r+=1,e.test(i)){if(0===u)break;o=n[u-1],t.test(o)&&(u-=1)}if(r===f)break}return n.substring(0,u)}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).removeLastCodePoint=t(); +//# sourceMappingURL=browser.js.map diff --git a/browser.js.map b/browser.js.map new file mode 100644 index 0000000..19908eb --- /dev/null +++ b/browser.js.map @@ -0,0 +1 @@ +{"version":3,"file":"browser.js","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\nvar RE_UTF16_LOW_SURROGATE = /[\\uDC00-\\uDFFF]/; // TODO: replace with stdlib pkg\nvar RE_UTF16_HIGH_SURROGATE = /[\\uD800-\\uDBFF]/; // TODO: replace with stdlib pkg\n\n\n// MAIN //\n\n/**\n* Removes the last `n` Unicode code points of a string.\n*\n* @param {string} str - input string\n* @param {NonNegativeInteger} n - number of Unicode code points to remove\n* @returns {string} output string\n*\n* @example\n* var out = removeLast( 'last man standing', 1 );\n* // returns 'last man standin'\n*\n* @example\n* var out = removeLast( 'presidential election', 1 );\n* // returns 'presidential electio'\n*\n* @example\n* var out = removeLast( 'JavaScript', 1 );\n* // returns 'JavaScrip'\n*\n* @example\n* var out = removeLast( 'Hidden Treasures', 1 );\n* // returns 'Hidden Treasure'\n*/\nfunction removeLast( str, n ) {\n\tvar len;\n\tvar ch1;\n\tvar ch2;\n\tvar cnt;\n\tvar i;\n\tif ( n === 0 ) {\n\t\treturn str;\n\t}\n\tlen = str.length;\n\tcnt = 0;\n\n\t// Process the string one Unicode code unit at a time and count UTF-16 surrogate pairs as a single Unicode code point...\n\tfor ( i = len - 1; i >= 0; i-- ) {\n\t\tch1 = str[ i ];\n\t\tcnt += 1;\n\n\t\t// Check for a low UTF-16 surrogate...\n\t\tif ( RE_UTF16_LOW_SURROGATE.test( ch1 ) ) {\n\t\t\t// Check for an unpaired surrogate at the end of the input string...\n\t\t\tif ( i === 0 ) {\n\t\t\t\t// We found an unpaired surrogate...\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\t// Check whether the high surrogate is paired with a low surrogate...\n\t\t\tch2 = str[ i-1 ];\n\t\t\tif ( RE_UTF16_HIGH_SURROGATE.test( ch2 ) ) {\n\t\t\t\t// We found a surrogate pair:\n\t\t\t\ti -= 1; // bump the index to process the next code unit\n\t\t\t}\n\t\t}\n\t\t// Check whether we've found the desired number of code points...\n\t\tif ( cnt === n ) {\n\t\t\tbreak;\n\t\t}\n\t}\n\treturn str.substring( 0, i );\n}\n\n\n// EXPORTS //\n\nexport default removeLast;\n"],"names":["RE_UTF16_LOW_SURROGATE","RE_UTF16_HIGH_SURROGATE","str","n","ch1","ch2","cnt","i","length","test","substring"],"mappings":";yCAsBA,IAAIA,EAAyB,kBACzBC,EAA0B,yBA4B9B,SAAqBC,EAAKC,GACzB,IACIC,EACAC,EACAC,EACAC,EACJ,GAAW,IAANJ,EACJ,OAAOD,EAMR,IAHAI,EAAM,EAGAC,EAJAL,EAAIM,OAIM,EAAGD,GAAK,EAAGA,IAAM,CAKhC,GAJAH,EAAMF,EAAKK,GACXD,GAAO,EAGFN,EAAuBS,KAAML,GAAQ,CAEzC,GAAW,IAANG,EAEJ,MAGDF,EAAMH,EAAKK,EAAE,GACRN,EAAwBQ,KAAMJ,KAElCE,GAAK,EAEN,CAED,GAAKD,IAAQH,EACZ,KAED,CACD,OAAOD,EAAIQ,UAAW,EAAGH,EAC1B"} \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index 8c96fd7..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import removeLast from '../docs/types/index'; -export = removeLast; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index e6b7220..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var s=function(e,t){return function(){return t||e((t={exports:{}}).exports,t),t.exports}};var f=s(function(D,n){ -var F=/[\uDC00-\uDFFF]/,c=/[\uD800-\uDBFF]/;function R(e,t){var i,u,v,a,r;if(t===0)return e;for(i=e.length,a=0,r=i-1;r>=0;r--){if(u=e[r],a+=1,F.test(u)){if(r===0)break;v=e[r-1],c.test(v)&&(r-=1)}if(a===t)break}return e.substring(0,r)}n.exports=R -});var _=f();module.exports=_; -/** @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 72561cf..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\nvar RE_UTF16_LOW_SURROGATE = /[\\uDC00-\\uDFFF]/; // TODO: replace with stdlib pkg\nvar RE_UTF16_HIGH_SURROGATE = /[\\uD800-\\uDBFF]/; // TODO: replace with stdlib pkg\n\n\n// MAIN //\n\n/**\n* Removes the last `n` Unicode code points of a string.\n*\n* @param {string} str - input string\n* @param {NonNegativeInteger} n - number of Unicode code points to remove\n* @returns {string} output string\n*\n* @example\n* var out = removeLast( 'last man standing', 1 );\n* // returns 'last man standin'\n*\n* @example\n* var out = removeLast( 'presidential election', 1 );\n* // returns 'presidential electio'\n*\n* @example\n* var out = removeLast( 'JavaScript', 1 );\n* // returns 'JavaScrip'\n*\n* @example\n* var out = removeLast( 'Hidden Treasures', 1 );\n* // returns 'Hidden Treasure'\n*/\nfunction removeLast( str, n ) {\n\tvar len;\n\tvar ch1;\n\tvar ch2;\n\tvar cnt;\n\tvar i;\n\tif ( n === 0 ) {\n\t\treturn str;\n\t}\n\tlen = str.length;\n\tcnt = 0;\n\n\t// Process the string one Unicode code unit at a time and count UTF-16 surrogate pairs as a single Unicode code point...\n\tfor ( i = len - 1; i >= 0; i-- ) {\n\t\tch1 = str[ i ];\n\t\tcnt += 1;\n\n\t\t// Check for a low UTF-16 surrogate...\n\t\tif ( RE_UTF16_LOW_SURROGATE.test( ch1 ) ) {\n\t\t\t// Check for an unpaired surrogate at the end of the input string...\n\t\t\tif ( i === 0 ) {\n\t\t\t\t// We found an unpaired surrogate...\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\t// Check whether the high surrogate is paired with a low surrogate...\n\t\t\tch2 = str[ i-1 ];\n\t\t\tif ( RE_UTF16_HIGH_SURROGATE.test( ch2 ) ) {\n\t\t\t\t// We found a surrogate pair:\n\t\t\t\ti -= 1; // bump the index to process the next code unit\n\t\t\t}\n\t\t}\n\t\t// Check whether we've found the desired number of code points...\n\t\tif ( cnt === n ) {\n\t\t\tbreak;\n\t\t}\n\t}\n\treturn str.substring( 0, i );\n}\n\n\n// EXPORTS //\n\nmodule.exports = removeLast;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Remove the last `n` Unicode code points of a string.\n*\n* @module @stdlib/string-base-remove-last-code-point\n*\n* @example\n* var removeLast = require( '@stdlib/string-base-remove-last-code-point' );\n*\n* var out = removeLast( 'last man standing', 1 );\n* // returns 'last man standin'\n*\n* out = removeLast( 'Hidden Treasures', 1 );\n* // returns 'Hidden Treasure';\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,EAAyB,kBACzBC,EAA0B,kBA4B9B,SAASC,EAAYC,EAAKC,EAAI,CAC7B,IAAIC,EACAC,EACAC,EACAC,EACAC,EACJ,GAAKL,IAAM,EACV,OAAOD,EAMR,IAJAE,EAAMF,EAAI,OACVK,EAAM,EAGAC,EAAIJ,EAAM,EAAGI,GAAK,EAAGA,IAAM,CAKhC,GAJAH,EAAMH,EAAKM,CAAE,EACbD,GAAO,EAGFR,EAAuB,KAAMM,CAAI,EAAI,CAEzC,GAAKG,IAAM,EAEV,MAGDF,EAAMJ,EAAKM,EAAE,CAAE,EACVR,EAAwB,KAAMM,CAAI,IAEtCE,GAAK,EAEP,CAEA,GAAKD,IAAQJ,EACZ,KAEF,CACA,OAAOD,EAAI,UAAW,EAAGM,CAAE,CAC5B,CAKAV,EAAO,QAAUG,ICxDjB,IAAIQ,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "RE_UTF16_LOW_SURROGATE", "RE_UTF16_HIGH_SURROGATE", "removeLast", "str", "n", "len", "ch1", "ch2", "cnt", "i", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index a08ea55..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,29 +0,0 @@ - -{{alias}}( str, n ) - Removes the last `n` Unicode code points of a string. - - Parameters - ---------- - str: string - Input string. - - n: integer - Number of Unicode code points to remove. - - Returns - ------- - out: string - Output string. - - Examples - -------- - > var out = {{alias}}( 'beep', 1 ) - 'bee' - > out = {{alias}}( 'Boop', 1 ) - 'Boo' - > out = {{alias}}( 'foo bar', 5 ) - 'fo' - - See Also - -------- - diff --git a/docs/types/index.d.ts b/docs/types/index.d.ts deleted file mode 100644 index 8a1c90b..0000000 --- a/docs/types/index.d.ts +++ /dev/null @@ -1,53 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 - -/** -* Removes the last `n` Unicode code points of a string. -* -* @param str - input string -* @param n - number of code points to remove -* @returns output string -* -* @example -* var out = removeLast( 'last man standing', 1 ); -* // returns 'last man standin' -* -* @example -* var out = removeLast( 'presidential election', 1 ); -* // returns 'presidential electio' -* -* @example -* var out = removeLast( 'JavaScript', 1 ); -* // returns 'JavaScrip' -* -* @example -* var out = removeLast( 'Hidden Treasures', 1 ); -* // returns 'Hidden Treasure' -* -* @example -* var out = removeLast( 'foo bar', 5 ); -* // returns 'fo' -*/ -declare function removeLast( str: string, n: number ): string; - - -// EXPORTS // - -export = removeLast; diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index fd426d2..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,57 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 removeLast = require( './index' ); - - -// TESTS // - -// The function returns a string... -{ - removeLast( 'abc', 1 ); // $ExpectType string -} - -// The compiler throws an error if the function is provided a value other than a string... -{ - removeLast( true, 1 ); // $ExpectError - removeLast( false, 1 ); // $ExpectError - removeLast( null, 1 ); // $ExpectError - removeLast( undefined, 1 ); // $ExpectError - removeLast( 5, 1 ); // $ExpectError - removeLast( [], 1 ); // $ExpectError - removeLast( {}, 1 ); // $ExpectError - removeLast( ( x: number ): number => x, 1 ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument that is not a number... -{ - removeLast( 'abc', true ); // $ExpectError - removeLast( 'abc', false ); // $ExpectError - removeLast( 'abc', null ); // $ExpectError - removeLast( 'abc', 'abc' ); // $ExpectError - removeLast( 'abc', [] ); // $ExpectError - removeLast( 'abc', {} ); // $ExpectError - removeLast( 'abc', ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - removeLast(); // $ExpectError - removeLast( 'abc' ); // $ExpectError - removeLast( 'abc', 1, 2 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 085633e..0000000 --- a/examples/index.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var removeLastCodePoint = require( './../lib' ); - -console.log( removeLastCodePoint( 'presidential election', 1 ) ); -// => 'presidential electio' - -console.log( removeLastCodePoint( 'JavaScript', 1 ) ); -// => 'JavaScrip' - -console.log( removeLastCodePoint( 'The Last of the Mohicans', 5 ) ); -// => 'The Last of the Moh' - -console.log( removeLastCodePoint( 'अनुच्छेद', 1 ) ); -// => 'अनुच्छे' diff --git a/index.js b/index.js new file mode 100644 index 0000000..4e500d1 --- /dev/null +++ b/index.js @@ -0,0 +1,3 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +var e,t;e=this,t=function(){"use strict";var e=/[\uDC00-\uDFFF]/,t=/[\uD800-\uDBFF]/;return function(n,f){var i,o,r,u;if(0===f)return n;for(r=0,u=n.length-1;u>=0;u--){if(i=n[u],r+=1,e.test(i)){if(0===u)break;o=n[u-1],t.test(o)&&(u-=1)}if(r===f)break}return n.substring(0,u)}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).removeLastCodePoint=t(); +//# sourceMappingURL=index.js.map diff --git a/index.js.map b/index.js.map new file mode 100644 index 0000000..d557af8 --- /dev/null +++ b/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\nvar RE_UTF16_LOW_SURROGATE = /[\\uDC00-\\uDFFF]/; // TODO: replace with stdlib pkg\nvar RE_UTF16_HIGH_SURROGATE = /[\\uD800-\\uDBFF]/; // TODO: replace with stdlib pkg\n\n\n// MAIN //\n\n/**\n* Removes the last `n` Unicode code points of a string.\n*\n* @param {string} str - input string\n* @param {NonNegativeInteger} n - number of Unicode code points to remove\n* @returns {string} output string\n*\n* @example\n* var out = removeLast( 'last man standing', 1 );\n* // returns 'last man standin'\n*\n* @example\n* var out = removeLast( 'presidential election', 1 );\n* // returns 'presidential electio'\n*\n* @example\n* var out = removeLast( 'JavaScript', 1 );\n* // returns 'JavaScrip'\n*\n* @example\n* var out = removeLast( 'Hidden Treasures', 1 );\n* // returns 'Hidden Treasure'\n*/\nfunction removeLast( str, n ) {\n\tvar len;\n\tvar ch1;\n\tvar ch2;\n\tvar cnt;\n\tvar i;\n\tif ( n === 0 ) {\n\t\treturn str;\n\t}\n\tlen = str.length;\n\tcnt = 0;\n\n\t// Process the string one Unicode code unit at a time and count UTF-16 surrogate pairs as a single Unicode code point...\n\tfor ( i = len - 1; i >= 0; i-- ) {\n\t\tch1 = str[ i ];\n\t\tcnt += 1;\n\n\t\t// Check for a low UTF-16 surrogate...\n\t\tif ( RE_UTF16_LOW_SURROGATE.test( ch1 ) ) {\n\t\t\t// Check for an unpaired surrogate at the end of the input string...\n\t\t\tif ( i === 0 ) {\n\t\t\t\t// We found an unpaired surrogate...\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\t// Check whether the high surrogate is paired with a low surrogate...\n\t\t\tch2 = str[ i-1 ];\n\t\t\tif ( RE_UTF16_HIGH_SURROGATE.test( ch2 ) ) {\n\t\t\t\t// We found a surrogate pair:\n\t\t\t\ti -= 1; // bump the index to process the next code unit\n\t\t\t}\n\t\t}\n\t\t// Check whether we've found the desired number of code points...\n\t\tif ( cnt === n ) {\n\t\t\tbreak;\n\t\t}\n\t}\n\treturn str.substring( 0, i );\n}\n\n\n// EXPORTS //\n\nexport default removeLast;\n"],"names":["RE_UTF16_LOW_SURROGATE","RE_UTF16_HIGH_SURROGATE","str","n","ch1","ch2","cnt","i","length","test","substring"],"mappings":";yCAsBA,IAAIA,EAAyB,kBACzBC,EAA0B,yBA4B9B,SAAqBC,EAAKC,GACzB,IACIC,EACAC,EACAC,EACAC,EACJ,GAAW,IAANJ,EACJ,OAAOD,EAMR,IAHAI,EAAM,EAGAC,EAJAL,EAAIM,OAIM,EAAGD,GAAK,EAAGA,IAAM,CAKhC,GAJAH,EAAMF,EAAKK,GACXD,GAAO,EAGFN,EAAuBS,KAAML,GAAQ,CAEzC,GAAW,IAANG,EAEJ,MAGDF,EAAMH,EAAKK,EAAE,GACRN,EAAwBQ,KAAMJ,KAElCE,GAAK,EAEN,CAED,GAAKD,IAAQH,EACZ,KAED,CACD,OAAOD,EAAIQ,UAAW,EAAGH,EAC1B"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 9860da0..0000000 --- a/lib/index.js +++ /dev/null @@ -1,43 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Remove the last `n` Unicode code points of a string. -* -* @module @stdlib/string-base-remove-last-code-point -* -* @example -* var removeLast = require( '@stdlib/string-base-remove-last-code-point' ); -* -* var out = removeLast( 'last man standing', 1 ); -* // returns 'last man standin' -* -* out = removeLast( 'Hidden Treasures', 1 ); -* // returns 'Hidden Treasure'; -*/ - -// 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 fc34187..0000000 --- a/lib/main.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// VARIABLES // - -var RE_UTF16_LOW_SURROGATE = /[\uDC00-\uDFFF]/; // TODO: replace with stdlib pkg -var RE_UTF16_HIGH_SURROGATE = /[\uD800-\uDBFF]/; // TODO: replace with stdlib pkg - - -// MAIN // - -/** -* Removes the last `n` Unicode code points of a string. -* -* @param {string} str - input string -* @param {NonNegativeInteger} n - number of Unicode code points to remove -* @returns {string} output string -* -* @example -* var out = removeLast( 'last man standing', 1 ); -* // returns 'last man standin' -* -* @example -* var out = removeLast( 'presidential election', 1 ); -* // returns 'presidential electio' -* -* @example -* var out = removeLast( 'JavaScript', 1 ); -* // returns 'JavaScrip' -* -* @example -* var out = removeLast( 'Hidden Treasures', 1 ); -* // returns 'Hidden Treasure' -*/ -function removeLast( str, n ) { - var len; - var ch1; - var ch2; - var cnt; - var i; - if ( n === 0 ) { - return str; - } - len = str.length; - cnt = 0; - - // Process the string one Unicode code unit at a time and count UTF-16 surrogate pairs as a single Unicode code point... - for ( i = len - 1; i >= 0; i-- ) { - ch1 = str[ i ]; - cnt += 1; - - // Check for a low UTF-16 surrogate... - if ( RE_UTF16_LOW_SURROGATE.test( ch1 ) ) { - // Check for an unpaired surrogate at the end of the input string... - if ( i === 0 ) { - // We found an unpaired surrogate... - break; - } - // Check whether the high surrogate is paired with a low surrogate... - ch2 = str[ i-1 ]; - if ( RE_UTF16_HIGH_SURROGATE.test( ch2 ) ) { - // We found a surrogate pair: - i -= 1; // bump the index to process the next code unit - } - } - // Check whether we've found the desired number of code points... - if ( cnt === n ) { - break; - } - } - return str.substring( 0, i ); -} - - -// EXPORTS // - -module.exports = removeLast; diff --git a/package.json b/package.json index 8dd3c53..e1a7e6d 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,7 @@ "version": "0.2.2", "description": "Remove the last Unicode code point of a string.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "main": "./index.js", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,31 +12,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/assert-is-string": "^0.2.2", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdstring", @@ -81,4 +32,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/stats_browser.html b/stats_browser.html new file mode 100644 index 0000000..2c17dcc --- /dev/null +++ b/stats_browser.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/stats_node.html b/stats_node.html new file mode 100644 index 0000000..1e086d4 --- /dev/null +++ b/stats_node.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index a25545e..0000000 --- a/test/test.js +++ /dev/null @@ -1,108 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var removeLast = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof removeLast, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns an empty string if provided an empty string', function test( t ) { - t.strictEqual( removeLast( '', 1 ), '', 'returns expected value' ); - t.strictEqual( removeLast( '', 2 ), '', 'returns expected value' ); - t.strictEqual( removeLast( '', 3 ), '', 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns the input string if provided zero as the second argument', function test( t ) { - t.strictEqual( removeLast( 'hello world', 0 ), 'hello world', 'returns expected value' ); - t.end(); -}); - -tape( 'the function removes the last Unicode code point of a provided string (ascii)', function test( t ) { - var out; - - out = removeLast( 'hello world', 1 ); - t.strictEqual( out, 'hello worl', 'returns expected value' ); - - out = removeLast( '!!!', 1 ); - t.strictEqual( out, '!!', 'returns expected value' ); - - out = removeLast( 'Hello World', 1 ); - t.strictEqual( out, 'Hello Worl', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function removes the last Unicode code point of a provided string (Unicode)', function test( t ) { - var out; - - out = removeLast( 'अनुच्छेद', 1 ); - t.strictEqual( out, 'अनुच्छे', 'returns expected value' ); - - out = removeLast( '六书/六書', 1 ); - t.strictEqual( out, '六书/六', 'returns expected value' ); - - out = removeLast( '𐒻𐓟', 1 ); - t.strictEqual( out, '𐒻', 'returns expected value' ); - - out = removeLast( '𐒻𐓟', 1 ); - t.strictEqual( out, '𐒻', 'returns expected value' ); - - out = removeLast( '\uDC00', 1 ); - t.strictEqual( out, '', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports removing the last `n` Unicode code points of a provided string', function test( t ) { - var out; - - out = removeLast( 'hello world', 1 ); - t.strictEqual( out, 'hello worl', 'returns expected value' ); - - out = removeLast( 'hello world', 7 ); - t.strictEqual( out, 'hell', 'returns expected value' ); - - out = removeLast( '!!!', 1 ); - t.strictEqual( out, '!!', 'returns expected value' ); - - out = removeLast( '!!!', 2 ); - t.strictEqual( out, '!', 'returns expected value' ); - - out = removeLast( 'अनुच्छेद', 1 ); - t.strictEqual( out, 'अनुच्छे', 'returns expected value' ); - - out = removeLast( '六书/六書', 3 ); - t.strictEqual( out, '六书', 'returns expected value' ); - - out = removeLast( '𐒻𐓟𐓟', 2 ); - t.strictEqual( out, '𐒻', 'returns expected value' ); - - t.end(); -}); From bd8b57fd4815d8612abd26957d2bfe84f672fd9a Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 8 Dec 2024 01:17:59 +0000 Subject: [PATCH 87/92] Transform error messages --- package.json | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index d1c7913..8dd3c53 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,9 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": {}, + "dependencies": { + "@stdlib/error-tools-fmtprodmsg": "^0.2.2" + }, "devDependencies": { "@stdlib/assert-is-string": "^0.2.2", "tape": "git+https://github.com/kgryte/tape.git#fix/globby", @@ -79,4 +81,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 2da4a55ab47466409c47d51c5d14d87ee96e900b Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 8 Dec 2024 01:25:20 +0000 Subject: [PATCH 88/92] Remove files --- browser.js | 3 - browser.js.map | 1 - index.js | 3 - index.js.map | 1 - stats_browser.html | 4842 -------------------------------------------- stats_node.html | 4842 -------------------------------------------- 6 files changed, 9692 deletions(-) delete mode 100644 browser.js delete mode 100644 browser.js.map delete mode 100644 index.js delete mode 100644 index.js.map delete mode 100644 stats_browser.html delete mode 100644 stats_node.html diff --git a/browser.js b/browser.js deleted file mode 100644 index f3a511a..0000000 --- a/browser.js +++ /dev/null @@ -1,3 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -var e,t;e=this,t=function(){"use strict";var e=/[\uDC00-\uDFFF]/,t=/[\uD800-\uDBFF]/;return function(n,f){var i,o,r,u;if(0===f)return n;for(r=0,u=n.length-1;u>=0;u--){if(i=n[u],r+=1,e.test(i)){if(0===u)break;o=n[u-1],t.test(o)&&(u-=1)}if(r===f)break}return n.substring(0,u)}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).removeLastCodePoint=t(); -//# sourceMappingURL=browser.js.map diff --git a/browser.js.map b/browser.js.map deleted file mode 100644 index 19908eb..0000000 --- a/browser.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"browser.js","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\nvar RE_UTF16_LOW_SURROGATE = /[\\uDC00-\\uDFFF]/; // TODO: replace with stdlib pkg\nvar RE_UTF16_HIGH_SURROGATE = /[\\uD800-\\uDBFF]/; // TODO: replace with stdlib pkg\n\n\n// MAIN //\n\n/**\n* Removes the last `n` Unicode code points of a string.\n*\n* @param {string} str - input string\n* @param {NonNegativeInteger} n - number of Unicode code points to remove\n* @returns {string} output string\n*\n* @example\n* var out = removeLast( 'last man standing', 1 );\n* // returns 'last man standin'\n*\n* @example\n* var out = removeLast( 'presidential election', 1 );\n* // returns 'presidential electio'\n*\n* @example\n* var out = removeLast( 'JavaScript', 1 );\n* // returns 'JavaScrip'\n*\n* @example\n* var out = removeLast( 'Hidden Treasures', 1 );\n* // returns 'Hidden Treasure'\n*/\nfunction removeLast( str, n ) {\n\tvar len;\n\tvar ch1;\n\tvar ch2;\n\tvar cnt;\n\tvar i;\n\tif ( n === 0 ) {\n\t\treturn str;\n\t}\n\tlen = str.length;\n\tcnt = 0;\n\n\t// Process the string one Unicode code unit at a time and count UTF-16 surrogate pairs as a single Unicode code point...\n\tfor ( i = len - 1; i >= 0; i-- ) {\n\t\tch1 = str[ i ];\n\t\tcnt += 1;\n\n\t\t// Check for a low UTF-16 surrogate...\n\t\tif ( RE_UTF16_LOW_SURROGATE.test( ch1 ) ) {\n\t\t\t// Check for an unpaired surrogate at the end of the input string...\n\t\t\tif ( i === 0 ) {\n\t\t\t\t// We found an unpaired surrogate...\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\t// Check whether the high surrogate is paired with a low surrogate...\n\t\t\tch2 = str[ i-1 ];\n\t\t\tif ( RE_UTF16_HIGH_SURROGATE.test( ch2 ) ) {\n\t\t\t\t// We found a surrogate pair:\n\t\t\t\ti -= 1; // bump the index to process the next code unit\n\t\t\t}\n\t\t}\n\t\t// Check whether we've found the desired number of code points...\n\t\tif ( cnt === n ) {\n\t\t\tbreak;\n\t\t}\n\t}\n\treturn str.substring( 0, i );\n}\n\n\n// EXPORTS //\n\nexport default removeLast;\n"],"names":["RE_UTF16_LOW_SURROGATE","RE_UTF16_HIGH_SURROGATE","str","n","ch1","ch2","cnt","i","length","test","substring"],"mappings":";yCAsBA,IAAIA,EAAyB,kBACzBC,EAA0B,yBA4B9B,SAAqBC,EAAKC,GACzB,IACIC,EACAC,EACAC,EACAC,EACJ,GAAW,IAANJ,EACJ,OAAOD,EAMR,IAHAI,EAAM,EAGAC,EAJAL,EAAIM,OAIM,EAAGD,GAAK,EAAGA,IAAM,CAKhC,GAJAH,EAAMF,EAAKK,GACXD,GAAO,EAGFN,EAAuBS,KAAML,GAAQ,CAEzC,GAAW,IAANG,EAEJ,MAGDF,EAAMH,EAAKK,EAAE,GACRN,EAAwBQ,KAAMJ,KAElCE,GAAK,EAEN,CAED,GAAKD,IAAQH,EACZ,KAED,CACD,OAAOD,EAAIQ,UAAW,EAAGH,EAC1B"} \ No newline at end of file diff --git a/index.js b/index.js deleted file mode 100644 index 4e500d1..0000000 --- a/index.js +++ /dev/null @@ -1,3 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -var e,t;e=this,t=function(){"use strict";var e=/[\uDC00-\uDFFF]/,t=/[\uD800-\uDBFF]/;return function(n,f){var i,o,r,u;if(0===f)return n;for(r=0,u=n.length-1;u>=0;u--){if(i=n[u],r+=1,e.test(i)){if(0===u)break;o=n[u-1],t.test(o)&&(u-=1)}if(r===f)break}return n.substring(0,u)}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).removeLastCodePoint=t(); -//# sourceMappingURL=index.js.map diff --git a/index.js.map b/index.js.map deleted file mode 100644 index d557af8..0000000 --- a/index.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.js","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\nvar RE_UTF16_LOW_SURROGATE = /[\\uDC00-\\uDFFF]/; // TODO: replace with stdlib pkg\nvar RE_UTF16_HIGH_SURROGATE = /[\\uD800-\\uDBFF]/; // TODO: replace with stdlib pkg\n\n\n// MAIN //\n\n/**\n* Removes the last `n` Unicode code points of a string.\n*\n* @param {string} str - input string\n* @param {NonNegativeInteger} n - number of Unicode code points to remove\n* @returns {string} output string\n*\n* @example\n* var out = removeLast( 'last man standing', 1 );\n* // returns 'last man standin'\n*\n* @example\n* var out = removeLast( 'presidential election', 1 );\n* // returns 'presidential electio'\n*\n* @example\n* var out = removeLast( 'JavaScript', 1 );\n* // returns 'JavaScrip'\n*\n* @example\n* var out = removeLast( 'Hidden Treasures', 1 );\n* // returns 'Hidden Treasure'\n*/\nfunction removeLast( str, n ) {\n\tvar len;\n\tvar ch1;\n\tvar ch2;\n\tvar cnt;\n\tvar i;\n\tif ( n === 0 ) {\n\t\treturn str;\n\t}\n\tlen = str.length;\n\tcnt = 0;\n\n\t// Process the string one Unicode code unit at a time and count UTF-16 surrogate pairs as a single Unicode code point...\n\tfor ( i = len - 1; i >= 0; i-- ) {\n\t\tch1 = str[ i ];\n\t\tcnt += 1;\n\n\t\t// Check for a low UTF-16 surrogate...\n\t\tif ( RE_UTF16_LOW_SURROGATE.test( ch1 ) ) {\n\t\t\t// Check for an unpaired surrogate at the end of the input string...\n\t\t\tif ( i === 0 ) {\n\t\t\t\t// We found an unpaired surrogate...\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\t// Check whether the high surrogate is paired with a low surrogate...\n\t\t\tch2 = str[ i-1 ];\n\t\t\tif ( RE_UTF16_HIGH_SURROGATE.test( ch2 ) ) {\n\t\t\t\t// We found a surrogate pair:\n\t\t\t\ti -= 1; // bump the index to process the next code unit\n\t\t\t}\n\t\t}\n\t\t// Check whether we've found the desired number of code points...\n\t\tif ( cnt === n ) {\n\t\t\tbreak;\n\t\t}\n\t}\n\treturn str.substring( 0, i );\n}\n\n\n// EXPORTS //\n\nexport default removeLast;\n"],"names":["RE_UTF16_LOW_SURROGATE","RE_UTF16_HIGH_SURROGATE","str","n","ch1","ch2","cnt","i","length","test","substring"],"mappings":";yCAsBA,IAAIA,EAAyB,kBACzBC,EAA0B,yBA4B9B,SAAqBC,EAAKC,GACzB,IACIC,EACAC,EACAC,EACAC,EACJ,GAAW,IAANJ,EACJ,OAAOD,EAMR,IAHAI,EAAM,EAGAC,EAJAL,EAAIM,OAIM,EAAGD,GAAK,EAAGA,IAAM,CAKhC,GAJAH,EAAMF,EAAKK,GACXD,GAAO,EAGFN,EAAuBS,KAAML,GAAQ,CAEzC,GAAW,IAANG,EAEJ,MAGDF,EAAMH,EAAKK,EAAE,GACRN,EAAwBQ,KAAMJ,KAElCE,GAAK,EAEN,CAED,GAAKD,IAAQH,EACZ,KAED,CACD,OAAOD,EAAIQ,UAAW,EAAGH,EAC1B"} \ No newline at end of file diff --git a/stats_browser.html b/stats_browser.html deleted file mode 100644 index 2c17dcc..0000000 --- a/stats_browser.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - diff --git a/stats_node.html b/stats_node.html deleted file mode 100644 index 1e086d4..0000000 --- a/stats_node.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 514b1b404f0fe84990c54e7805ed366b92270826 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 8 Dec 2024 01:25:31 +0000 Subject: [PATCH 89/92] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 66 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 794 --- .github/workflows/publish.yml | 252 - .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .github/workflows/test_published_package.yml | 105 - .gitignore | 190 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 121 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 58 +- SECURITY.md | 5 - benchmark/benchmark.js | 56 - branches.md | 56 - browser.js | 3 + browser.js.map | 1 + dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 29 - docs/types/index.d.ts | 53 - docs/types/test.ts | 57 - examples/index.js | 33 - index.js | 3 + index.js.map | 1 + lib/index.js | 43 - lib/main.js | 94 - package.json | 53 +- stats_browser.html | 4842 ++++++++++++++++++ stats_node.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 108 - 46 files changed, 9731 insertions(+), 4055 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .github/workflows/test_published_package.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md create mode 100644 browser.js create mode 100644 browser.js.map 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/index.d.ts delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js create mode 100644 index.js create mode 100644 index.js.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats_browser.html create mode 100644 stats_node.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 52cd9c4..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/base/remove-last-code-point) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 533eeee..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/base/remove-last-code-point) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 2a724f2..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: '29 5 * * 0' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index f4575e9..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,794 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n +``` -```javascript -var removeLastCodePoint = require( '@stdlib/string-base-remove-last-code-point' ); +If no recognized module system is present, access bundle contents via the global scope: + +```html + ``` #### removeLastCodePoint( str, n ) @@ -91,8 +97,13 @@ out = removeLastCodePoint( 'foo bar', 10 ); -```javascript -var removeLastCodePoint = require( '@stdlib/string-base-remove-last-code-point' ); +```html + + + + + + + ```
@@ -201,11 +217,11 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/string/base/remove-first-code-point]: https://github.com/stdlib-js/string-base-remove-first-code-point +[@stdlib/string/base/remove-first-code-point]: https://github.com/stdlib-js/string-base-remove-first-code-point/tree/umd -[@stdlib/string/base/remove-last-grapheme-cluster]: https://github.com/stdlib-js/string-base-remove-last-grapheme-cluster +[@stdlib/string/base/remove-last-grapheme-cluster]: https://github.com/stdlib-js/string-base-remove-last-grapheme-cluster/tree/umd -[@stdlib/string/base/remove-last]: https://github.com/stdlib-js/string-base-remove-last +[@stdlib/string/base/remove-last]: https://github.com/stdlib-js/string-base-remove-last/tree/umd 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 a39bd29..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,56 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var removeLast = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var values; - var out; - var i; - - values = [ - 'beep boop', - 'foo bar', - 'xyz abc', - '🐶🐮🐷🐰🐸' - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = removeLast( values[ i%values.length ], 1 ); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( !isString( out ) ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index f585c99..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/base/remove-last-code-point" -%% click B href "https://github.com/stdlib-js/string-base-remove-last-code-point/tree/main" -%% click C href "https://github.com/stdlib-js/string-base-remove-last-code-point/tree/production" -%% click D href "https://github.com/stdlib-js/string-base-remove-last-code-point/tree/esm" -%% click E href "https://github.com/stdlib-js/string-base-remove-last-code-point/tree/deno" -%% click F href "https://github.com/stdlib-js/string-base-remove-last-code-point/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/base/remove-last-code-point -[production-url]: https://github.com/stdlib-js/string-base-remove-last-code-point/tree/production -[deno-url]: https://github.com/stdlib-js/string-base-remove-last-code-point/tree/deno -[deno-readme]: https://github.com/stdlib-js/string-base-remove-last-code-point/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/string-base-remove-last-code-point/tree/umd -[umd-readme]: https://github.com/stdlib-js/string-base-remove-last-code-point/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/string-base-remove-last-code-point/tree/esm -[esm-readme]: https://github.com/stdlib-js/string-base-remove-last-code-point/blob/esm/README.md \ No newline at end of file diff --git a/browser.js b/browser.js new file mode 100644 index 0000000..f3a511a --- /dev/null +++ b/browser.js @@ -0,0 +1,3 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +var e,t;e=this,t=function(){"use strict";var e=/[\uDC00-\uDFFF]/,t=/[\uD800-\uDBFF]/;return function(n,f){var i,o,r,u;if(0===f)return n;for(r=0,u=n.length-1;u>=0;u--){if(i=n[u],r+=1,e.test(i)){if(0===u)break;o=n[u-1],t.test(o)&&(u-=1)}if(r===f)break}return n.substring(0,u)}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).removeLastCodePoint=t(); +//# sourceMappingURL=browser.js.map diff --git a/browser.js.map b/browser.js.map new file mode 100644 index 0000000..19908eb --- /dev/null +++ b/browser.js.map @@ -0,0 +1 @@ +{"version":3,"file":"browser.js","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\nvar RE_UTF16_LOW_SURROGATE = /[\\uDC00-\\uDFFF]/; // TODO: replace with stdlib pkg\nvar RE_UTF16_HIGH_SURROGATE = /[\\uD800-\\uDBFF]/; // TODO: replace with stdlib pkg\n\n\n// MAIN //\n\n/**\n* Removes the last `n` Unicode code points of a string.\n*\n* @param {string} str - input string\n* @param {NonNegativeInteger} n - number of Unicode code points to remove\n* @returns {string} output string\n*\n* @example\n* var out = removeLast( 'last man standing', 1 );\n* // returns 'last man standin'\n*\n* @example\n* var out = removeLast( 'presidential election', 1 );\n* // returns 'presidential electio'\n*\n* @example\n* var out = removeLast( 'JavaScript', 1 );\n* // returns 'JavaScrip'\n*\n* @example\n* var out = removeLast( 'Hidden Treasures', 1 );\n* // returns 'Hidden Treasure'\n*/\nfunction removeLast( str, n ) {\n\tvar len;\n\tvar ch1;\n\tvar ch2;\n\tvar cnt;\n\tvar i;\n\tif ( n === 0 ) {\n\t\treturn str;\n\t}\n\tlen = str.length;\n\tcnt = 0;\n\n\t// Process the string one Unicode code unit at a time and count UTF-16 surrogate pairs as a single Unicode code point...\n\tfor ( i = len - 1; i >= 0; i-- ) {\n\t\tch1 = str[ i ];\n\t\tcnt += 1;\n\n\t\t// Check for a low UTF-16 surrogate...\n\t\tif ( RE_UTF16_LOW_SURROGATE.test( ch1 ) ) {\n\t\t\t// Check for an unpaired surrogate at the end of the input string...\n\t\t\tif ( i === 0 ) {\n\t\t\t\t// We found an unpaired surrogate...\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\t// Check whether the high surrogate is paired with a low surrogate...\n\t\t\tch2 = str[ i-1 ];\n\t\t\tif ( RE_UTF16_HIGH_SURROGATE.test( ch2 ) ) {\n\t\t\t\t// We found a surrogate pair:\n\t\t\t\ti -= 1; // bump the index to process the next code unit\n\t\t\t}\n\t\t}\n\t\t// Check whether we've found the desired number of code points...\n\t\tif ( cnt === n ) {\n\t\t\tbreak;\n\t\t}\n\t}\n\treturn str.substring( 0, i );\n}\n\n\n// EXPORTS //\n\nexport default removeLast;\n"],"names":["RE_UTF16_LOW_SURROGATE","RE_UTF16_HIGH_SURROGATE","str","n","ch1","ch2","cnt","i","length","test","substring"],"mappings":";yCAsBA,IAAIA,EAAyB,kBACzBC,EAA0B,yBA4B9B,SAAqBC,EAAKC,GACzB,IACIC,EACAC,EACAC,EACAC,EACJ,GAAW,IAANJ,EACJ,OAAOD,EAMR,IAHAI,EAAM,EAGAC,EAJAL,EAAIM,OAIM,EAAGD,GAAK,EAAGA,IAAM,CAKhC,GAJAH,EAAMF,EAAKK,GACXD,GAAO,EAGFN,EAAuBS,KAAML,GAAQ,CAEzC,GAAW,IAANG,EAEJ,MAGDF,EAAMH,EAAKK,EAAE,GACRN,EAAwBQ,KAAMJ,KAElCE,GAAK,EAEN,CAED,GAAKD,IAAQH,EACZ,KAED,CACD,OAAOD,EAAIQ,UAAW,EAAGH,EAC1B"} \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index 8c96fd7..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import removeLast from '../docs/types/index'; -export = removeLast; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index e6b7220..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var s=function(e,t){return function(){return t||e((t={exports:{}}).exports,t),t.exports}};var f=s(function(D,n){ -var F=/[\uDC00-\uDFFF]/,c=/[\uD800-\uDBFF]/;function R(e,t){var i,u,v,a,r;if(t===0)return e;for(i=e.length,a=0,r=i-1;r>=0;r--){if(u=e[r],a+=1,F.test(u)){if(r===0)break;v=e[r-1],c.test(v)&&(r-=1)}if(a===t)break}return e.substring(0,r)}n.exports=R -});var _=f();module.exports=_; -/** @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 72561cf..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\nvar RE_UTF16_LOW_SURROGATE = /[\\uDC00-\\uDFFF]/; // TODO: replace with stdlib pkg\nvar RE_UTF16_HIGH_SURROGATE = /[\\uD800-\\uDBFF]/; // TODO: replace with stdlib pkg\n\n\n// MAIN //\n\n/**\n* Removes the last `n` Unicode code points of a string.\n*\n* @param {string} str - input string\n* @param {NonNegativeInteger} n - number of Unicode code points to remove\n* @returns {string} output string\n*\n* @example\n* var out = removeLast( 'last man standing', 1 );\n* // returns 'last man standin'\n*\n* @example\n* var out = removeLast( 'presidential election', 1 );\n* // returns 'presidential electio'\n*\n* @example\n* var out = removeLast( 'JavaScript', 1 );\n* // returns 'JavaScrip'\n*\n* @example\n* var out = removeLast( 'Hidden Treasures', 1 );\n* // returns 'Hidden Treasure'\n*/\nfunction removeLast( str, n ) {\n\tvar len;\n\tvar ch1;\n\tvar ch2;\n\tvar cnt;\n\tvar i;\n\tif ( n === 0 ) {\n\t\treturn str;\n\t}\n\tlen = str.length;\n\tcnt = 0;\n\n\t// Process the string one Unicode code unit at a time and count UTF-16 surrogate pairs as a single Unicode code point...\n\tfor ( i = len - 1; i >= 0; i-- ) {\n\t\tch1 = str[ i ];\n\t\tcnt += 1;\n\n\t\t// Check for a low UTF-16 surrogate...\n\t\tif ( RE_UTF16_LOW_SURROGATE.test( ch1 ) ) {\n\t\t\t// Check for an unpaired surrogate at the end of the input string...\n\t\t\tif ( i === 0 ) {\n\t\t\t\t// We found an unpaired surrogate...\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\t// Check whether the high surrogate is paired with a low surrogate...\n\t\t\tch2 = str[ i-1 ];\n\t\t\tif ( RE_UTF16_HIGH_SURROGATE.test( ch2 ) ) {\n\t\t\t\t// We found a surrogate pair:\n\t\t\t\ti -= 1; // bump the index to process the next code unit\n\t\t\t}\n\t\t}\n\t\t// Check whether we've found the desired number of code points...\n\t\tif ( cnt === n ) {\n\t\t\tbreak;\n\t\t}\n\t}\n\treturn str.substring( 0, i );\n}\n\n\n// EXPORTS //\n\nmodule.exports = removeLast;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Remove the last `n` Unicode code points of a string.\n*\n* @module @stdlib/string-base-remove-last-code-point\n*\n* @example\n* var removeLast = require( '@stdlib/string-base-remove-last-code-point' );\n*\n* var out = removeLast( 'last man standing', 1 );\n* // returns 'last man standin'\n*\n* out = removeLast( 'Hidden Treasures', 1 );\n* // returns 'Hidden Treasure';\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,EAAyB,kBACzBC,EAA0B,kBA4B9B,SAASC,EAAYC,EAAKC,EAAI,CAC7B,IAAIC,EACAC,EACAC,EACAC,EACAC,EACJ,GAAKL,IAAM,EACV,OAAOD,EAMR,IAJAE,EAAMF,EAAI,OACVK,EAAM,EAGAC,EAAIJ,EAAM,EAAGI,GAAK,EAAGA,IAAM,CAKhC,GAJAH,EAAMH,EAAKM,CAAE,EACbD,GAAO,EAGFR,EAAuB,KAAMM,CAAI,EAAI,CAEzC,GAAKG,IAAM,EAEV,MAGDF,EAAMJ,EAAKM,EAAE,CAAE,EACVR,EAAwB,KAAMM,CAAI,IAEtCE,GAAK,EAEP,CAEA,GAAKD,IAAQJ,EACZ,KAEF,CACA,OAAOD,EAAI,UAAW,EAAGM,CAAE,CAC5B,CAKAV,EAAO,QAAUG,ICxDjB,IAAIQ,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "RE_UTF16_LOW_SURROGATE", "RE_UTF16_HIGH_SURROGATE", "removeLast", "str", "n", "len", "ch1", "ch2", "cnt", "i", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index a08ea55..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,29 +0,0 @@ - -{{alias}}( str, n ) - Removes the last `n` Unicode code points of a string. - - Parameters - ---------- - str: string - Input string. - - n: integer - Number of Unicode code points to remove. - - Returns - ------- - out: string - Output string. - - Examples - -------- - > var out = {{alias}}( 'beep', 1 ) - 'bee' - > out = {{alias}}( 'Boop', 1 ) - 'Boo' - > out = {{alias}}( 'foo bar', 5 ) - 'fo' - - See Also - -------- - diff --git a/docs/types/index.d.ts b/docs/types/index.d.ts deleted file mode 100644 index 8a1c90b..0000000 --- a/docs/types/index.d.ts +++ /dev/null @@ -1,53 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 - -/** -* Removes the last `n` Unicode code points of a string. -* -* @param str - input string -* @param n - number of code points to remove -* @returns output string -* -* @example -* var out = removeLast( 'last man standing', 1 ); -* // returns 'last man standin' -* -* @example -* var out = removeLast( 'presidential election', 1 ); -* // returns 'presidential electio' -* -* @example -* var out = removeLast( 'JavaScript', 1 ); -* // returns 'JavaScrip' -* -* @example -* var out = removeLast( 'Hidden Treasures', 1 ); -* // returns 'Hidden Treasure' -* -* @example -* var out = removeLast( 'foo bar', 5 ); -* // returns 'fo' -*/ -declare function removeLast( str: string, n: number ): string; - - -// EXPORTS // - -export = removeLast; diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index fd426d2..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,57 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 removeLast = require( './index' ); - - -// TESTS // - -// The function returns a string... -{ - removeLast( 'abc', 1 ); // $ExpectType string -} - -// The compiler throws an error if the function is provided a value other than a string... -{ - removeLast( true, 1 ); // $ExpectError - removeLast( false, 1 ); // $ExpectError - removeLast( null, 1 ); // $ExpectError - removeLast( undefined, 1 ); // $ExpectError - removeLast( 5, 1 ); // $ExpectError - removeLast( [], 1 ); // $ExpectError - removeLast( {}, 1 ); // $ExpectError - removeLast( ( x: number ): number => x, 1 ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument that is not a number... -{ - removeLast( 'abc', true ); // $ExpectError - removeLast( 'abc', false ); // $ExpectError - removeLast( 'abc', null ); // $ExpectError - removeLast( 'abc', 'abc' ); // $ExpectError - removeLast( 'abc', [] ); // $ExpectError - removeLast( 'abc', {} ); // $ExpectError - removeLast( 'abc', ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - removeLast(); // $ExpectError - removeLast( 'abc' ); // $ExpectError - removeLast( 'abc', 1, 2 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 085633e..0000000 --- a/examples/index.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var removeLastCodePoint = require( './../lib' ); - -console.log( removeLastCodePoint( 'presidential election', 1 ) ); -// => 'presidential electio' - -console.log( removeLastCodePoint( 'JavaScript', 1 ) ); -// => 'JavaScrip' - -console.log( removeLastCodePoint( 'The Last of the Mohicans', 5 ) ); -// => 'The Last of the Moh' - -console.log( removeLastCodePoint( 'अनुच्छेद', 1 ) ); -// => 'अनुच्छे' diff --git a/index.js b/index.js new file mode 100644 index 0000000..4e500d1 --- /dev/null +++ b/index.js @@ -0,0 +1,3 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +var e,t;e=this,t=function(){"use strict";var e=/[\uDC00-\uDFFF]/,t=/[\uD800-\uDBFF]/;return function(n,f){var i,o,r,u;if(0===f)return n;for(r=0,u=n.length-1;u>=0;u--){if(i=n[u],r+=1,e.test(i)){if(0===u)break;o=n[u-1],t.test(o)&&(u-=1)}if(r===f)break}return n.substring(0,u)}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).removeLastCodePoint=t(); +//# sourceMappingURL=index.js.map diff --git a/index.js.map b/index.js.map new file mode 100644 index 0000000..d557af8 --- /dev/null +++ b/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\nvar RE_UTF16_LOW_SURROGATE = /[\\uDC00-\\uDFFF]/; // TODO: replace with stdlib pkg\nvar RE_UTF16_HIGH_SURROGATE = /[\\uD800-\\uDBFF]/; // TODO: replace with stdlib pkg\n\n\n// MAIN //\n\n/**\n* Removes the last `n` Unicode code points of a string.\n*\n* @param {string} str - input string\n* @param {NonNegativeInteger} n - number of Unicode code points to remove\n* @returns {string} output string\n*\n* @example\n* var out = removeLast( 'last man standing', 1 );\n* // returns 'last man standin'\n*\n* @example\n* var out = removeLast( 'presidential election', 1 );\n* // returns 'presidential electio'\n*\n* @example\n* var out = removeLast( 'JavaScript', 1 );\n* // returns 'JavaScrip'\n*\n* @example\n* var out = removeLast( 'Hidden Treasures', 1 );\n* // returns 'Hidden Treasure'\n*/\nfunction removeLast( str, n ) {\n\tvar len;\n\tvar ch1;\n\tvar ch2;\n\tvar cnt;\n\tvar i;\n\tif ( n === 0 ) {\n\t\treturn str;\n\t}\n\tlen = str.length;\n\tcnt = 0;\n\n\t// Process the string one Unicode code unit at a time and count UTF-16 surrogate pairs as a single Unicode code point...\n\tfor ( i = len - 1; i >= 0; i-- ) {\n\t\tch1 = str[ i ];\n\t\tcnt += 1;\n\n\t\t// Check for a low UTF-16 surrogate...\n\t\tif ( RE_UTF16_LOW_SURROGATE.test( ch1 ) ) {\n\t\t\t// Check for an unpaired surrogate at the end of the input string...\n\t\t\tif ( i === 0 ) {\n\t\t\t\t// We found an unpaired surrogate...\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\t// Check whether the high surrogate is paired with a low surrogate...\n\t\t\tch2 = str[ i-1 ];\n\t\t\tif ( RE_UTF16_HIGH_SURROGATE.test( ch2 ) ) {\n\t\t\t\t// We found a surrogate pair:\n\t\t\t\ti -= 1; // bump the index to process the next code unit\n\t\t\t}\n\t\t}\n\t\t// Check whether we've found the desired number of code points...\n\t\tif ( cnt === n ) {\n\t\t\tbreak;\n\t\t}\n\t}\n\treturn str.substring( 0, i );\n}\n\n\n// EXPORTS //\n\nexport default removeLast;\n"],"names":["RE_UTF16_LOW_SURROGATE","RE_UTF16_HIGH_SURROGATE","str","n","ch1","ch2","cnt","i","length","test","substring"],"mappings":";yCAsBA,IAAIA,EAAyB,kBACzBC,EAA0B,yBA4B9B,SAAqBC,EAAKC,GACzB,IACIC,EACAC,EACAC,EACAC,EACJ,GAAW,IAANJ,EACJ,OAAOD,EAMR,IAHAI,EAAM,EAGAC,EAJAL,EAAIM,OAIM,EAAGD,GAAK,EAAGA,IAAM,CAKhC,GAJAH,EAAMF,EAAKK,GACXD,GAAO,EAGFN,EAAuBS,KAAML,GAAQ,CAEzC,GAAW,IAANG,EAEJ,MAGDF,EAAMH,EAAKK,EAAE,GACRN,EAAwBQ,KAAMJ,KAElCE,GAAK,EAEN,CAED,GAAKD,IAAQH,EACZ,KAED,CACD,OAAOD,EAAIQ,UAAW,EAAGH,EAC1B"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 9860da0..0000000 --- a/lib/index.js +++ /dev/null @@ -1,43 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Remove the last `n` Unicode code points of a string. -* -* @module @stdlib/string-base-remove-last-code-point -* -* @example -* var removeLast = require( '@stdlib/string-base-remove-last-code-point' ); -* -* var out = removeLast( 'last man standing', 1 ); -* // returns 'last man standin' -* -* out = removeLast( 'Hidden Treasures', 1 ); -* // returns 'Hidden Treasure'; -*/ - -// 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 fc34187..0000000 --- a/lib/main.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// VARIABLES // - -var RE_UTF16_LOW_SURROGATE = /[\uDC00-\uDFFF]/; // TODO: replace with stdlib pkg -var RE_UTF16_HIGH_SURROGATE = /[\uD800-\uDBFF]/; // TODO: replace with stdlib pkg - - -// MAIN // - -/** -* Removes the last `n` Unicode code points of a string. -* -* @param {string} str - input string -* @param {NonNegativeInteger} n - number of Unicode code points to remove -* @returns {string} output string -* -* @example -* var out = removeLast( 'last man standing', 1 ); -* // returns 'last man standin' -* -* @example -* var out = removeLast( 'presidential election', 1 ); -* // returns 'presidential electio' -* -* @example -* var out = removeLast( 'JavaScript', 1 ); -* // returns 'JavaScrip' -* -* @example -* var out = removeLast( 'Hidden Treasures', 1 ); -* // returns 'Hidden Treasure' -*/ -function removeLast( str, n ) { - var len; - var ch1; - var ch2; - var cnt; - var i; - if ( n === 0 ) { - return str; - } - len = str.length; - cnt = 0; - - // Process the string one Unicode code unit at a time and count UTF-16 surrogate pairs as a single Unicode code point... - for ( i = len - 1; i >= 0; i-- ) { - ch1 = str[ i ]; - cnt += 1; - - // Check for a low UTF-16 surrogate... - if ( RE_UTF16_LOW_SURROGATE.test( ch1 ) ) { - // Check for an unpaired surrogate at the end of the input string... - if ( i === 0 ) { - // We found an unpaired surrogate... - break; - } - // Check whether the high surrogate is paired with a low surrogate... - ch2 = str[ i-1 ]; - if ( RE_UTF16_HIGH_SURROGATE.test( ch2 ) ) { - // We found a surrogate pair: - i -= 1; // bump the index to process the next code unit - } - } - // Check whether we've found the desired number of code points... - if ( cnt === n ) { - break; - } - } - return str.substring( 0, i ); -} - - -// EXPORTS // - -module.exports = removeLast; diff --git a/package.json b/package.json index 8dd3c53..e1a7e6d 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,7 @@ "version": "0.2.2", "description": "Remove the last Unicode code point of a string.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "main": "./index.js", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,31 +12,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/assert-is-string": "^0.2.2", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdstring", @@ -81,4 +32,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/stats_browser.html b/stats_browser.html new file mode 100644 index 0000000..2c17dcc --- /dev/null +++ b/stats_browser.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/stats_node.html b/stats_node.html new file mode 100644 index 0000000..1e086d4 --- /dev/null +++ b/stats_node.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index a25545e..0000000 --- a/test/test.js +++ /dev/null @@ -1,108 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var removeLast = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof removeLast, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns an empty string if provided an empty string', function test( t ) { - t.strictEqual( removeLast( '', 1 ), '', 'returns expected value' ); - t.strictEqual( removeLast( '', 2 ), '', 'returns expected value' ); - t.strictEqual( removeLast( '', 3 ), '', 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns the input string if provided zero as the second argument', function test( t ) { - t.strictEqual( removeLast( 'hello world', 0 ), 'hello world', 'returns expected value' ); - t.end(); -}); - -tape( 'the function removes the last Unicode code point of a provided string (ascii)', function test( t ) { - var out; - - out = removeLast( 'hello world', 1 ); - t.strictEqual( out, 'hello worl', 'returns expected value' ); - - out = removeLast( '!!!', 1 ); - t.strictEqual( out, '!!', 'returns expected value' ); - - out = removeLast( 'Hello World', 1 ); - t.strictEqual( out, 'Hello Worl', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function removes the last Unicode code point of a provided string (Unicode)', function test( t ) { - var out; - - out = removeLast( 'अनुच्छेद', 1 ); - t.strictEqual( out, 'अनुच्छे', 'returns expected value' ); - - out = removeLast( '六书/六書', 1 ); - t.strictEqual( out, '六书/六', 'returns expected value' ); - - out = removeLast( '𐒻𐓟', 1 ); - t.strictEqual( out, '𐒻', 'returns expected value' ); - - out = removeLast( '𐒻𐓟', 1 ); - t.strictEqual( out, '𐒻', 'returns expected value' ); - - out = removeLast( '\uDC00', 1 ); - t.strictEqual( out, '', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports removing the last `n` Unicode code points of a provided string', function test( t ) { - var out; - - out = removeLast( 'hello world', 1 ); - t.strictEqual( out, 'hello worl', 'returns expected value' ); - - out = removeLast( 'hello world', 7 ); - t.strictEqual( out, 'hell', 'returns expected value' ); - - out = removeLast( '!!!', 1 ); - t.strictEqual( out, '!!', 'returns expected value' ); - - out = removeLast( '!!!', 2 ); - t.strictEqual( out, '!', 'returns expected value' ); - - out = removeLast( 'अनुच्छेद', 1 ); - t.strictEqual( out, 'अनुच्छे', 'returns expected value' ); - - out = removeLast( '六书/六書', 3 ); - t.strictEqual( out, '六书', 'returns expected value' ); - - out = removeLast( '𐒻𐓟𐓟', 2 ); - t.strictEqual( out, '𐒻', 'returns expected value' ); - - t.end(); -}); From 318327d0b125cac4396734c86573dc8650574b87 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 10 Feb 2025 00:42:33 +0000 Subject: [PATCH 90/92] Transform error messages --- package.json | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index d1c7913..8dd3c53 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,9 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": {}, + "dependencies": { + "@stdlib/error-tools-fmtprodmsg": "^0.2.2" + }, "devDependencies": { "@stdlib/assert-is-string": "^0.2.2", "tape": "git+https://github.com/kgryte/tape.git#fix/globby", @@ -79,4 +81,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 75b0057887b7672e2aed70373a7d6babd221b5c7 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 10 Feb 2025 00:50:26 +0000 Subject: [PATCH 91/92] Remove files --- browser.js | 3 - browser.js.map | 1 - index.js | 3 - index.js.map | 1 - stats_browser.html | 4842 -------------------------------------------- stats_node.html | 4842 -------------------------------------------- 6 files changed, 9692 deletions(-) delete mode 100644 browser.js delete mode 100644 browser.js.map delete mode 100644 index.js delete mode 100644 index.js.map delete mode 100644 stats_browser.html delete mode 100644 stats_node.html diff --git a/browser.js b/browser.js deleted file mode 100644 index f3a511a..0000000 --- a/browser.js +++ /dev/null @@ -1,3 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -var e,t;e=this,t=function(){"use strict";var e=/[\uDC00-\uDFFF]/,t=/[\uD800-\uDBFF]/;return function(n,f){var i,o,r,u;if(0===f)return n;for(r=0,u=n.length-1;u>=0;u--){if(i=n[u],r+=1,e.test(i)){if(0===u)break;o=n[u-1],t.test(o)&&(u-=1)}if(r===f)break}return n.substring(0,u)}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).removeLastCodePoint=t(); -//# sourceMappingURL=browser.js.map diff --git a/browser.js.map b/browser.js.map deleted file mode 100644 index 19908eb..0000000 --- a/browser.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"browser.js","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\nvar RE_UTF16_LOW_SURROGATE = /[\\uDC00-\\uDFFF]/; // TODO: replace with stdlib pkg\nvar RE_UTF16_HIGH_SURROGATE = /[\\uD800-\\uDBFF]/; // TODO: replace with stdlib pkg\n\n\n// MAIN //\n\n/**\n* Removes the last `n` Unicode code points of a string.\n*\n* @param {string} str - input string\n* @param {NonNegativeInteger} n - number of Unicode code points to remove\n* @returns {string} output string\n*\n* @example\n* var out = removeLast( 'last man standing', 1 );\n* // returns 'last man standin'\n*\n* @example\n* var out = removeLast( 'presidential election', 1 );\n* // returns 'presidential electio'\n*\n* @example\n* var out = removeLast( 'JavaScript', 1 );\n* // returns 'JavaScrip'\n*\n* @example\n* var out = removeLast( 'Hidden Treasures', 1 );\n* // returns 'Hidden Treasure'\n*/\nfunction removeLast( str, n ) {\n\tvar len;\n\tvar ch1;\n\tvar ch2;\n\tvar cnt;\n\tvar i;\n\tif ( n === 0 ) {\n\t\treturn str;\n\t}\n\tlen = str.length;\n\tcnt = 0;\n\n\t// Process the string one Unicode code unit at a time and count UTF-16 surrogate pairs as a single Unicode code point...\n\tfor ( i = len - 1; i >= 0; i-- ) {\n\t\tch1 = str[ i ];\n\t\tcnt += 1;\n\n\t\t// Check for a low UTF-16 surrogate...\n\t\tif ( RE_UTF16_LOW_SURROGATE.test( ch1 ) ) {\n\t\t\t// Check for an unpaired surrogate at the end of the input string...\n\t\t\tif ( i === 0 ) {\n\t\t\t\t// We found an unpaired surrogate...\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\t// Check whether the high surrogate is paired with a low surrogate...\n\t\t\tch2 = str[ i-1 ];\n\t\t\tif ( RE_UTF16_HIGH_SURROGATE.test( ch2 ) ) {\n\t\t\t\t// We found a surrogate pair:\n\t\t\t\ti -= 1; // bump the index to process the next code unit\n\t\t\t}\n\t\t}\n\t\t// Check whether we've found the desired number of code points...\n\t\tif ( cnt === n ) {\n\t\t\tbreak;\n\t\t}\n\t}\n\treturn str.substring( 0, i );\n}\n\n\n// EXPORTS //\n\nexport default removeLast;\n"],"names":["RE_UTF16_LOW_SURROGATE","RE_UTF16_HIGH_SURROGATE","str","n","ch1","ch2","cnt","i","length","test","substring"],"mappings":";yCAsBA,IAAIA,EAAyB,kBACzBC,EAA0B,yBA4B9B,SAAqBC,EAAKC,GACzB,IACIC,EACAC,EACAC,EACAC,EACJ,GAAW,IAANJ,EACJ,OAAOD,EAMR,IAHAI,EAAM,EAGAC,EAJAL,EAAIM,OAIM,EAAGD,GAAK,EAAGA,IAAM,CAKhC,GAJAH,EAAMF,EAAKK,GACXD,GAAO,EAGFN,EAAuBS,KAAML,GAAQ,CAEzC,GAAW,IAANG,EAEJ,MAGDF,EAAMH,EAAKK,EAAE,GACRN,EAAwBQ,KAAMJ,KAElCE,GAAK,EAEN,CAED,GAAKD,IAAQH,EACZ,KAED,CACD,OAAOD,EAAIQ,UAAW,EAAGH,EAC1B"} \ No newline at end of file diff --git a/index.js b/index.js deleted file mode 100644 index 4e500d1..0000000 --- a/index.js +++ /dev/null @@ -1,3 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -var e,t;e=this,t=function(){"use strict";var e=/[\uDC00-\uDFFF]/,t=/[\uD800-\uDBFF]/;return function(n,f){var i,o,r,u;if(0===f)return n;for(r=0,u=n.length-1;u>=0;u--){if(i=n[u],r+=1,e.test(i)){if(0===u)break;o=n[u-1],t.test(o)&&(u-=1)}if(r===f)break}return n.substring(0,u)}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).removeLastCodePoint=t(); -//# sourceMappingURL=index.js.map diff --git a/index.js.map b/index.js.map deleted file mode 100644 index d557af8..0000000 --- a/index.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.js","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\nvar RE_UTF16_LOW_SURROGATE = /[\\uDC00-\\uDFFF]/; // TODO: replace with stdlib pkg\nvar RE_UTF16_HIGH_SURROGATE = /[\\uD800-\\uDBFF]/; // TODO: replace with stdlib pkg\n\n\n// MAIN //\n\n/**\n* Removes the last `n` Unicode code points of a string.\n*\n* @param {string} str - input string\n* @param {NonNegativeInteger} n - number of Unicode code points to remove\n* @returns {string} output string\n*\n* @example\n* var out = removeLast( 'last man standing', 1 );\n* // returns 'last man standin'\n*\n* @example\n* var out = removeLast( 'presidential election', 1 );\n* // returns 'presidential electio'\n*\n* @example\n* var out = removeLast( 'JavaScript', 1 );\n* // returns 'JavaScrip'\n*\n* @example\n* var out = removeLast( 'Hidden Treasures', 1 );\n* // returns 'Hidden Treasure'\n*/\nfunction removeLast( str, n ) {\n\tvar len;\n\tvar ch1;\n\tvar ch2;\n\tvar cnt;\n\tvar i;\n\tif ( n === 0 ) {\n\t\treturn str;\n\t}\n\tlen = str.length;\n\tcnt = 0;\n\n\t// Process the string one Unicode code unit at a time and count UTF-16 surrogate pairs as a single Unicode code point...\n\tfor ( i = len - 1; i >= 0; i-- ) {\n\t\tch1 = str[ i ];\n\t\tcnt += 1;\n\n\t\t// Check for a low UTF-16 surrogate...\n\t\tif ( RE_UTF16_LOW_SURROGATE.test( ch1 ) ) {\n\t\t\t// Check for an unpaired surrogate at the end of the input string...\n\t\t\tif ( i === 0 ) {\n\t\t\t\t// We found an unpaired surrogate...\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\t// Check whether the high surrogate is paired with a low surrogate...\n\t\t\tch2 = str[ i-1 ];\n\t\t\tif ( RE_UTF16_HIGH_SURROGATE.test( ch2 ) ) {\n\t\t\t\t// We found a surrogate pair:\n\t\t\t\ti -= 1; // bump the index to process the next code unit\n\t\t\t}\n\t\t}\n\t\t// Check whether we've found the desired number of code points...\n\t\tif ( cnt === n ) {\n\t\t\tbreak;\n\t\t}\n\t}\n\treturn str.substring( 0, i );\n}\n\n\n// EXPORTS //\n\nexport default removeLast;\n"],"names":["RE_UTF16_LOW_SURROGATE","RE_UTF16_HIGH_SURROGATE","str","n","ch1","ch2","cnt","i","length","test","substring"],"mappings":";yCAsBA,IAAIA,EAAyB,kBACzBC,EAA0B,yBA4B9B,SAAqBC,EAAKC,GACzB,IACIC,EACAC,EACAC,EACAC,EACJ,GAAW,IAANJ,EACJ,OAAOD,EAMR,IAHAI,EAAM,EAGAC,EAJAL,EAAIM,OAIM,EAAGD,GAAK,EAAGA,IAAM,CAKhC,GAJAH,EAAMF,EAAKK,GACXD,GAAO,EAGFN,EAAuBS,KAAML,GAAQ,CAEzC,GAAW,IAANG,EAEJ,MAGDF,EAAMH,EAAKK,EAAE,GACRN,EAAwBQ,KAAMJ,KAElCE,GAAK,EAEN,CAED,GAAKD,IAAQH,EACZ,KAED,CACD,OAAOD,EAAIQ,UAAW,EAAGH,EAC1B"} \ No newline at end of file diff --git a/stats_browser.html b/stats_browser.html deleted file mode 100644 index 2c17dcc..0000000 --- a/stats_browser.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - diff --git a/stats_node.html b/stats_node.html deleted file mode 100644 index 1e086d4..0000000 --- a/stats_node.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 6159247fd9aa408383b5d8fb0626b6506070e498 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 10 Feb 2025 00:50:37 +0000 Subject: [PATCH 92/92] Auto-generated commit --- .editorconfig | 180 - .eslintrc.js | 1 - .gitattributes | 66 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 794 --- .github/workflows/publish.yml | 252 - .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .github/workflows/test_published_package.yml | 105 - .gitignore | 190 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 121 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 58 +- SECURITY.md | 5 - benchmark/benchmark.js | 56 - branches.md | 56 - browser.js | 3 + browser.js.map | 1 + dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 29 - docs/types/index.d.ts | 53 - docs/types/test.ts | 57 - examples/index.js | 33 - index.js | 3 + index.js.map | 1 + lib/index.js | 43 - lib/main.js | 94 - package.json | 53 +- stats_browser.html | 4842 ++++++++++++++++++ stats_node.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 108 - 47 files changed, 9731 insertions(+), 4055 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .github/workflows/test_published_package.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md create mode 100644 browser.js create mode 100644 browser.js.map 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/index.d.ts delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js create mode 100644 index.js create mode 100644 index.js.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats_browser.html create mode 100644 stats_node.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index dab5d2a..0000000 --- a/.editorconfig +++ /dev/null @@ -1,180 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true # Note: this disables using two spaces to force a hard line break, which is permitted in Markdown. As we don't typically follow that practice (TMK), we should be safe to automatically trim. - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 991d179..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2025-02-10T00:39:04.834Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 52cd9c4..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/base/remove-last-code-point) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 533eeee..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/base/remove-last-code-point) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 2a724f2..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: '29 5 * * 0' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index f4575e9..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,794 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n +``` -```javascript -var removeLastCodePoint = require( '@stdlib/string-base-remove-last-code-point' ); +If no recognized module system is present, access bundle contents via the global scope: + +```html + ``` #### removeLastCodePoint( str, n ) @@ -91,8 +97,13 @@ out = removeLastCodePoint( 'foo bar', 10 ); -```javascript -var removeLastCodePoint = require( '@stdlib/string-base-remove-last-code-point' ); +```html + + + + + + + ```
@@ -201,11 +217,11 @@ Copyright © 2016-2025. The Stdlib [Authors][stdlib-authors]. -[@stdlib/string/base/remove-first-code-point]: https://github.com/stdlib-js/string-base-remove-first-code-point +[@stdlib/string/base/remove-first-code-point]: https://github.com/stdlib-js/string-base-remove-first-code-point/tree/umd -[@stdlib/string/base/remove-last-grapheme-cluster]: https://github.com/stdlib-js/string-base-remove-last-grapheme-cluster +[@stdlib/string/base/remove-last-grapheme-cluster]: https://github.com/stdlib-js/string-base-remove-last-grapheme-cluster/tree/umd -[@stdlib/string/base/remove-last]: https://github.com/stdlib-js/string-base-remove-last +[@stdlib/string/base/remove-last]: https://github.com/stdlib-js/string-base-remove-last/tree/umd 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 a39bd29..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,56 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isString = require( '@stdlib/assert-is-string' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var removeLast = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var values; - var out; - var i; - - values = [ - 'beep boop', - 'foo bar', - 'xyz abc', - '🐶🐮🐷🐰🐸' - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = removeLast( values[ i%values.length ], 1 ); - if ( typeof out !== 'string' ) { - b.fail( 'should return a string' ); - } - } - b.toc(); - if ( !isString( out ) ) { - b.fail( 'should return a string' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index f585c99..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/base/remove-last-code-point" -%% click B href "https://github.com/stdlib-js/string-base-remove-last-code-point/tree/main" -%% click C href "https://github.com/stdlib-js/string-base-remove-last-code-point/tree/production" -%% click D href "https://github.com/stdlib-js/string-base-remove-last-code-point/tree/esm" -%% click E href "https://github.com/stdlib-js/string-base-remove-last-code-point/tree/deno" -%% click F href "https://github.com/stdlib-js/string-base-remove-last-code-point/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/string/base/remove-last-code-point -[production-url]: https://github.com/stdlib-js/string-base-remove-last-code-point/tree/production -[deno-url]: https://github.com/stdlib-js/string-base-remove-last-code-point/tree/deno -[deno-readme]: https://github.com/stdlib-js/string-base-remove-last-code-point/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/string-base-remove-last-code-point/tree/umd -[umd-readme]: https://github.com/stdlib-js/string-base-remove-last-code-point/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/string-base-remove-last-code-point/tree/esm -[esm-readme]: https://github.com/stdlib-js/string-base-remove-last-code-point/blob/esm/README.md \ No newline at end of file diff --git a/browser.js b/browser.js new file mode 100644 index 0000000..eb0d81d --- /dev/null +++ b/browser.js @@ -0,0 +1,3 @@ +// Copyright (c) 2025 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +var e,t;e=this,t=function(){"use strict";var e=/[\uDC00-\uDFFF]/,t=/[\uD800-\uDBFF]/;return function(n,f){var i,o,r,u;if(0===f)return n;for(r=0,u=n.length-1;u>=0;u--){if(i=n[u],r+=1,e.test(i)){if(0===u)break;o=n[u-1],t.test(o)&&(u-=1)}if(r===f)break}return n.substring(0,u)}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).removeLastCodePoint=t(); +//# sourceMappingURL=browser.js.map diff --git a/browser.js.map b/browser.js.map new file mode 100644 index 0000000..19908eb --- /dev/null +++ b/browser.js.map @@ -0,0 +1 @@ +{"version":3,"file":"browser.js","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\nvar RE_UTF16_LOW_SURROGATE = /[\\uDC00-\\uDFFF]/; // TODO: replace with stdlib pkg\nvar RE_UTF16_HIGH_SURROGATE = /[\\uD800-\\uDBFF]/; // TODO: replace with stdlib pkg\n\n\n// MAIN //\n\n/**\n* Removes the last `n` Unicode code points of a string.\n*\n* @param {string} str - input string\n* @param {NonNegativeInteger} n - number of Unicode code points to remove\n* @returns {string} output string\n*\n* @example\n* var out = removeLast( 'last man standing', 1 );\n* // returns 'last man standin'\n*\n* @example\n* var out = removeLast( 'presidential election', 1 );\n* // returns 'presidential electio'\n*\n* @example\n* var out = removeLast( 'JavaScript', 1 );\n* // returns 'JavaScrip'\n*\n* @example\n* var out = removeLast( 'Hidden Treasures', 1 );\n* // returns 'Hidden Treasure'\n*/\nfunction removeLast( str, n ) {\n\tvar len;\n\tvar ch1;\n\tvar ch2;\n\tvar cnt;\n\tvar i;\n\tif ( n === 0 ) {\n\t\treturn str;\n\t}\n\tlen = str.length;\n\tcnt = 0;\n\n\t// Process the string one Unicode code unit at a time and count UTF-16 surrogate pairs as a single Unicode code point...\n\tfor ( i = len - 1; i >= 0; i-- ) {\n\t\tch1 = str[ i ];\n\t\tcnt += 1;\n\n\t\t// Check for a low UTF-16 surrogate...\n\t\tif ( RE_UTF16_LOW_SURROGATE.test( ch1 ) ) {\n\t\t\t// Check for an unpaired surrogate at the end of the input string...\n\t\t\tif ( i === 0 ) {\n\t\t\t\t// We found an unpaired surrogate...\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\t// Check whether the high surrogate is paired with a low surrogate...\n\t\t\tch2 = str[ i-1 ];\n\t\t\tif ( RE_UTF16_HIGH_SURROGATE.test( ch2 ) ) {\n\t\t\t\t// We found a surrogate pair:\n\t\t\t\ti -= 1; // bump the index to process the next code unit\n\t\t\t}\n\t\t}\n\t\t// Check whether we've found the desired number of code points...\n\t\tif ( cnt === n ) {\n\t\t\tbreak;\n\t\t}\n\t}\n\treturn str.substring( 0, i );\n}\n\n\n// EXPORTS //\n\nexport default removeLast;\n"],"names":["RE_UTF16_LOW_SURROGATE","RE_UTF16_HIGH_SURROGATE","str","n","ch1","ch2","cnt","i","length","test","substring"],"mappings":";yCAsBA,IAAIA,EAAyB,kBACzBC,EAA0B,yBA4B9B,SAAqBC,EAAKC,GACzB,IACIC,EACAC,EACAC,EACAC,EACJ,GAAW,IAANJ,EACJ,OAAOD,EAMR,IAHAI,EAAM,EAGAC,EAJAL,EAAIM,OAIM,EAAGD,GAAK,EAAGA,IAAM,CAKhC,GAJAH,EAAMF,EAAKK,GACXD,GAAO,EAGFN,EAAuBS,KAAML,GAAQ,CAEzC,GAAW,IAANG,EAEJ,MAGDF,EAAMH,EAAKK,EAAE,GACRN,EAAwBQ,KAAMJ,KAElCE,GAAK,EAEN,CAED,GAAKD,IAAQH,EACZ,KAED,CACD,OAAOD,EAAIQ,UAAW,EAAGH,EAC1B"} \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index 8c96fd7..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import removeLast from '../docs/types/index'; -export = removeLast; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index e6b7220..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var s=function(e,t){return function(){return t||e((t={exports:{}}).exports,t),t.exports}};var f=s(function(D,n){ -var F=/[\uDC00-\uDFFF]/,c=/[\uD800-\uDBFF]/;function R(e,t){var i,u,v,a,r;if(t===0)return e;for(i=e.length,a=0,r=i-1;r>=0;r--){if(u=e[r],a+=1,F.test(u)){if(r===0)break;v=e[r-1],c.test(v)&&(r-=1)}if(a===t)break}return e.substring(0,r)}n.exports=R -});var _=f();module.exports=_; -/** @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 72561cf..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\nvar RE_UTF16_LOW_SURROGATE = /[\\uDC00-\\uDFFF]/; // TODO: replace with stdlib pkg\nvar RE_UTF16_HIGH_SURROGATE = /[\\uD800-\\uDBFF]/; // TODO: replace with stdlib pkg\n\n\n// MAIN //\n\n/**\n* Removes the last `n` Unicode code points of a string.\n*\n* @param {string} str - input string\n* @param {NonNegativeInteger} n - number of Unicode code points to remove\n* @returns {string} output string\n*\n* @example\n* var out = removeLast( 'last man standing', 1 );\n* // returns 'last man standin'\n*\n* @example\n* var out = removeLast( 'presidential election', 1 );\n* // returns 'presidential electio'\n*\n* @example\n* var out = removeLast( 'JavaScript', 1 );\n* // returns 'JavaScrip'\n*\n* @example\n* var out = removeLast( 'Hidden Treasures', 1 );\n* // returns 'Hidden Treasure'\n*/\nfunction removeLast( str, n ) {\n\tvar len;\n\tvar ch1;\n\tvar ch2;\n\tvar cnt;\n\tvar i;\n\tif ( n === 0 ) {\n\t\treturn str;\n\t}\n\tlen = str.length;\n\tcnt = 0;\n\n\t// Process the string one Unicode code unit at a time and count UTF-16 surrogate pairs as a single Unicode code point...\n\tfor ( i = len - 1; i >= 0; i-- ) {\n\t\tch1 = str[ i ];\n\t\tcnt += 1;\n\n\t\t// Check for a low UTF-16 surrogate...\n\t\tif ( RE_UTF16_LOW_SURROGATE.test( ch1 ) ) {\n\t\t\t// Check for an unpaired surrogate at the end of the input string...\n\t\t\tif ( i === 0 ) {\n\t\t\t\t// We found an unpaired surrogate...\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\t// Check whether the high surrogate is paired with a low surrogate...\n\t\t\tch2 = str[ i-1 ];\n\t\t\tif ( RE_UTF16_HIGH_SURROGATE.test( ch2 ) ) {\n\t\t\t\t// We found a surrogate pair:\n\t\t\t\ti -= 1; // bump the index to process the next code unit\n\t\t\t}\n\t\t}\n\t\t// Check whether we've found the desired number of code points...\n\t\tif ( cnt === n ) {\n\t\t\tbreak;\n\t\t}\n\t}\n\treturn str.substring( 0, i );\n}\n\n\n// EXPORTS //\n\nmodule.exports = removeLast;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Remove the last `n` Unicode code points of a string.\n*\n* @module @stdlib/string-base-remove-last-code-point\n*\n* @example\n* var removeLast = require( '@stdlib/string-base-remove-last-code-point' );\n*\n* var out = removeLast( 'last man standing', 1 );\n* // returns 'last man standin'\n*\n* out = removeLast( 'Hidden Treasures', 1 );\n* // returns 'Hidden Treasure';\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,EAAyB,kBACzBC,EAA0B,kBA4B9B,SAASC,EAAYC,EAAKC,EAAI,CAC7B,IAAIC,EACAC,EACAC,EACAC,EACAC,EACJ,GAAKL,IAAM,EACV,OAAOD,EAMR,IAJAE,EAAMF,EAAI,OACVK,EAAM,EAGAC,EAAIJ,EAAM,EAAGI,GAAK,EAAGA,IAAM,CAKhC,GAJAH,EAAMH,EAAKM,CAAE,EACbD,GAAO,EAGFR,EAAuB,KAAMM,CAAI,EAAI,CAEzC,GAAKG,IAAM,EAEV,MAGDF,EAAMJ,EAAKM,EAAE,CAAE,EACVR,EAAwB,KAAMM,CAAI,IAEtCE,GAAK,EAEP,CAEA,GAAKD,IAAQJ,EACZ,KAEF,CACA,OAAOD,EAAI,UAAW,EAAGM,CAAE,CAC5B,CAKAV,EAAO,QAAUG,ICxDjB,IAAIQ,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "RE_UTF16_LOW_SURROGATE", "RE_UTF16_HIGH_SURROGATE", "removeLast", "str", "n", "len", "ch1", "ch2", "cnt", "i", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index a08ea55..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,29 +0,0 @@ - -{{alias}}( str, n ) - Removes the last `n` Unicode code points of a string. - - Parameters - ---------- - str: string - Input string. - - n: integer - Number of Unicode code points to remove. - - Returns - ------- - out: string - Output string. - - Examples - -------- - > var out = {{alias}}( 'beep', 1 ) - 'bee' - > out = {{alias}}( 'Boop', 1 ) - 'Boo' - > out = {{alias}}( 'foo bar', 5 ) - 'fo' - - See Also - -------- - diff --git a/docs/types/index.d.ts b/docs/types/index.d.ts deleted file mode 100644 index 8a1c90b..0000000 --- a/docs/types/index.d.ts +++ /dev/null @@ -1,53 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 - -/** -* Removes the last `n` Unicode code points of a string. -* -* @param str - input string -* @param n - number of code points to remove -* @returns output string -* -* @example -* var out = removeLast( 'last man standing', 1 ); -* // returns 'last man standin' -* -* @example -* var out = removeLast( 'presidential election', 1 ); -* // returns 'presidential electio' -* -* @example -* var out = removeLast( 'JavaScript', 1 ); -* // returns 'JavaScrip' -* -* @example -* var out = removeLast( 'Hidden Treasures', 1 ); -* // returns 'Hidden Treasure' -* -* @example -* var out = removeLast( 'foo bar', 5 ); -* // returns 'fo' -*/ -declare function removeLast( str: string, n: number ): string; - - -// EXPORTS // - -export = removeLast; diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index fd426d2..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,57 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 removeLast = require( './index' ); - - -// TESTS // - -// The function returns a string... -{ - removeLast( 'abc', 1 ); // $ExpectType string -} - -// The compiler throws an error if the function is provided a value other than a string... -{ - removeLast( true, 1 ); // $ExpectError - removeLast( false, 1 ); // $ExpectError - removeLast( null, 1 ); // $ExpectError - removeLast( undefined, 1 ); // $ExpectError - removeLast( 5, 1 ); // $ExpectError - removeLast( [], 1 ); // $ExpectError - removeLast( {}, 1 ); // $ExpectError - removeLast( ( x: number ): number => x, 1 ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument that is not a number... -{ - removeLast( 'abc', true ); // $ExpectError - removeLast( 'abc', false ); // $ExpectError - removeLast( 'abc', null ); // $ExpectError - removeLast( 'abc', 'abc' ); // $ExpectError - removeLast( 'abc', [] ); // $ExpectError - removeLast( 'abc', {} ); // $ExpectError - removeLast( 'abc', ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - removeLast(); // $ExpectError - removeLast( 'abc' ); // $ExpectError - removeLast( 'abc', 1, 2 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 085633e..0000000 --- a/examples/index.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var removeLastCodePoint = require( './../lib' ); - -console.log( removeLastCodePoint( 'presidential election', 1 ) ); -// => 'presidential electio' - -console.log( removeLastCodePoint( 'JavaScript', 1 ) ); -// => 'JavaScrip' - -console.log( removeLastCodePoint( 'The Last of the Mohicans', 5 ) ); -// => 'The Last of the Moh' - -console.log( removeLastCodePoint( 'अनुच्छेद', 1 ) ); -// => 'अनुच्छे' diff --git a/index.js b/index.js new file mode 100644 index 0000000..0ea9197 --- /dev/null +++ b/index.js @@ -0,0 +1,3 @@ +// Copyright (c) 2025 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +var e,t;e=this,t=function(){"use strict";var e=/[\uDC00-\uDFFF]/,t=/[\uD800-\uDBFF]/;return function(n,f){var i,o,r,u;if(0===f)return n;for(r=0,u=n.length-1;u>=0;u--){if(i=n[u],r+=1,e.test(i)){if(0===u)break;o=n[u-1],t.test(o)&&(u-=1)}if(r===f)break}return n.substring(0,u)}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).removeLastCodePoint=t(); +//# sourceMappingURL=index.js.map diff --git a/index.js.map b/index.js.map new file mode 100644 index 0000000..d557af8 --- /dev/null +++ b/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// VARIABLES //\n\nvar RE_UTF16_LOW_SURROGATE = /[\\uDC00-\\uDFFF]/; // TODO: replace with stdlib pkg\nvar RE_UTF16_HIGH_SURROGATE = /[\\uD800-\\uDBFF]/; // TODO: replace with stdlib pkg\n\n\n// MAIN //\n\n/**\n* Removes the last `n` Unicode code points of a string.\n*\n* @param {string} str - input string\n* @param {NonNegativeInteger} n - number of Unicode code points to remove\n* @returns {string} output string\n*\n* @example\n* var out = removeLast( 'last man standing', 1 );\n* // returns 'last man standin'\n*\n* @example\n* var out = removeLast( 'presidential election', 1 );\n* // returns 'presidential electio'\n*\n* @example\n* var out = removeLast( 'JavaScript', 1 );\n* // returns 'JavaScrip'\n*\n* @example\n* var out = removeLast( 'Hidden Treasures', 1 );\n* // returns 'Hidden Treasure'\n*/\nfunction removeLast( str, n ) {\n\tvar len;\n\tvar ch1;\n\tvar ch2;\n\tvar cnt;\n\tvar i;\n\tif ( n === 0 ) {\n\t\treturn str;\n\t}\n\tlen = str.length;\n\tcnt = 0;\n\n\t// Process the string one Unicode code unit at a time and count UTF-16 surrogate pairs as a single Unicode code point...\n\tfor ( i = len - 1; i >= 0; i-- ) {\n\t\tch1 = str[ i ];\n\t\tcnt += 1;\n\n\t\t// Check for a low UTF-16 surrogate...\n\t\tif ( RE_UTF16_LOW_SURROGATE.test( ch1 ) ) {\n\t\t\t// Check for an unpaired surrogate at the end of the input string...\n\t\t\tif ( i === 0 ) {\n\t\t\t\t// We found an unpaired surrogate...\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\t// Check whether the high surrogate is paired with a low surrogate...\n\t\t\tch2 = str[ i-1 ];\n\t\t\tif ( RE_UTF16_HIGH_SURROGATE.test( ch2 ) ) {\n\t\t\t\t// We found a surrogate pair:\n\t\t\t\ti -= 1; // bump the index to process the next code unit\n\t\t\t}\n\t\t}\n\t\t// Check whether we've found the desired number of code points...\n\t\tif ( cnt === n ) {\n\t\t\tbreak;\n\t\t}\n\t}\n\treturn str.substring( 0, i );\n}\n\n\n// EXPORTS //\n\nexport default removeLast;\n"],"names":["RE_UTF16_LOW_SURROGATE","RE_UTF16_HIGH_SURROGATE","str","n","ch1","ch2","cnt","i","length","test","substring"],"mappings":";yCAsBA,IAAIA,EAAyB,kBACzBC,EAA0B,yBA4B9B,SAAqBC,EAAKC,GACzB,IACIC,EACAC,EACAC,EACAC,EACJ,GAAW,IAANJ,EACJ,OAAOD,EAMR,IAHAI,EAAM,EAGAC,EAJAL,EAAIM,OAIM,EAAGD,GAAK,EAAGA,IAAM,CAKhC,GAJAH,EAAMF,EAAKK,GACXD,GAAO,EAGFN,EAAuBS,KAAML,GAAQ,CAEzC,GAAW,IAANG,EAEJ,MAGDF,EAAMH,EAAKK,EAAE,GACRN,EAAwBQ,KAAMJ,KAElCE,GAAK,EAEN,CAED,GAAKD,IAAQH,EACZ,KAED,CACD,OAAOD,EAAIQ,UAAW,EAAGH,EAC1B"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 9860da0..0000000 --- a/lib/index.js +++ /dev/null @@ -1,43 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Remove the last `n` Unicode code points of a string. -* -* @module @stdlib/string-base-remove-last-code-point -* -* @example -* var removeLast = require( '@stdlib/string-base-remove-last-code-point' ); -* -* var out = removeLast( 'last man standing', 1 ); -* // returns 'last man standin' -* -* out = removeLast( 'Hidden Treasures', 1 ); -* // returns 'Hidden Treasure'; -*/ - -// 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 fc34187..0000000 --- a/lib/main.js +++ /dev/null @@ -1,94 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// VARIABLES // - -var RE_UTF16_LOW_SURROGATE = /[\uDC00-\uDFFF]/; // TODO: replace with stdlib pkg -var RE_UTF16_HIGH_SURROGATE = /[\uD800-\uDBFF]/; // TODO: replace with stdlib pkg - - -// MAIN // - -/** -* Removes the last `n` Unicode code points of a string. -* -* @param {string} str - input string -* @param {NonNegativeInteger} n - number of Unicode code points to remove -* @returns {string} output string -* -* @example -* var out = removeLast( 'last man standing', 1 ); -* // returns 'last man standin' -* -* @example -* var out = removeLast( 'presidential election', 1 ); -* // returns 'presidential electio' -* -* @example -* var out = removeLast( 'JavaScript', 1 ); -* // returns 'JavaScrip' -* -* @example -* var out = removeLast( 'Hidden Treasures', 1 ); -* // returns 'Hidden Treasure' -*/ -function removeLast( str, n ) { - var len; - var ch1; - var ch2; - var cnt; - var i; - if ( n === 0 ) { - return str; - } - len = str.length; - cnt = 0; - - // Process the string one Unicode code unit at a time and count UTF-16 surrogate pairs as a single Unicode code point... - for ( i = len - 1; i >= 0; i-- ) { - ch1 = str[ i ]; - cnt += 1; - - // Check for a low UTF-16 surrogate... - if ( RE_UTF16_LOW_SURROGATE.test( ch1 ) ) { - // Check for an unpaired surrogate at the end of the input string... - if ( i === 0 ) { - // We found an unpaired surrogate... - break; - } - // Check whether the high surrogate is paired with a low surrogate... - ch2 = str[ i-1 ]; - if ( RE_UTF16_HIGH_SURROGATE.test( ch2 ) ) { - // We found a surrogate pair: - i -= 1; // bump the index to process the next code unit - } - } - // Check whether we've found the desired number of code points... - if ( cnt === n ) { - break; - } - } - return str.substring( 0, i ); -} - - -// EXPORTS // - -module.exports = removeLast; diff --git a/package.json b/package.json index 8dd3c53..e1a7e6d 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,7 @@ "version": "0.2.2", "description": "Remove the last Unicode code point of a string.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "main": "./index.js", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,31 +12,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/assert-is-string": "^0.2.2", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdstring", @@ -81,4 +32,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/stats_browser.html b/stats_browser.html new file mode 100644 index 0000000..2c17dcc --- /dev/null +++ b/stats_browser.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/stats_node.html b/stats_node.html new file mode 100644 index 0000000..1e086d4 --- /dev/null +++ b/stats_node.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index a25545e..0000000 --- a/test/test.js +++ /dev/null @@ -1,108 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var removeLast = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof removeLast, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns an empty string if provided an empty string', function test( t ) { - t.strictEqual( removeLast( '', 1 ), '', 'returns expected value' ); - t.strictEqual( removeLast( '', 2 ), '', 'returns expected value' ); - t.strictEqual( removeLast( '', 3 ), '', 'returns expected value' ); - t.end(); -}); - -tape( 'the function returns the input string if provided zero as the second argument', function test( t ) { - t.strictEqual( removeLast( 'hello world', 0 ), 'hello world', 'returns expected value' ); - t.end(); -}); - -tape( 'the function removes the last Unicode code point of a provided string (ascii)', function test( t ) { - var out; - - out = removeLast( 'hello world', 1 ); - t.strictEqual( out, 'hello worl', 'returns expected value' ); - - out = removeLast( '!!!', 1 ); - t.strictEqual( out, '!!', 'returns expected value' ); - - out = removeLast( 'Hello World', 1 ); - t.strictEqual( out, 'Hello Worl', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function removes the last Unicode code point of a provided string (Unicode)', function test( t ) { - var out; - - out = removeLast( 'अनुच्छेद', 1 ); - t.strictEqual( out, 'अनुच्छे', 'returns expected value' ); - - out = removeLast( '六书/六書', 1 ); - t.strictEqual( out, '六书/六', 'returns expected value' ); - - out = removeLast( '𐒻𐓟', 1 ); - t.strictEqual( out, '𐒻', 'returns expected value' ); - - out = removeLast( '𐒻𐓟', 1 ); - t.strictEqual( out, '𐒻', 'returns expected value' ); - - out = removeLast( '\uDC00', 1 ); - t.strictEqual( out, '', 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports removing the last `n` Unicode code points of a provided string', function test( t ) { - var out; - - out = removeLast( 'hello world', 1 ); - t.strictEqual( out, 'hello worl', 'returns expected value' ); - - out = removeLast( 'hello world', 7 ); - t.strictEqual( out, 'hell', 'returns expected value' ); - - out = removeLast( '!!!', 1 ); - t.strictEqual( out, '!!', 'returns expected value' ); - - out = removeLast( '!!!', 2 ); - t.strictEqual( out, '!', 'returns expected value' ); - - out = removeLast( 'अनुच्छेद', 1 ); - t.strictEqual( out, 'अनुच्छे', 'returns expected value' ); - - out = removeLast( '六书/六書', 3 ); - t.strictEqual( out, '六书', 'returns expected value' ); - - out = removeLast( '𐒻𐓟𐓟', 2 ); - t.strictEqual( out, '𐒻', 'returns expected value' ); - - t.end(); -});