From 10da832e2ba6631afac9cb6d098ab18ec6075a10 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 14 Mar 2022 19:33:33 +0000 Subject: [PATCH] Release v0.0.1 --- .editorconfig | 181 ++++ .eslintrc.js | 1 + .gitattributes | 33 + .github/PULL_REQUEST_TEMPLATE.md | 7 + .github/workflows/benchmark.yml | 42 + .github/workflows/bundle.yml | 256 +++++ .github/workflows/cancel.yml | 41 + .github/workflows/close_pull_requests.yml | 44 + .github/workflows/examples.yml | 42 + .github/workflows/publish.yml | 99 ++ .github/workflows/test.yml | 62 ++ .github/workflows/test_bundles.yml | 99 ++ .github/workflows/test_coverage.yml | 76 ++ .github/workflows/test_install.yml | 55 ++ .gitignore | 178 ++++ .npmignore | 226 +++++ .npmrc | 28 + CHANGELOG.md | 5 + CODE_OF_CONDUCT.md | 3 + CONTRIBUTING.md | 3 + CONTRIBUTORS | 28 + LICENSE | 481 +++++++++ Makefile | 534 ++++++++++ NOTICE | 1 + README.md | 197 ++++ benchmark/benchmark.js | 73 ++ docs/repl.txt | 31 + examples/index.js | 41 + lib/format_double.js | 111 +++ lib/format_integer.js | 115 +++ lib/index.js | 43 + lib/main.js | 194 ++++ lib/space_pad.js | 51 + lib/tokenize.js | 85 ++ lib/zero_pad.js | 60 ++ package.json | 97 ++ test/test.format_double.js | 106 ++ test/test.format_integer.js | 170 ++++ test/test.js | 1092 +++++++++++++++++++++ test/test.space_pad.js | 84 ++ test/test.tokenize.js | 287 ++++++ test/test.zero_pad.js | 69 ++ 42 files changed, 5431 insertions(+) create mode 100644 .editorconfig create mode 100644 .eslintrc.js create mode 100644 .gitattributes create mode 100644 .github/PULL_REQUEST_TEMPLATE.md create mode 100644 .github/workflows/benchmark.yml create mode 100644 .github/workflows/bundle.yml create mode 100644 .github/workflows/cancel.yml create mode 100644 .github/workflows/close_pull_requests.yml create mode 100644 .github/workflows/examples.yml create mode 100644 .github/workflows/publish.yml create mode 100644 .github/workflows/test.yml create mode 100644 .github/workflows/test_bundles.yml create mode 100644 .github/workflows/test_coverage.yml create mode 100644 .github/workflows/test_install.yml create mode 100644 .gitignore create mode 100644 .npmignore create mode 100644 .npmrc create mode 100644 CHANGELOG.md create mode 100644 CODE_OF_CONDUCT.md create mode 100644 CONTRIBUTING.md create mode 100644 CONTRIBUTORS create mode 100644 LICENSE create mode 100644 Makefile create mode 100644 NOTICE create mode 100644 README.md create mode 100644 benchmark/benchmark.js create mode 100644 docs/repl.txt create mode 100644 examples/index.js create mode 100644 lib/format_double.js create mode 100644 lib/format_integer.js create mode 100644 lib/index.js create mode 100644 lib/main.js create mode 100644 lib/space_pad.js create mode 100644 lib/tokenize.js create mode 100644 lib/zero_pad.js create mode 100644 package.json create mode 100644 test/test.format_double.js create mode 100644 test/test.format_integer.js create mode 100644 test/test.js create mode 100644 test/test.space_pad.js create mode 100644 test/test.tokenize.js create mode 100644 test/test.zero_pad.js diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..0fd4d6c --- /dev/null +++ b/.editorconfig @@ -0,0 +1,181 @@ +#/ +# @license Apache-2.0 +# +# Copyright (c) 2017 The Stdlib Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +#/ + +# EditorConfig configuration file (see ). + +# Indicate that this file is a root-level configuration file: +root = true + +# Set properties for all files: +[*] +end_of_line = lf +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true + +# Set properties for JavaScript files: +[*.{js,js.txt}] +indent_style = tab + +# Set properties for JavaScript ES module files: +[*.{mjs,mjs.txt}] +indent_style = tab + +# Set properties for JavaScript CommonJS files: +[*.{cjs,cjs.txt}] +indent_style = tab + +# Set properties for JSON files: +[*.{json,json.txt}] +indent_style = space +indent_size = 2 + +# Set properties for `cli_opts.json` files: +[cli_opts.json] +indent_style = tab + +# Set properties for TypeScript files: +[*.ts] +indent_style = tab + +# Set properties for Python files: +[*.{py,py.txt}] +indent_style = space +indent_size = 4 + +# Set properties for Julia files: +[*.{jl,jl.txt}] +indent_style = tab + +# Set properties for R files: +[*.{R,R.txt}] +indent_style = tab + +# Set properties for C files: +[*.{c,c.txt}] +indent_style = tab + +# Set properties for C header files: +[*.{h,h.txt}] +indent_style = tab + +# Set properties for C++ files: +[*.{cpp,cpp.txt}] +indent_style = tab + +# Set properties for C++ header files: +[*.{hpp,hpp.txt}] +indent_style = tab + +# Set properties for Fortran files: +[*.{f,f.txt}] +indent_style = space +indent_size = 2 +insert_final_newline = false + +# Set properties for shell files: +[*.{sh,sh.txt}] +indent_style = tab + +# Set properties for AWK files: +[*.{awk,awk.txt}] +indent_style = tab + +# Set properties for HTML files: +[*.{html,html.txt}] +indent_style = tab +tab_width = 2 + +# Set properties for XML files: +[*.{xml,xml.txt}] +indent_style = tab +tab_width = 2 + +# Set properties for CSS files: +[*.{css,css.txt}] +indent_style = tab + +# Set properties for Makefiles: +[Makefile] +indent_style = tab + +[*.{mk,mk.txt}] +indent_style = tab + +# Set properties for Markdown files: +[*.{md,md.txt}] +indent_style = space +indent_size = 4 +trim_trailing_whitespace = false + +# Set properties for `usage.txt` files: +[usage.txt] +indent_style = space +indent_size = 2 + +# Set properties for `repl.txt` files: +[repl.txt] +indent_style = space +indent_size = 4 + +# Set properties for `package.json` files: +[package.{json,json.txt}] +indent_style = space +indent_size = 2 + +# Set properties for `datapackage.json` files: +[datapackage.json] +indent_style = space +indent_size = 2 + +# Set properties for `manifest.json` files: +[manifest.json] +indent_style = space +indent_size = 2 + +# Set properties for `tslint.json` files: +[tslint.json] +indent_style = space +indent_size = 2 + +# Set properties for `tsconfig.json` files: +[tsconfig.json] +indent_style = space +indent_size = 2 + +# Set properties for LaTeX files: +[*.{tex,tex.txt}] +indent_style = tab + +# Set properties for LaTeX Bibliography files: +[*.{bib,bib.txt}] +indent_style = tab + +# Set properties for YAML files: +[*.{yml,yml.txt}] +indent_style = space +indent_size = 2 + +# Set properties for GYP files: +[binding.gyp] +indent_style = space +indent_size = 2 + +[*.gypi] +indent_style = space +indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js new file mode 100644 index 0000000..5f30286 --- /dev/null +++ b/.eslintrc.js @@ -0,0 +1 @@ +/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..7212d81 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,33 @@ +#/ +# @license Apache-2.0 +# +# Copyright (c) 2017 The Stdlib Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +#/ + +# Configuration file which assigns attributes to pathnames. +# +# [1]: https://git-scm.com/docs/gitattributes + +# Automatically normalize the line endings of any committed text files: +* text=auto + +# Override what is considered "vendored" by GitHub's linguist: +/deps/** linguist-vendored=false +/lib/node_modules/** linguist-vendored=false linguist-generated=false +test/fixtures/** linguist-vendored=false +tools/** linguist-vendored=false + +# Override what is considered "documentation" by GitHub's linguist: +examples/** linguist-documentation=false diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 0000000..95150e0 --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,7 @@ + + +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/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 new file mode 100644 index 0000000..fccb4c2 --- /dev/null +++ b/.github/workflows/benchmark.yml @@ -0,0 +1,42 @@ +#/ +# @license Apache-2.0 +# +# Copyright (c) 2021 The Stdlib Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS 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: + workflow_dispatch: + +# Workflow jobs: +jobs: + benchmark: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-node@v2 + with: + node-version: 16 + timeout-minutes: 5 + - name: Install production and development dependencies + run: | + npm install || npm install || npm install + timeout-minutes: 15 + - 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