diff --git a/.editorconfig b/.editorconfig index dab5d2a..0fd4d6c 100644 --- a/.editorconfig +++ b/.editorconfig @@ -86,6 +86,7 @@ indent_style = tab [*.{f,f.txt}] indent_style = space indent_size = 2 +insert_final_newline = false # Set properties for shell files: [*.{sh,sh.txt}] @@ -120,7 +121,7 @@ indent_style = tab [*.{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. +trim_trailing_whitespace = false # Set properties for `usage.txt` files: [usage.txt] @@ -147,6 +148,11 @@ indent_size = 2 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 @@ -173,8 +179,3 @@ 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/.gitattributes b/.gitattributes index 1c88e69..7212d81 100644 --- a/.gitattributes +++ b/.gitattributes @@ -23,44 +23,11 @@ # 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 +/deps/** linguist-vendored=false +/lib/node_modules/** linguist-vendored=false linguist-generated=false +test/fixtures/** linguist-vendored=false +tools/** linguist-vendored=false -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation +# 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 e603b51..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2025-03-17T01:20:38.202Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 758f430..95150e0 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -2,6 +2,6 @@ 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/format) of the main repository where we’ll review and provide feedback. -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/contributing/development.md) for help on developing stdlib. +If this is your first stdlib contribution, be 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 index e4f10fe..fccb4c2 100644 --- a/.github/workflows/benchmark.yml +++ b/.github/workflows/benchmark.yml @@ -21,44 +21,22 @@ 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... + runs-on: ubuntu-latest 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 + - uses: actions/checkout@v2 + - uses: actions/setup-node@v2 with: - node-version: 20 + node-version: 16 timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' + - name: Install production and development dependencies run: | npm install || npm install || npm install timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' + - name: Run benchmarks run: | npm run benchmark diff --git a/.github/workflows/bundle.yml b/.github/workflows/bundle.yml new file mode 100644 index 0000000..c52c372 --- /dev/null +++ b/.github/workflows/bundle.yml @@ -0,0 +1,256 @@ +#/ +# @license Apache-2.0 +# +# Copyright (c) 2022 The Stdlib Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +#/ + +# Workflow name: +name: bundle + +# Workflow triggers: +on: + workflow_dispatch: + push: + branches: + - main + tags_ignore: + - 'v[0-9]+\.[0-9]+\.[0-9]+' + +# Workflow jobs: +jobs: + deno: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - 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 + - uses: actions/setup-node@v2 + with: + node-version: 16 + timeout-minutes: 5 + - name: Install production and development dependencies + id: install + run: | + npm install || npm install || npm install + timeout-minutes: 15 + - name: Bundle package for Deno + id: deno-bundle + uses: stdlib-js/bundle-action@main + with: + target: 'deno' + - name: Rewrite file contents + run: | + # Replace links to other packages with links to the deno branch: + find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; + + # Replace reference to `@stdlib/types` with CDN link: + find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" + + # Change wording of project description to avoid reference to JavaScript and Node.js: + find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" + + # Rewrite all `require()`s to use jsDelivr links: + find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { + s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i + s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ + s/';/@deno\/mod.js';/ + }" + + # Remove `installation`, `cli`, and `c` sections: + find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" + find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" + find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" + + # Create package.json file for deno branch: + jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json + + - name: Publish to deno branch + uses: peaceiris/actions-gh-pages@v3 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + publish_dir: ./deno + publish_branch: deno + keep_files: true + user_name: 'stdlib-bot' + user_email: 'noreply@stdlib.io' + commit_message: 'Auto-generated commit' + enable_jekyll: true + - name: Send status to Slack channel in case of failure + uses: act10ns/slack@v1 + with: + status: ${{ job.status }} + steps: ${{ toJson(steps) }} + channel: '#npm-ci' + if: failure() + umd: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Copy files to umd directory + run: | + mkdir -p umd + cp README.md LICENSE CONTRIBUTORS NOTICE ./umd + - uses: actions/setup-node@v2 + with: + node-version: 16 + timeout-minutes: 5 + - name: Install production and development dependencies + id: install + run: | + npm install || npm install || npm install + timeout-minutes: 15 + - name: Extract Alias + id: extract-alias + run: | + alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') + echo "::set-output name=alias::${alias}" + - name: Create Universal Module Definition (UMD) bundle + id: umd-bundle + uses: stdlib-js/bundle-action@main + with: + target: 'umd' + alias: ${{ steps.extract-alias.outputs.alias }} + - 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\/bundle.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n