From fe5fb5779f19a7833c62ca9a3ef0d1cb6a9a80b5 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Apr 2022 05:25:36 +0000 Subject: [PATCH 001/133] Auto-generated commit 6a0e28787d8c12b2442fa01cd5daa8d15c939c0b --- index.d.ts | 48 + index.mjs | 4 + index.mjs.map | 1 + stats.html | 2689 +++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 2742 insertions(+) create mode 100644 index.d.ts create mode 100644 index.mjs create mode 100644 index.mjs.map create mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts new file mode 100644 index 0000000..f77442a --- /dev/null +++ b/index.d.ts @@ -0,0 +1,48 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2019 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +// TypeScript Version: 2.0 + +/** +* Tests if a value is an array of probabilities that sum to one. +* +* @param v - value to test +* @returns boolean indicating if a value is a probability array +* +* @example +* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] ); +* // returns true +* +* @example +* var bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) ); +* // returns true +* +* @example +* var bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] ); +* // returns false +* +* @example +* var bool = isUnityProbabilityArray( [ 3.14, 0.0 ] ); +* // returns false +*/ +declare function isUnityProbabilityArray( v: any ): boolean; + + +// EXPORTS // + +export = isUnityProbabilityArray; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..4bb2a54 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-typed-array@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-number@esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/math-base-utils-absolute-difference@esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/constants-float64-sqrt-eps@esm/index.mjs";var n=s,d=t,m=r.isPrimitive,a=e,o=i;var f=function(s){var t,r;if(d(s)){for(t=0,r=0;r1||s[r]<0)return!1;t+=s[r]}return a(t,1)<=o}if(n(s)){for(t=0,r=0;r1||s[r]<0)return!1;t+=s[r]}return a(t,1)<=o}return!1};export{f as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..e0d943c --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isTypedArray = require( '@stdlib/assert-is-typed-array' );\nvar isArray = require( '@stdlib/assert-is-array' );\nvar isNumber = require( '@stdlib/assert-is-number' ).isPrimitive;\nvar absdiff = require( '@stdlib/math-base-utils-absolute-difference' );\nvar FLOAT64_SQRT_EPS = require( '@stdlib/constants-float64-sqrt-eps' );\n\n\n// MAIN //\n\n/**\n* Tests if a value is an array of probabilities that sum to one.\n*\n* @param {*} v - value to test\n* @returns {boolean} boolean indicating if a value is a probability array\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] );\n* // returns true\n*\n* @example\n* var bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) );\n* // returns true\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] );\n* // returns false\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 3.14, 0.0 ] );\n* // returns false\n*/\nfunction isUnityProbabilityArray( v ) {\n\tvar sum;\n\tvar i;\n\tif ( isArray( v ) ) {\n\t\tsum = 0.0;\n\t\tfor ( i = 0; i < v.length; i++ ) {\n\t\t\tif (\n\t\t\t\t!isNumber( v[ i ] ) ||\n\t\t\t\tv[ i ] > 1.0 ||\n\t\t\t\tv[ i ] < 0.0\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tsum += v[ i ];\n\t\t}\n\t\treturn ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS );\n\t}\n\tif ( isTypedArray( v ) ) {\n\t\tsum = 0.0;\n\t\tfor ( i = 0; i < v.length; i++ ) {\n\t\t\tif (\n\t\t\t\tv[ i ] > 1.0 ||\n\t\t\t\tv[ i ] < 0.0\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tsum += v[ i ];\n\t\t}\n\t\treturn ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS );\n\t}\n\treturn false;\n}\n\n\n// EXPORTS //\n\nmodule.exports = isUnityProbabilityArray;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Test if a value is an array of probabilities that sum to one.\n*\n* @module @stdlib/assert-is-unity-probability-array\n*\n* @example\n* var isUnityProbabilityArray = require( '@stdlib/assert-is-unity-probability-array' );\n*\n* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] );\n* // returns true\n*\n* bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) );\n* // returns true\n*\n* bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] );\n* // returns false\n*\n* bool = isUnityProbabilityArray( [ 3.14, 0.0 ] );\n* // returns false\n*/\n\n// MODULES //\n\nvar isUnityProbabilityArray = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = isUnityProbabilityArray;\n"],"names":["isTypedArray","require$$0","isArray","require$$1","isNumber","require$$2","isPrimitive","absdiff","require$$3","FLOAT64_SQRT_EPS","require$$4","lib","v","sum","i","length"],"mappings":";;qcAsBA,IAAIA,EAAeC,EACfC,EAAUC,EACVC,EAAWC,EAAsCC,YACjDC,EAAUC,EACVC,EAAmBC,EA+DvB,ICzCAC,EDKA,SAAkCC,GACjC,IAAIC,EACAC,EACJ,GAAKZ,EAASU,GAAM,CAEnB,IADAC,EAAM,EACAC,EAAI,EAAGA,EAAIF,EAAEG,OAAQD,IAAM,CAChC,IACEV,EAAUQ,EAAGE,KACdF,EAAGE,GAAM,GACTF,EAAGE,GAAM,EAET,OAAO,EAERD,GAAOD,EAAGE,GAEX,OAASP,EAASM,EAAK,IAASJ,EAEjC,GAAKT,EAAcY,GAAM,CAExB,IADAC,EAAM,EACAC,EAAI,EAAGA,EAAIF,EAAEG,OAAQD,IAAM,CAChC,GACCF,EAAGE,GAAM,GACTF,EAAGE,GAAM,EAET,OAAO,EAERD,GAAOD,EAAGE,GAEX,OAASP,EAASM,EAAK,IAASJ,EAEjC,OAAO"} \ No newline at end of file diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..1fd022d --- /dev/null +++ b/stats.html @@ -0,0 +1,2689 @@ + + + + + + + + RollUp Visualizer + + + +
+ + + + + From e699aea1742360396109d717440fa140ca20adf8 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 31 May 2022 00:43:54 +0000 Subject: [PATCH 002/133] Auto-generated commit --- .editorconfig | 181 -------- .eslintrc.js | 1 - .gitattributes | 33 -- .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 62 --- .github/workflows/bundle.yml | 504 -------------------- .github/workflows/cancel.yml | 56 --- .github/workflows/close_pull_requests.yml | 44 -- .github/workflows/examples.yml | 62 --- .github/workflows/npm_downloads.yml | 108 ----- .github/workflows/productionize.yml | 160 ------- .github/workflows/publish.yml | 157 ------- .github/workflows/test.yml | 92 ---- .github/workflows/test_bundles.yml | 158 ------- .github/workflows/test_coverage.yml | 123 ----- .github/workflows/test_install.yml | 83 ---- .gitignore | 178 -------- .npmignore | 227 --------- .npmrc | 28 -- CHANGELOG.md | 5 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 ---------------------- README.md | 41 +- benchmark/benchmark.js | 103 ----- branches.md | 53 --- docs/repl.txt | 29 -- docs/types/index.d.ts | 48 -- docs/types/test.ts | 34 -- examples/index.js | 48 -- lib/index.js | 49 -- lib/main.js | 90 ---- package.json | 67 +-- stats.html | 2 +- test/test.js | 106 ----- 35 files changed, 20 insertions(+), 3459 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/bundle.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md 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 delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 0fd4d6c..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 7212d81..0000000 --- a/.gitattributes +++ /dev/null @@ -1,33 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 75a4c32..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/assert/is-unity-probability-array) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index 29bf533..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,62 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/bundle.yml b/.github/workflows/bundle.yml deleted file mode 100644 index f18e58f..0000000 --- a/.github/workflows/bundle.yml +++ /dev/null @@ -1,504 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: bundle - -# Workflow triggers: -on: - # Allow workflow to be manually run: - workflow_dispatch: - - # Run workflow upon completion of `productionize` workflow: - workflow_run: - workflows: ["productionize"] - types: [completed] - -# Workflow jobs: -jobs: - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Checkout production branch: - - name: 'Checkout production branch' - run: | - git fetch --all - git checkout -b production origin/production - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "::set-output name=remote-exists::true" - else - echo "::set-output name=remote-exists::false" - fi - - # If `deno` exists, checkout branch and rebase on `main`: - - name: 'If `deno` exists, checkout branch and rebase on `main`' - if: steps.deno-branch-exists.outputs.remote-exists - continue-on-error: true - run: | - git checkout -b deno origin/deno - git rebase main -s recursive -X ours - while [ $? -ne 0 ]; do - git rebase --skip - done - - # If `deno` does not exist, checkout `main` and create `deno` branch: - - name: 'If `deno` does not exist, checkout `main` and create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout main - git checkout -b deno - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno --force - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - uses: act10ns/slack@v1 - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Checkout production branch: - - name: 'Checkout production branch' - run: | - git fetch --all - git checkout -b production origin/production - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "::set-output name=alias::${alias}" - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -165,7 +158,7 @@ bool = isUnityProbabilityArray( null ); ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -229,9 +222,9 @@ Copyright © 2016-2022. The Stdlib [Authors][stdlib-authors]. -[@stdlib/assert/is-probability]: https://github.com/stdlib-js/assert-is-probability +[@stdlib/assert/is-probability]: https://github.com/stdlib-js/assert-is-probability/tree/esm -[@stdlib/assert/is-probability-array]: https://github.com/stdlib-js/assert-is-probability-array +[@stdlib/assert/is-probability-array]: https://github.com/stdlib-js/assert-is-probability-array/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 8974b71..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,103 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var isUnityProbabilityArray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x; - var i; - - x = []; - for ( i = 0; i < len; i++ ) { - x.push( 1.0/len ); - } - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: we are testing the worst case scenario where a function must scan the entire array before finding a failing value. - x[ len-1 ] = i * 3.14; - bool = isUnityProbabilityArray( x ); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( isBoolean( bool ) ) { - b.pass( 'benchmark finished' ); - } else { - b.fail( 'should return a boolean' ); - } - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':len='+len, f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index 6fcd715..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/assert/is-unity-probability-array" -click B href "https://github.com/stdlib-js/assert-is-unity-probability-array/tree/main" -click C href "https://github.com/stdlib-js/assert-is-unity-probability-array/tree/production" -click D href "https://github.com/stdlib-js/assert-is-unity-probability-array/tree/esm" -click E href "https://github.com/stdlib-js/assert-is-unity-probability-array/tree/deno" -click F href "https://github.com/stdlib-js/assert-is-unity-probability-array/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/assert/is-unity-probability-array -[production-url]: https://github.com/stdlib-js/assert-is-unity-probability-array/tree/production -[deno-url]: https://github.com/stdlib-js/assert-is-unity-probability-array/tree/deno -[umd-url]: https://github.com/stdlib-js/assert-is-unity-probability-array/tree/umd -[esm-url]: https://github.com/stdlib-js/assert-is-unity-probability-array/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index a2414be..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,29 +0,0 @@ - -{{alias}}( value ) - Tests if a value is an array of probabilities that sum to one. - - Parameters - ---------- - value: any - Value to test. - - Returns - ------- - bool: boolean - Boolean indicating whether value is an array of probabilities that sum - to one. - - Examples - -------- - > var bool = {{alias}}( [ 0.25, 0.5, 0.25 ] ) - true - > bool = {{alias}}( new {{alias:@stdlib/array/uint8}}( [ 0, 1 ] ) ) - true - > bool = {{alias}}( [ 0.4, 0.4, 0.4 ] ) - false - > bool = {{alias}}( [ 3.14, 0.0 ] ) - false - - See Also - -------- - diff --git a/docs/types/index.d.ts b/docs/types/index.d.ts deleted file mode 100644 index f77442a..0000000 --- a/docs/types/index.d.ts +++ /dev/null @@ -1,48 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 2.0 - -/** -* Tests if a value is an array of probabilities that sum to one. -* -* @param v - value to test -* @returns boolean indicating if a value is a probability array -* -* @example -* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] ); -* // returns true -* -* @example -* var bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) ); -* // returns true -* -* @example -* var bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] ); -* // returns false -* -* @example -* var bool = isUnityProbabilityArray( [ 3.14, 0.0 ] ); -* // returns false -*/ -declare function isUnityProbabilityArray( v: any ): boolean; - - -// EXPORTS // - -export = isUnityProbabilityArray; diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 4e48f3e..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,34 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import isUnityProbabilityArray = require( './index' ); - - -// TESTS // - -// The function returns a boolean... -{ - isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] ); // $ExpectType boolean - isUnityProbabilityArray( [ 2, 3 ] ); // $ExpectType boolean -} - -// The function does not compile if provided an unsupported number of arguments... -{ - isUnityProbabilityArray(); // $ExpectError - isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ], 123 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index b0b6bbc..0000000 --- a/examples/index.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var Uint8Array = require( '@stdlib/array-uint8' ); -var isUnityProbabilityArray = require( './../lib' ); - -var arr = [ 0.0, 1.0 ]; -console.log( isUnityProbabilityArray( arr ) ); -// => true - -arr = [ 0.5, 0.25, 0.25 ]; -console.log( isUnityProbabilityArray( arr ) ); -// => true - -arr = new Uint8Array( [ 0, 0, 1, 0 ] ); -console.log( isUnityProbabilityArray( arr ) ); -// => true - -arr = [ 0.4, 0.4, 0.4 ]; -console.log( isUnityProbabilityArray( arr ) ); -// => false - -arr = [ 3.14, -1.0 ]; -console.log( isUnityProbabilityArray( arr ) ); -// => false - -console.log( isUnityProbabilityArray( [] ) ); -// => false - -console.log( isUnityProbabilityArray( null ) ); -// => false diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 6bd0b9d..0000000 --- a/lib/index.js +++ /dev/null @@ -1,49 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Test if a value is an array of probabilities that sum to one. -* -* @module @stdlib/assert-is-unity-probability-array -* -* @example -* var isUnityProbabilityArray = require( '@stdlib/assert-is-unity-probability-array' ); -* -* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] ); -* // returns true -* -* bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) ); -* // returns true -* -* bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] ); -* // returns false -* -* bool = isUnityProbabilityArray( [ 3.14, 0.0 ] ); -* // returns false -*/ - -// MODULES // - -var isUnityProbabilityArray = require( './main.js' ); - - -// EXPORTS // - -module.exports = isUnityProbabilityArray; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index d0bda40..0000000 --- a/lib/main.js +++ /dev/null @@ -1,90 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -var isArray = require( '@stdlib/assert-is-array' ); -var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var absdiff = require( '@stdlib/math-base-utils-absolute-difference' ); -var FLOAT64_SQRT_EPS = require( '@stdlib/constants-float64-sqrt-eps' ); - - -// MAIN // - -/** -* Tests if a value is an array of probabilities that sum to one. -* -* @param {*} v - value to test -* @returns {boolean} boolean indicating if a value is a probability array -* -* @example -* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] ); -* // returns true -* -* @example -* var bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) ); -* // returns true -* -* @example -* var bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] ); -* // returns false -* -* @example -* var bool = isUnityProbabilityArray( [ 3.14, 0.0 ] ); -* // returns false -*/ -function isUnityProbabilityArray( v ) { - var sum; - var i; - if ( isArray( v ) ) { - sum = 0.0; - for ( i = 0; i < v.length; i++ ) { - if ( - !isNumber( v[ i ] ) || - v[ i ] > 1.0 || - v[ i ] < 0.0 - ) { - return false; - } - sum += v[ i ]; - } - return ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS ); - } - if ( isTypedArray( v ) ) { - sum = 0.0; - for ( i = 0; i < v.length; i++ ) { - if ( - v[ i ] > 1.0 || - v[ i ] < 0.0 - ) { - return false; - } - sum += v[ i ]; - } - return ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS ); - } - return false; -} - - -// EXPORTS // - -module.exports = isUnityProbabilityArray; diff --git a/package.json b/package.json index 3c769e3..bf1e9c3 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.7", "description": "Test if a value is an array of probabilities that sum to one.", "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" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,46 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-array": "^0.0.x", - "@stdlib/assert-is-number": "^0.0.x", - "@stdlib/assert-is-typed-array": "^0.0.x", - "@stdlib/constants-float64-sqrt-eps": "^0.0.x", - "@stdlib/math-base-utils-absolute-difference": "^0.0.x" - }, - "devDependencies": { - "@stdlib/array-float32": "^0.0.x", - "@stdlib/array-float64": "^0.0.x", - "@stdlib/array-int16": "^0.0.x", - "@stdlib/array-int32": "^0.0.x", - "@stdlib/array-int8": "^0.0.x", - "@stdlib/array-uint16": "^0.0.x", - "@stdlib/array-uint32": "^0.0.x", - "@stdlib/array-uint8": "^0.0.x", - "@stdlib/array-uint8c": "^0.0.x", - "@stdlib/assert-is-boolean": "^0.0.x", - "@stdlib/bench": "^0.0.x", - "@stdlib/buffer-from-array": "^0.0.x", - "@stdlib/math-base-special-pow": "^0.0.x", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-spec": "5.x.x" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdassert", diff --git a/stats.html b/stats.html index 1fd022d..808606a 100644 --- a/stats.html +++ b/stats.html @@ -2669,7 +2669,7 @@ - - - - From 27169de5bab9d453c8d57e0a2f53d635687e9e5a Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Jul 2022 16:56:16 +0000 Subject: [PATCH 005/133] Auto-generated commit --- .editorconfig | 181 -- .eslintrc.js | 1 - .gitattributes | 33 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 62 - .github/workflows/cancel.yml | 56 - .github/workflows/close_pull_requests.yml | 44 - .github/workflows/examples.yml | 62 - .github/workflows/npm_downloads.yml | 108 - .github/workflows/productionize.yml | 681 ------ .github/workflows/publish.yml | 157 -- .github/workflows/test.yml | 92 - .github/workflows/test_bundles.yml | 180 -- .github/workflows/test_coverage.yml | 123 - .github/workflows/test_install.yml | 83 - .gitignore | 178 -- .npmignore | 227 -- .npmrc | 28 - CHANGELOG.md | 5 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 ---- README.md | 41 +- benchmark/benchmark.js | 103 - branches.md | 53 - docs/repl.txt | 29 - docs/types/test.ts | 34 - examples/index.js | 48 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 49 - lib/main.js | 90 - package.json | 70 +- stats.html | 2689 +++++++++++++++++++++ test/test.js | 106 - 37 files changed, 2714 insertions(+), 3452 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 0fd4d6c..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 7212d81..0000000 --- a/.gitattributes +++ /dev/null @@ -1,33 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 46af05a..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2022-07-01T01:31:30.173Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 75a4c32..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/assert/is-unity-probability-array) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index 29bf533..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,62 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index a7a7f51..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,56 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - uses: styfle/cancel-workflow-action@0.9.0 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index a5cb54c..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/assert/is-unity-probability-array) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index 39b1613..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,62 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout the repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index 7ca169c..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,108 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '0 8 * * 6' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "::set-output name=package_name::$name" - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "::set-output name=data::$data" - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - uses: actions/upload-artifact@v2 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - uses: distributhor/workflow-webhook@v2 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 128c22e..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,681 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the repository: - push: - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - uses: actions/checkout@v3 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Format error messages: - - name: 'Replace double quotes with single quotes in rewritten format string error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\( \"([a-zA-Z0-9]+)\"/Error\( format\( '\1'/g" {} \; - - # Format string literal error messages: - - name: 'Replace double quotes with single quotes in rewritten string literal error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\(\"([a-zA-Z0-9]+)\"\)/Error\( format\( '\1' \)/g" {} \; - - # Format code: - - name: 'Replace double quotes with single quotes in inserted `require` calls' - run: | - find . -name "*.js" -exec sed -E -i "s/require\( ?\"@stdlib\/error-tools-fmtprodmsg\" ?\);/require\( '@stdlib\/error-tools-fmtprodmsg' \);/g" {} \; - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\"/\"@stdlib\/error-tools-fmtprodmsg\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^0.0.x'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "::set-output name=remote-exists::true" - else - echo "::set-output name=remote-exists::false" - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs rm -rf - - git add -A - git commit -m "Remove files" - - git merge -s recursive -X theirs origin/production --allow-unrelated-histories - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch or create new branch tag: - - name: 'Push changes to `deno` branch or create new branch tag' - run: | - SLUG=${{ github.repository }} - VERSION=$(echo ${{ github.ref }} | sed -E -n 's/refs\/tags\/?(v[0-9]+.[0-9]+.[0-9]+).*/\1/p') - if [ -z "$VERSION" ]; then - echo "Workflow job was not triggered by a new tag...." - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - else - echo "Workflow job was triggered by a new tag: $VERSION" - echo "Creating new bundle branch tag of the form $VERSION-deno" - git tag -a $VERSION-deno -m "$VERSION-deno" - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" $VERSION-deno - fi - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - uses: act10ns/slack@v1 - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "::set-output name=remote-exists::true" - else - echo "::set-output name=remote-exists::false" - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs rm -rf - - git add -A - git commit -m "Remove files" - - git merge -s recursive -X theirs origin/production --allow-unrelated-histories - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "::set-output name=alias::${alias}" - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -165,7 +158,7 @@ bool = isUnityProbabilityArray( null ); ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -229,9 +222,9 @@ Copyright © 2016-2022. The Stdlib [Authors][stdlib-authors]. -[@stdlib/assert/is-probability]: https://github.com/stdlib-js/assert-is-probability +[@stdlib/assert/is-probability]: https://github.com/stdlib-js/assert-is-probability/tree/esm -[@stdlib/assert/is-probability-array]: https://github.com/stdlib-js/assert-is-probability-array +[@stdlib/assert/is-probability-array]: https://github.com/stdlib-js/assert-is-probability-array/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 8974b71..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,103 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var isUnityProbabilityArray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x; - var i; - - x = []; - for ( i = 0; i < len; i++ ) { - x.push( 1.0/len ); - } - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: we are testing the worst case scenario where a function must scan the entire array before finding a failing value. - x[ len-1 ] = i * 3.14; - bool = isUnityProbabilityArray( x ); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( isBoolean( bool ) ) { - b.pass( 'benchmark finished' ); - } else { - b.fail( 'should return a boolean' ); - } - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':len='+len, f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index 6fcd715..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/assert/is-unity-probability-array" -click B href "https://github.com/stdlib-js/assert-is-unity-probability-array/tree/main" -click C href "https://github.com/stdlib-js/assert-is-unity-probability-array/tree/production" -click D href "https://github.com/stdlib-js/assert-is-unity-probability-array/tree/esm" -click E href "https://github.com/stdlib-js/assert-is-unity-probability-array/tree/deno" -click F href "https://github.com/stdlib-js/assert-is-unity-probability-array/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/assert/is-unity-probability-array -[production-url]: https://github.com/stdlib-js/assert-is-unity-probability-array/tree/production -[deno-url]: https://github.com/stdlib-js/assert-is-unity-probability-array/tree/deno -[umd-url]: https://github.com/stdlib-js/assert-is-unity-probability-array/tree/umd -[esm-url]: https://github.com/stdlib-js/assert-is-unity-probability-array/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index a2414be..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,29 +0,0 @@ - -{{alias}}( value ) - Tests if a value is an array of probabilities that sum to one. - - Parameters - ---------- - value: any - Value to test. - - Returns - ------- - bool: boolean - Boolean indicating whether value is an array of probabilities that sum - to one. - - Examples - -------- - > var bool = {{alias}}( [ 0.25, 0.5, 0.25 ] ) - true - > bool = {{alias}}( new {{alias:@stdlib/array/uint8}}( [ 0, 1 ] ) ) - true - > bool = {{alias}}( [ 0.4, 0.4, 0.4 ] ) - false - > bool = {{alias}}( [ 3.14, 0.0 ] ) - false - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 4e48f3e..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,34 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import isUnityProbabilityArray = require( './index' ); - - -// TESTS // - -// The function returns a boolean... -{ - isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] ); // $ExpectType boolean - isUnityProbabilityArray( [ 2, 3 ] ); // $ExpectType boolean -} - -// The function does not compile if provided an unsupported number of arguments... -{ - isUnityProbabilityArray(); // $ExpectError - isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ], 123 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index b0b6bbc..0000000 --- a/examples/index.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var Uint8Array = require( '@stdlib/array-uint8' ); -var isUnityProbabilityArray = require( './../lib' ); - -var arr = [ 0.0, 1.0 ]; -console.log( isUnityProbabilityArray( arr ) ); -// => true - -arr = [ 0.5, 0.25, 0.25 ]; -console.log( isUnityProbabilityArray( arr ) ); -// => true - -arr = new Uint8Array( [ 0, 0, 1, 0 ] ); -console.log( isUnityProbabilityArray( arr ) ); -// => true - -arr = [ 0.4, 0.4, 0.4 ]; -console.log( isUnityProbabilityArray( arr ) ); -// => false - -arr = [ 3.14, -1.0 ]; -console.log( isUnityProbabilityArray( arr ) ); -// => false - -console.log( isUnityProbabilityArray( [] ) ); -// => false - -console.log( isUnityProbabilityArray( null ) ); -// => false diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..44ce222 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-typed-array@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array@esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-number@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/math-base-utils-absolute-difference@esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/constants-float64-sqrt-eps@esm/index.mjs";function n(n){var d,m;if(t(n)){for(d=0,m=0;m1||n[m]<0)return!1;d+=n[m]}return r(d,1)<=i}if(s(n)){for(d=0,m=0;m1||n[m]<0)return!1;d+=n[m]}return r(d,1)<=i}return!1}export{n as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..0e27c38 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isTypedArray from '@stdlib/assert-is-typed-array' ;\nimport isArray from '@stdlib/assert-is-array' ;\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number' ;\nimport absdiff from '@stdlib/math-base-utils-absolute-difference' ;\nimport FLOAT64_SQRT_EPS from '@stdlib/constants-float64-sqrt-eps' ;\n\n\n// MAIN //\n\n/**\n* Tests if a value is an array of probabilities that sum to one.\n*\n* @param {*} v - value to test\n* @returns {boolean} boolean indicating if a value is a probability array\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] );\n* // returns true\n*\n* @example\n* var bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) );\n* // returns true\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] );\n* // returns false\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 3.14, 0.0 ] );\n* // returns false\n*/\nfunction isUnityProbabilityArray( v ) {\n\tvar sum;\n\tvar i;\n\tif ( isArray( v ) ) {\n\t\tsum = 0.0;\n\t\tfor ( i = 0; i < v.length; i++ ) {\n\t\t\tif (\n\t\t\t\t!isNumber( v[ i ] ) ||\n\t\t\t\tv[ i ] > 1.0 ||\n\t\t\t\tv[ i ] < 0.0\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tsum += v[ i ];\n\t\t}\n\t\treturn ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS );\n\t}\n\tif ( isTypedArray( v ) ) {\n\t\tsum = 0.0;\n\t\tfor ( i = 0; i < v.length; i++ ) {\n\t\t\tif (\n\t\t\t\tv[ i ] > 1.0 ||\n\t\t\t\tv[ i ] < 0.0\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tsum += v[ i ];\n\t\t}\n\t\treturn ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS );\n\t}\n\treturn false;\n}\n\n\n// EXPORTS //\n\nexport default isUnityProbabilityArray;\n"],"names":["isUnityProbabilityArray","v","sum","i","isArray","length","isNumber","absdiff","FLOAT64_SQRT_EPS","isTypedArray"],"mappings":";;odAqDA,SAASA,EAAyBC,GACjC,IAAIC,EACAC,EACJ,GAAKC,EAASH,GAAM,CAEnB,IADAC,EAAM,EACAC,EAAI,EAAGA,EAAIF,EAAEI,OAAQF,IAAM,CAChC,IACEG,EAAUL,EAAGE,KACdF,EAAGE,GAAM,GACTF,EAAGE,GAAM,EAET,OAAO,EAERD,GAAOD,EAAGE,GAEX,OAASI,EAASL,EAAK,IAASM,EAEjC,GAAKC,EAAcR,GAAM,CAExB,IADAC,EAAM,EACAC,EAAI,EAAGA,EAAIF,EAAEI,OAAQF,IAAM,CAChC,GACCF,EAAGE,GAAM,GACTF,EAAGE,GAAM,EAET,OAAO,EAERD,GAAOD,EAAGE,GAEX,OAASI,EAASL,EAAK,IAASM,EAEjC,OAAO"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 6bd0b9d..0000000 --- a/lib/index.js +++ /dev/null @@ -1,49 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Test if a value is an array of probabilities that sum to one. -* -* @module @stdlib/assert-is-unity-probability-array -* -* @example -* var isUnityProbabilityArray = require( '@stdlib/assert-is-unity-probability-array' ); -* -* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] ); -* // returns true -* -* bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) ); -* // returns true -* -* bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] ); -* // returns false -* -* bool = isUnityProbabilityArray( [ 3.14, 0.0 ] ); -* // returns false -*/ - -// MODULES // - -var isUnityProbabilityArray = require( './main.js' ); - - -// EXPORTS // - -module.exports = isUnityProbabilityArray; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index d0bda40..0000000 --- a/lib/main.js +++ /dev/null @@ -1,90 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -var isArray = require( '@stdlib/assert-is-array' ); -var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var absdiff = require( '@stdlib/math-base-utils-absolute-difference' ); -var FLOAT64_SQRT_EPS = require( '@stdlib/constants-float64-sqrt-eps' ); - - -// MAIN // - -/** -* Tests if a value is an array of probabilities that sum to one. -* -* @param {*} v - value to test -* @returns {boolean} boolean indicating if a value is a probability array -* -* @example -* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] ); -* // returns true -* -* @example -* var bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) ); -* // returns true -* -* @example -* var bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] ); -* // returns false -* -* @example -* var bool = isUnityProbabilityArray( [ 3.14, 0.0 ] ); -* // returns false -*/ -function isUnityProbabilityArray( v ) { - var sum; - var i; - if ( isArray( v ) ) { - sum = 0.0; - for ( i = 0; i < v.length; i++ ) { - if ( - !isNumber( v[ i ] ) || - v[ i ] > 1.0 || - v[ i ] < 0.0 - ) { - return false; - } - sum += v[ i ]; - } - return ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS ); - } - if ( isTypedArray( v ) ) { - sum = 0.0; - for ( i = 0; i < v.length; i++ ) { - if ( - v[ i ] > 1.0 || - v[ i ] < 0.0 - ) { - return false; - } - sum += v[ i ]; - } - return ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS ); - } - return false; -} - - -// EXPORTS // - -module.exports = isUnityProbabilityArray; diff --git a/package.json b/package.json index 16e31f9..bf1e9c3 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.7", "description": "Test if a value is an array of probabilities that sum to one.", "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" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,47 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-array": "^0.0.x", - "@stdlib/assert-is-number": "^0.0.x", - "@stdlib/assert-is-typed-array": "^0.0.x", - "@stdlib/constants-float64-sqrt-eps": "^0.0.x", - "@stdlib/math-base-utils-absolute-difference": "^0.0.x", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x" - }, - "devDependencies": { - "@stdlib/array-float32": "^0.0.x", - "@stdlib/array-float64": "^0.0.x", - "@stdlib/array-int16": "^0.0.x", - "@stdlib/array-int32": "^0.0.x", - "@stdlib/array-int8": "^0.0.x", - "@stdlib/array-uint16": "^0.0.x", - "@stdlib/array-uint32": "^0.0.x", - "@stdlib/array-uint8": "^0.0.x", - "@stdlib/array-uint8c": "^0.0.x", - "@stdlib/assert-is-boolean": "^0.0.x", - "@stdlib/bench": "^0.0.x", - "@stdlib/buffer-from-array": "^0.0.x", - "@stdlib/math-base-special-pow": "^0.0.x", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-spec": "5.x.x" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdassert", @@ -105,4 +41,4 @@ "type": "patreon", "url": "https://www.patreon.com/athan" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..23efefe --- /dev/null +++ b/stats.html @@ -0,0 +1,2689 @@ + + + + + + + + RollUp Visualizer + + + +
+ + + + + diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 7f6a066..0000000 --- a/test/test.js +++ /dev/null @@ -1,106 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Int8Array = require( '@stdlib/array-int8' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Float64Array = require( '@stdlib/array-float64' ); -var array2buffer = require( '@stdlib/buffer-from-array' ); -var isUnityProbabilityArray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof isUnityProbabilityArray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns `true` if provided an array of probabilities that sum to one', function test( t ) { - var values; - var i; - - values = [ - new Int8Array( [ 0, 0, 1 ] ), - new Uint8Array( [ 1, 0, 0 ] ), - new Uint8ClampedArray( [ 0, 1 ] ), - new Int16Array( [ 0, 0, 1, 0 ] ), - new Uint16Array( [ 1 ] ), - new Int32Array( [ 1, 0, 0 ] ), - new Uint32Array( [ 0, 1, 0 ] ), - new Float32Array( [ 0.0, 0.5, 0.5 ] ), - new Float64Array( [ 0.25, 0.25, 0.5 ] ), - [ 0.5, 0.25, 0.25 ] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.strictEqual( isUnityProbabilityArray( values[i] ), true, 'returns true when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function allows a difference in sum within floating-point epsilon', function test( t ) { - var bool = isUnityProbabilityArray( [ 0.1, 0.2, 0.1, 0.1, 0.2, 0.2, 0.1 ] ); - t.strictEqual( bool, true, 'returns true' ); - t.end(); -}); - -tape( 'the function returns `false` if not provided an array of probabilities that sum to one', function test( t ) { - var values; - var i; - - values = [ - '10', - '01', - '0.5', - '5', - 5, - NaN, - null, - void 0, - true, - [], - [ 5, null ], - [ 5, '5' ], - [ 1.0, 3.14 ], - [ -1.0, 1.0, 1.0 ], - [ 0.25, 0.33, 0.5 ], - new Float64Array( [ 0.25, 0.33, 0.5 ] ), - new Float64Array( [ 0.25, 1.33, 0.5 ] ), - new Float64Array( [ 0.25, -0.33, 0.5 ] ), - {}, - function noop() {}, - array2buffer( [ 1, 1, 0 ] ) - ]; - - for ( i = 0; i < values.length; i++ ) { - t.strictEqual( isUnityProbabilityArray( values[i] ), false, 'returns false when provided '+values[i] ); - } - t.end(); -}); From 5dce221aa29faa08eab252482efa8d35f7b34ac3 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 4 Jul 2022 17:07:11 +0000 Subject: [PATCH 006/133] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 3c769e3..16e31f9 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,8 @@ "@stdlib/assert-is-number": "^0.0.x", "@stdlib/assert-is-typed-array": "^0.0.x", "@stdlib/constants-float64-sqrt-eps": "^0.0.x", - "@stdlib/math-base-utils-absolute-difference": "^0.0.x" + "@stdlib/math-base-utils-absolute-difference": "^0.0.x", + "@stdlib/error-tools-fmtprodmsg": "^0.0.x" }, "devDependencies": { "@stdlib/array-float32": "^0.0.x", @@ -104,4 +105,4 @@ "type": "patreon", "url": "https://www.patreon.com/athan" } -} +} \ No newline at end of file From 2dc3e77b066867d3a469fcb3197b20f5265e2874 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 4 Jul 2022 19:01:03 +0000 Subject: [PATCH 007/133] Remove files --- index.d.ts | 48 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 2689 ------------------------------------------------- 4 files changed, 2742 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index f77442a..0000000 --- a/index.d.ts +++ /dev/null @@ -1,48 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 2.0 - -/** -* Tests if a value is an array of probabilities that sum to one. -* -* @param v - value to test -* @returns boolean indicating if a value is a probability array -* -* @example -* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] ); -* // returns true -* -* @example -* var bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) ); -* // returns true -* -* @example -* var bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] ); -* // returns false -* -* @example -* var bool = isUnityProbabilityArray( [ 3.14, 0.0 ] ); -* // returns false -*/ -declare function isUnityProbabilityArray( v: any ): boolean; - - -// EXPORTS // - -export = isUnityProbabilityArray; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 44ce222..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-typed-array@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array@esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-number@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/math-base-utils-absolute-difference@esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/constants-float64-sqrt-eps@esm/index.mjs";function n(n){var d,m;if(t(n)){for(d=0,m=0;m1||n[m]<0)return!1;d+=n[m]}return r(d,1)<=i}if(s(n)){for(d=0,m=0;m1||n[m]<0)return!1;d+=n[m]}return r(d,1)<=i}return!1}export{n as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 0e27c38..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isTypedArray from '@stdlib/assert-is-typed-array' ;\nimport isArray from '@stdlib/assert-is-array' ;\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number' ;\nimport absdiff from '@stdlib/math-base-utils-absolute-difference' ;\nimport FLOAT64_SQRT_EPS from '@stdlib/constants-float64-sqrt-eps' ;\n\n\n// MAIN //\n\n/**\n* Tests if a value is an array of probabilities that sum to one.\n*\n* @param {*} v - value to test\n* @returns {boolean} boolean indicating if a value is a probability array\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] );\n* // returns true\n*\n* @example\n* var bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) );\n* // returns true\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] );\n* // returns false\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 3.14, 0.0 ] );\n* // returns false\n*/\nfunction isUnityProbabilityArray( v ) {\n\tvar sum;\n\tvar i;\n\tif ( isArray( v ) ) {\n\t\tsum = 0.0;\n\t\tfor ( i = 0; i < v.length; i++ ) {\n\t\t\tif (\n\t\t\t\t!isNumber( v[ i ] ) ||\n\t\t\t\tv[ i ] > 1.0 ||\n\t\t\t\tv[ i ] < 0.0\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tsum += v[ i ];\n\t\t}\n\t\treturn ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS );\n\t}\n\tif ( isTypedArray( v ) ) {\n\t\tsum = 0.0;\n\t\tfor ( i = 0; i < v.length; i++ ) {\n\t\t\tif (\n\t\t\t\tv[ i ] > 1.0 ||\n\t\t\t\tv[ i ] < 0.0\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tsum += v[ i ];\n\t\t}\n\t\treturn ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS );\n\t}\n\treturn false;\n}\n\n\n// EXPORTS //\n\nexport default isUnityProbabilityArray;\n"],"names":["isUnityProbabilityArray","v","sum","i","isArray","length","isNumber","absdiff","FLOAT64_SQRT_EPS","isTypedArray"],"mappings":";;odAqDA,SAASA,EAAyBC,GACjC,IAAIC,EACAC,EACJ,GAAKC,EAASH,GAAM,CAEnB,IADAC,EAAM,EACAC,EAAI,EAAGA,EAAIF,EAAEI,OAAQF,IAAM,CAChC,IACEG,EAAUL,EAAGE,KACdF,EAAGE,GAAM,GACTF,EAAGE,GAAM,EAET,OAAO,EAERD,GAAOD,EAAGE,GAEX,OAASI,EAASL,EAAK,IAASM,EAEjC,GAAKC,EAAcR,GAAM,CAExB,IADAC,EAAM,EACAC,EAAI,EAAGA,EAAIF,EAAEI,OAAQF,IAAM,CAChC,GACCF,EAAGE,GAAM,GACTF,EAAGE,GAAM,EAET,OAAO,EAERD,GAAOD,EAAGE,GAEX,OAASI,EAASL,EAAK,IAASM,EAEjC,OAAO"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 23efefe..0000000 --- a/stats.html +++ /dev/null @@ -1,2689 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From 1675a1e21304e6a20621a06d25c12892da75ffa7 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 4 Jul 2022 19:01:58 +0000 Subject: [PATCH 008/133] Auto-generated commit --- .editorconfig | 181 -- .eslintrc.js | 1 - .gitattributes | 33 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 62 - .github/workflows/cancel.yml | 56 - .github/workflows/close_pull_requests.yml | 44 - .github/workflows/examples.yml | 62 - .github/workflows/npm_downloads.yml | 108 - .github/workflows/productionize.yml | 687 ------ .github/workflows/publish.yml | 117 - .github/workflows/test.yml | 92 - .github/workflows/test_bundles.yml | 180 -- .github/workflows/test_coverage.yml | 123 - .github/workflows/test_install.yml | 83 - .gitignore | 178 -- .npmignore | 227 -- .npmrc | 28 - CHANGELOG.md | 5 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 ---- README.md | 41 +- benchmark/benchmark.js | 103 - branches.md | 53 - docs/repl.txt | 29 - docs/types/test.ts | 34 - examples/index.js | 48 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 49 - lib/main.js | 90 - package.json | 70 +- stats.html | 2689 +++++++++++++++++++++ test/test.js | 106 - 36 files changed, 2714 insertions(+), 3417 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 0fd4d6c..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 7212d81..0000000 --- a/.gitattributes +++ /dev/null @@ -1,33 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 75a4c32..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/assert/is-unity-probability-array) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index 29bf533..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,62 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index a7a7f51..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,56 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - uses: styfle/cancel-workflow-action@0.9.0 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index a5cb54c..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/assert/is-unity-probability-array) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index 39b1613..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,62 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout the repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index 7ca169c..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,108 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '0 8 * * 6' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "::set-output name=package_name::$name" - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "::set-output name=data::$data" - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - uses: actions/upload-artifact@v2 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - uses: distributhor/workflow-webhook@v2 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 6726965..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,687 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the repository: - push: - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - uses: actions/checkout@v3 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Format error messages: - - name: 'Replace double quotes with single quotes in rewritten format string error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\( \"([a-zA-Z0-9]+)\"/Error\( format\( '\1'/g" {} \; - - # Format string literal error messages: - - name: 'Replace double quotes with single quotes in rewritten string literal error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\(\"([a-zA-Z0-9]+)\"\)/Error\( format\( '\1' \)/g" {} \; - - # Format code: - - name: 'Replace double quotes with single quotes in inserted `require` calls' - run: | - find . -name "*.js" -exec sed -E -i "s/require\( ?\"@stdlib\/error-tools-fmtprodmsg\" ?\);/require\( '@stdlib\/error-tools-fmtprodmsg' \);/g" {} \; - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\"/\"@stdlib\/error-tools-fmtprodmsg\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^0.0.x'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "::set-output name=remote-exists::true" - else - echo "::set-output name=remote-exists::false" - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch or create new branch tag: - - name: 'Push changes to `deno` branch or create new branch tag' - run: | - SLUG=${{ github.repository }} - VERSION=$(echo ${{ github.ref }} | sed -E -n 's/refs\/tags\/?(v[0-9]+.[0-9]+.[0-9]+).*/\1/p') - if [ -z "$VERSION" ]; then - echo "Workflow job was not triggered by a new tag...." - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - else - echo "Workflow job was triggered by a new tag: $VERSION" - echo "Creating new bundle branch tag of the form $VERSION-deno" - git tag -a $VERSION-deno -m "$VERSION-deno" - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" $VERSION-deno - fi - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - uses: act10ns/slack@v1 - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "::set-output name=remote-exists::true" - else - echo "::set-output name=remote-exists::false" - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "::set-output name=alias::${alias}" - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -165,7 +158,7 @@ bool = isUnityProbabilityArray( null ); ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -229,9 +222,9 @@ Copyright © 2016-2022. The Stdlib [Authors][stdlib-authors]. -[@stdlib/assert/is-probability]: https://github.com/stdlib-js/assert-is-probability +[@stdlib/assert/is-probability]: https://github.com/stdlib-js/assert-is-probability/tree/esm -[@stdlib/assert/is-probability-array]: https://github.com/stdlib-js/assert-is-probability-array +[@stdlib/assert/is-probability-array]: https://github.com/stdlib-js/assert-is-probability-array/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 8974b71..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,103 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var isUnityProbabilityArray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x; - var i; - - x = []; - for ( i = 0; i < len; i++ ) { - x.push( 1.0/len ); - } - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: we are testing the worst case scenario where a function must scan the entire array before finding a failing value. - x[ len-1 ] = i * 3.14; - bool = isUnityProbabilityArray( x ); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( isBoolean( bool ) ) { - b.pass( 'benchmark finished' ); - } else { - b.fail( 'should return a boolean' ); - } - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':len='+len, f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index 6fcd715..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/assert/is-unity-probability-array" -click B href "https://github.com/stdlib-js/assert-is-unity-probability-array/tree/main" -click C href "https://github.com/stdlib-js/assert-is-unity-probability-array/tree/production" -click D href "https://github.com/stdlib-js/assert-is-unity-probability-array/tree/esm" -click E href "https://github.com/stdlib-js/assert-is-unity-probability-array/tree/deno" -click F href "https://github.com/stdlib-js/assert-is-unity-probability-array/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/assert/is-unity-probability-array -[production-url]: https://github.com/stdlib-js/assert-is-unity-probability-array/tree/production -[deno-url]: https://github.com/stdlib-js/assert-is-unity-probability-array/tree/deno -[umd-url]: https://github.com/stdlib-js/assert-is-unity-probability-array/tree/umd -[esm-url]: https://github.com/stdlib-js/assert-is-unity-probability-array/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index a2414be..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,29 +0,0 @@ - -{{alias}}( value ) - Tests if a value is an array of probabilities that sum to one. - - Parameters - ---------- - value: any - Value to test. - - Returns - ------- - bool: boolean - Boolean indicating whether value is an array of probabilities that sum - to one. - - Examples - -------- - > var bool = {{alias}}( [ 0.25, 0.5, 0.25 ] ) - true - > bool = {{alias}}( new {{alias:@stdlib/array/uint8}}( [ 0, 1 ] ) ) - true - > bool = {{alias}}( [ 0.4, 0.4, 0.4 ] ) - false - > bool = {{alias}}( [ 3.14, 0.0 ] ) - false - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 4e48f3e..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,34 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import isUnityProbabilityArray = require( './index' ); - - -// TESTS // - -// The function returns a boolean... -{ - isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] ); // $ExpectType boolean - isUnityProbabilityArray( [ 2, 3 ] ); // $ExpectType boolean -} - -// The function does not compile if provided an unsupported number of arguments... -{ - isUnityProbabilityArray(); // $ExpectError - isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ], 123 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index b0b6bbc..0000000 --- a/examples/index.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var Uint8Array = require( '@stdlib/array-uint8' ); -var isUnityProbabilityArray = require( './../lib' ); - -var arr = [ 0.0, 1.0 ]; -console.log( isUnityProbabilityArray( arr ) ); -// => true - -arr = [ 0.5, 0.25, 0.25 ]; -console.log( isUnityProbabilityArray( arr ) ); -// => true - -arr = new Uint8Array( [ 0, 0, 1, 0 ] ); -console.log( isUnityProbabilityArray( arr ) ); -// => true - -arr = [ 0.4, 0.4, 0.4 ]; -console.log( isUnityProbabilityArray( arr ) ); -// => false - -arr = [ 3.14, -1.0 ]; -console.log( isUnityProbabilityArray( arr ) ); -// => false - -console.log( isUnityProbabilityArray( [] ) ); -// => false - -console.log( isUnityProbabilityArray( null ) ); -// => false diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..44ce222 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-typed-array@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array@esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-number@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/math-base-utils-absolute-difference@esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/constants-float64-sqrt-eps@esm/index.mjs";function n(n){var d,m;if(t(n)){for(d=0,m=0;m1||n[m]<0)return!1;d+=n[m]}return r(d,1)<=i}if(s(n)){for(d=0,m=0;m1||n[m]<0)return!1;d+=n[m]}return r(d,1)<=i}return!1}export{n as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..0e27c38 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isTypedArray from '@stdlib/assert-is-typed-array' ;\nimport isArray from '@stdlib/assert-is-array' ;\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number' ;\nimport absdiff from '@stdlib/math-base-utils-absolute-difference' ;\nimport FLOAT64_SQRT_EPS from '@stdlib/constants-float64-sqrt-eps' ;\n\n\n// MAIN //\n\n/**\n* Tests if a value is an array of probabilities that sum to one.\n*\n* @param {*} v - value to test\n* @returns {boolean} boolean indicating if a value is a probability array\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] );\n* // returns true\n*\n* @example\n* var bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) );\n* // returns true\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] );\n* // returns false\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 3.14, 0.0 ] );\n* // returns false\n*/\nfunction isUnityProbabilityArray( v ) {\n\tvar sum;\n\tvar i;\n\tif ( isArray( v ) ) {\n\t\tsum = 0.0;\n\t\tfor ( i = 0; i < v.length; i++ ) {\n\t\t\tif (\n\t\t\t\t!isNumber( v[ i ] ) ||\n\t\t\t\tv[ i ] > 1.0 ||\n\t\t\t\tv[ i ] < 0.0\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tsum += v[ i ];\n\t\t}\n\t\treturn ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS );\n\t}\n\tif ( isTypedArray( v ) ) {\n\t\tsum = 0.0;\n\t\tfor ( i = 0; i < v.length; i++ ) {\n\t\t\tif (\n\t\t\t\tv[ i ] > 1.0 ||\n\t\t\t\tv[ i ] < 0.0\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tsum += v[ i ];\n\t\t}\n\t\treturn ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS );\n\t}\n\treturn false;\n}\n\n\n// EXPORTS //\n\nexport default isUnityProbabilityArray;\n"],"names":["isUnityProbabilityArray","v","sum","i","isArray","length","isNumber","absdiff","FLOAT64_SQRT_EPS","isTypedArray"],"mappings":";;odAqDA,SAASA,EAAyBC,GACjC,IAAIC,EACAC,EACJ,GAAKC,EAASH,GAAM,CAEnB,IADAC,EAAM,EACAC,EAAI,EAAGA,EAAIF,EAAEI,OAAQF,IAAM,CAChC,IACEG,EAAUL,EAAGE,KACdF,EAAGE,GAAM,GACTF,EAAGE,GAAM,EAET,OAAO,EAERD,GAAOD,EAAGE,GAEX,OAASI,EAASL,EAAK,IAASM,EAEjC,GAAKC,EAAcR,GAAM,CAExB,IADAC,EAAM,EACAC,EAAI,EAAGA,EAAIF,EAAEI,OAAQF,IAAM,CAChC,GACCF,EAAGE,GAAM,GACTF,EAAGE,GAAM,EAET,OAAO,EAERD,GAAOD,EAAGE,GAEX,OAASI,EAASL,EAAK,IAASM,EAEjC,OAAO"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 6bd0b9d..0000000 --- a/lib/index.js +++ /dev/null @@ -1,49 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Test if a value is an array of probabilities that sum to one. -* -* @module @stdlib/assert-is-unity-probability-array -* -* @example -* var isUnityProbabilityArray = require( '@stdlib/assert-is-unity-probability-array' ); -* -* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] ); -* // returns true -* -* bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) ); -* // returns true -* -* bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] ); -* // returns false -* -* bool = isUnityProbabilityArray( [ 3.14, 0.0 ] ); -* // returns false -*/ - -// MODULES // - -var isUnityProbabilityArray = require( './main.js' ); - - -// EXPORTS // - -module.exports = isUnityProbabilityArray; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index d0bda40..0000000 --- a/lib/main.js +++ /dev/null @@ -1,90 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -var isArray = require( '@stdlib/assert-is-array' ); -var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var absdiff = require( '@stdlib/math-base-utils-absolute-difference' ); -var FLOAT64_SQRT_EPS = require( '@stdlib/constants-float64-sqrt-eps' ); - - -// MAIN // - -/** -* Tests if a value is an array of probabilities that sum to one. -* -* @param {*} v - value to test -* @returns {boolean} boolean indicating if a value is a probability array -* -* @example -* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] ); -* // returns true -* -* @example -* var bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) ); -* // returns true -* -* @example -* var bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] ); -* // returns false -* -* @example -* var bool = isUnityProbabilityArray( [ 3.14, 0.0 ] ); -* // returns false -*/ -function isUnityProbabilityArray( v ) { - var sum; - var i; - if ( isArray( v ) ) { - sum = 0.0; - for ( i = 0; i < v.length; i++ ) { - if ( - !isNumber( v[ i ] ) || - v[ i ] > 1.0 || - v[ i ] < 0.0 - ) { - return false; - } - sum += v[ i ]; - } - return ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS ); - } - if ( isTypedArray( v ) ) { - sum = 0.0; - for ( i = 0; i < v.length; i++ ) { - if ( - v[ i ] > 1.0 || - v[ i ] < 0.0 - ) { - return false; - } - sum += v[ i ]; - } - return ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS ); - } - return false; -} - - -// EXPORTS // - -module.exports = isUnityProbabilityArray; diff --git a/package.json b/package.json index 16e31f9..bf1e9c3 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.7", "description": "Test if a value is an array of probabilities that sum to one.", "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" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,47 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-array": "^0.0.x", - "@stdlib/assert-is-number": "^0.0.x", - "@stdlib/assert-is-typed-array": "^0.0.x", - "@stdlib/constants-float64-sqrt-eps": "^0.0.x", - "@stdlib/math-base-utils-absolute-difference": "^0.0.x", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x" - }, - "devDependencies": { - "@stdlib/array-float32": "^0.0.x", - "@stdlib/array-float64": "^0.0.x", - "@stdlib/array-int16": "^0.0.x", - "@stdlib/array-int32": "^0.0.x", - "@stdlib/array-int8": "^0.0.x", - "@stdlib/array-uint16": "^0.0.x", - "@stdlib/array-uint32": "^0.0.x", - "@stdlib/array-uint8": "^0.0.x", - "@stdlib/array-uint8c": "^0.0.x", - "@stdlib/assert-is-boolean": "^0.0.x", - "@stdlib/bench": "^0.0.x", - "@stdlib/buffer-from-array": "^0.0.x", - "@stdlib/math-base-special-pow": "^0.0.x", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-spec": "5.x.x" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdassert", @@ -105,4 +41,4 @@ "type": "patreon", "url": "https://www.patreon.com/athan" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..c403c80 --- /dev/null +++ b/stats.html @@ -0,0 +1,2689 @@ + + + + + + + + RollUp Visualizer + + + +
+ + + + + diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 7f6a066..0000000 --- a/test/test.js +++ /dev/null @@ -1,106 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Int8Array = require( '@stdlib/array-int8' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Float64Array = require( '@stdlib/array-float64' ); -var array2buffer = require( '@stdlib/buffer-from-array' ); -var isUnityProbabilityArray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof isUnityProbabilityArray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns `true` if provided an array of probabilities that sum to one', function test( t ) { - var values; - var i; - - values = [ - new Int8Array( [ 0, 0, 1 ] ), - new Uint8Array( [ 1, 0, 0 ] ), - new Uint8ClampedArray( [ 0, 1 ] ), - new Int16Array( [ 0, 0, 1, 0 ] ), - new Uint16Array( [ 1 ] ), - new Int32Array( [ 1, 0, 0 ] ), - new Uint32Array( [ 0, 1, 0 ] ), - new Float32Array( [ 0.0, 0.5, 0.5 ] ), - new Float64Array( [ 0.25, 0.25, 0.5 ] ), - [ 0.5, 0.25, 0.25 ] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.strictEqual( isUnityProbabilityArray( values[i] ), true, 'returns true when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function allows a difference in sum within floating-point epsilon', function test( t ) { - var bool = isUnityProbabilityArray( [ 0.1, 0.2, 0.1, 0.1, 0.2, 0.2, 0.1 ] ); - t.strictEqual( bool, true, 'returns true' ); - t.end(); -}); - -tape( 'the function returns `false` if not provided an array of probabilities that sum to one', function test( t ) { - var values; - var i; - - values = [ - '10', - '01', - '0.5', - '5', - 5, - NaN, - null, - void 0, - true, - [], - [ 5, null ], - [ 5, '5' ], - [ 1.0, 3.14 ], - [ -1.0, 1.0, 1.0 ], - [ 0.25, 0.33, 0.5 ], - new Float64Array( [ 0.25, 0.33, 0.5 ] ), - new Float64Array( [ 0.25, 1.33, 0.5 ] ), - new Float64Array( [ 0.25, -0.33, 0.5 ] ), - {}, - function noop() {}, - array2buffer( [ 1, 1, 0 ] ) - ]; - - for ( i = 0; i < values.length; i++ ) { - t.strictEqual( isUnityProbabilityArray( values[i] ), false, 'returns false when provided '+values[i] ); - } - t.end(); -}); From 90704249daa7488e1c66972fbbdb1ffd1d7063d5 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Aug 2022 03:52:04 +0000 Subject: [PATCH 009/133] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 3c769e3..16e31f9 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,8 @@ "@stdlib/assert-is-number": "^0.0.x", "@stdlib/assert-is-typed-array": "^0.0.x", "@stdlib/constants-float64-sqrt-eps": "^0.0.x", - "@stdlib/math-base-utils-absolute-difference": "^0.0.x" + "@stdlib/math-base-utils-absolute-difference": "^0.0.x", + "@stdlib/error-tools-fmtprodmsg": "^0.0.x" }, "devDependencies": { "@stdlib/array-float32": "^0.0.x", @@ -104,4 +105,4 @@ "type": "patreon", "url": "https://www.patreon.com/athan" } -} +} \ No newline at end of file From e14deddf03db44766053658fad8c1f5456f13edd Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Aug 2022 14:29:40 +0000 Subject: [PATCH 010/133] Remove files --- index.d.ts | 48 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 2689 ------------------------------------------------- 4 files changed, 2742 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index f77442a..0000000 --- a/index.d.ts +++ /dev/null @@ -1,48 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 2.0 - -/** -* Tests if a value is an array of probabilities that sum to one. -* -* @param v - value to test -* @returns boolean indicating if a value is a probability array -* -* @example -* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] ); -* // returns true -* -* @example -* var bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) ); -* // returns true -* -* @example -* var bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] ); -* // returns false -* -* @example -* var bool = isUnityProbabilityArray( [ 3.14, 0.0 ] ); -* // returns false -*/ -declare function isUnityProbabilityArray( v: any ): boolean; - - -// EXPORTS // - -export = isUnityProbabilityArray; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 44ce222..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-typed-array@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array@esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-number@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/math-base-utils-absolute-difference@esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/constants-float64-sqrt-eps@esm/index.mjs";function n(n){var d,m;if(t(n)){for(d=0,m=0;m1||n[m]<0)return!1;d+=n[m]}return r(d,1)<=i}if(s(n)){for(d=0,m=0;m1||n[m]<0)return!1;d+=n[m]}return r(d,1)<=i}return!1}export{n as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 0e27c38..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isTypedArray from '@stdlib/assert-is-typed-array' ;\nimport isArray from '@stdlib/assert-is-array' ;\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number' ;\nimport absdiff from '@stdlib/math-base-utils-absolute-difference' ;\nimport FLOAT64_SQRT_EPS from '@stdlib/constants-float64-sqrt-eps' ;\n\n\n// MAIN //\n\n/**\n* Tests if a value is an array of probabilities that sum to one.\n*\n* @param {*} v - value to test\n* @returns {boolean} boolean indicating if a value is a probability array\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] );\n* // returns true\n*\n* @example\n* var bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) );\n* // returns true\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] );\n* // returns false\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 3.14, 0.0 ] );\n* // returns false\n*/\nfunction isUnityProbabilityArray( v ) {\n\tvar sum;\n\tvar i;\n\tif ( isArray( v ) ) {\n\t\tsum = 0.0;\n\t\tfor ( i = 0; i < v.length; i++ ) {\n\t\t\tif (\n\t\t\t\t!isNumber( v[ i ] ) ||\n\t\t\t\tv[ i ] > 1.0 ||\n\t\t\t\tv[ i ] < 0.0\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tsum += v[ i ];\n\t\t}\n\t\treturn ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS );\n\t}\n\tif ( isTypedArray( v ) ) {\n\t\tsum = 0.0;\n\t\tfor ( i = 0; i < v.length; i++ ) {\n\t\t\tif (\n\t\t\t\tv[ i ] > 1.0 ||\n\t\t\t\tv[ i ] < 0.0\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tsum += v[ i ];\n\t\t}\n\t\treturn ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS );\n\t}\n\treturn false;\n}\n\n\n// EXPORTS //\n\nexport default isUnityProbabilityArray;\n"],"names":["isUnityProbabilityArray","v","sum","i","isArray","length","isNumber","absdiff","FLOAT64_SQRT_EPS","isTypedArray"],"mappings":";;odAqDA,SAASA,EAAyBC,GACjC,IAAIC,EACAC,EACJ,GAAKC,EAASH,GAAM,CAEnB,IADAC,EAAM,EACAC,EAAI,EAAGA,EAAIF,EAAEI,OAAQF,IAAM,CAChC,IACEG,EAAUL,EAAGE,KACdF,EAAGE,GAAM,GACTF,EAAGE,GAAM,EAET,OAAO,EAERD,GAAOD,EAAGE,GAEX,OAASI,EAASL,EAAK,IAASM,EAEjC,GAAKC,EAAcR,GAAM,CAExB,IADAC,EAAM,EACAC,EAAI,EAAGA,EAAIF,EAAEI,OAAQF,IAAM,CAChC,GACCF,EAAGE,GAAM,GACTF,EAAGE,GAAM,EAET,OAAO,EAERD,GAAOD,EAAGE,GAEX,OAASI,EAASL,EAAK,IAASM,EAEjC,OAAO"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index c403c80..0000000 --- a/stats.html +++ /dev/null @@ -1,2689 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From c9d5a45c8e95d7045a09d3ef3388038849fc96a9 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Aug 2022 14:30:27 +0000 Subject: [PATCH 011/133] Auto-generated commit --- .editorconfig | 181 -- .eslintrc.js | 1 - .gitattributes | 33 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 62 - .github/workflows/cancel.yml | 56 - .github/workflows/close_pull_requests.yml | 44 - .github/workflows/examples.yml | 62 - .github/workflows/npm_downloads.yml | 108 - .github/workflows/productionize.yml | 760 ------ .github/workflows/publish.yml | 117 - .github/workflows/test.yml | 92 - .github/workflows/test_bundles.yml | 180 -- .github/workflows/test_coverage.yml | 123 - .github/workflows/test_install.yml | 83 - .gitignore | 178 -- .npmignore | 227 -- .npmrc | 28 - CHANGELOG.md | 5 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 ---- README.md | 41 +- benchmark/benchmark.js | 103 - branches.md | 53 - docs/repl.txt | 29 - docs/types/test.ts | 34 - examples/index.js | 48 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 49 - lib/main.js | 90 - package.json | 70 +- stats.html | 2689 +++++++++++++++++++++ test/test.js | 106 - 37 files changed, 2714 insertions(+), 3491 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 0fd4d6c..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 7212d81..0000000 --- a/.gitattributes +++ /dev/null @@ -1,33 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index fdc1f98..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2022-08-01T01:34:09.675Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 75a4c32..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/assert/is-unity-probability-array) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index 29bf533..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,62 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index a7a7f51..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,56 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - uses: styfle/cancel-workflow-action@0.9.0 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index a5cb54c..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/assert/is-unity-probability-array) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index 39b1613..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,62 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout the repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index 7ca169c..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,108 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '0 8 * * 6' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "::set-output name=package_name::$name" - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "::set-output name=data::$data" - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - uses: actions/upload-artifact@v2 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - uses: distributhor/workflow-webhook@v2 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 5094681..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,760 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - uses: actions/checkout@v3 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Format error messages: - - name: 'Replace double quotes with single quotes in rewritten format string error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\( \"([a-zA-Z0-9]+)\"/Error\( format\( '\1'/g" {} \; - - # Format string literal error messages: - - name: 'Replace double quotes with single quotes in rewritten string literal error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\(\"([a-zA-Z0-9]+)\"\)/Error\( format\( '\1' \)/g" {} \; - - # Format code: - - name: 'Replace double quotes with single quotes in inserted `require` calls' - run: | - find . -name "*.js" -exec sed -E -i "s/require\( ?\"@stdlib\/error-tools-fmtprodmsg\" ?\);/require\( '@stdlib\/error-tools-fmtprodmsg' \);/g" {} \; - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\"/\"@stdlib\/error-tools-fmtprodmsg\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^0.0.x'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "::set-output name=remote-exists::true" - else - echo "::set-output name=remote-exists::false" - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - uses: act10ns/slack@v1 - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "::set-output name=remote-exists::true" - else - echo "::set-output name=remote-exists::false" - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "::set-output name=alias::${alias}" - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -165,7 +158,7 @@ bool = isUnityProbabilityArray( null ); ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -229,9 +222,9 @@ Copyright © 2016-2022. The Stdlib [Authors][stdlib-authors]. -[@stdlib/assert/is-probability]: https://github.com/stdlib-js/assert-is-probability +[@stdlib/assert/is-probability]: https://github.com/stdlib-js/assert-is-probability/tree/esm -[@stdlib/assert/is-probability-array]: https://github.com/stdlib-js/assert-is-probability-array +[@stdlib/assert/is-probability-array]: https://github.com/stdlib-js/assert-is-probability-array/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 8974b71..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,103 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var isUnityProbabilityArray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x; - var i; - - x = []; - for ( i = 0; i < len; i++ ) { - x.push( 1.0/len ); - } - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: we are testing the worst case scenario where a function must scan the entire array before finding a failing value. - x[ len-1 ] = i * 3.14; - bool = isUnityProbabilityArray( x ); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( isBoolean( bool ) ) { - b.pass( 'benchmark finished' ); - } else { - b.fail( 'should return a boolean' ); - } - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':len='+len, f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index 6fcd715..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/assert/is-unity-probability-array" -click B href "https://github.com/stdlib-js/assert-is-unity-probability-array/tree/main" -click C href "https://github.com/stdlib-js/assert-is-unity-probability-array/tree/production" -click D href "https://github.com/stdlib-js/assert-is-unity-probability-array/tree/esm" -click E href "https://github.com/stdlib-js/assert-is-unity-probability-array/tree/deno" -click F href "https://github.com/stdlib-js/assert-is-unity-probability-array/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/assert/is-unity-probability-array -[production-url]: https://github.com/stdlib-js/assert-is-unity-probability-array/tree/production -[deno-url]: https://github.com/stdlib-js/assert-is-unity-probability-array/tree/deno -[umd-url]: https://github.com/stdlib-js/assert-is-unity-probability-array/tree/umd -[esm-url]: https://github.com/stdlib-js/assert-is-unity-probability-array/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index a2414be..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,29 +0,0 @@ - -{{alias}}( value ) - Tests if a value is an array of probabilities that sum to one. - - Parameters - ---------- - value: any - Value to test. - - Returns - ------- - bool: boolean - Boolean indicating whether value is an array of probabilities that sum - to one. - - Examples - -------- - > var bool = {{alias}}( [ 0.25, 0.5, 0.25 ] ) - true - > bool = {{alias}}( new {{alias:@stdlib/array/uint8}}( [ 0, 1 ] ) ) - true - > bool = {{alias}}( [ 0.4, 0.4, 0.4 ] ) - false - > bool = {{alias}}( [ 3.14, 0.0 ] ) - false - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 4e48f3e..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,34 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import isUnityProbabilityArray = require( './index' ); - - -// TESTS // - -// The function returns a boolean... -{ - isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] ); // $ExpectType boolean - isUnityProbabilityArray( [ 2, 3 ] ); // $ExpectType boolean -} - -// The function does not compile if provided an unsupported number of arguments... -{ - isUnityProbabilityArray(); // $ExpectError - isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ], 123 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index b0b6bbc..0000000 --- a/examples/index.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var Uint8Array = require( '@stdlib/array-uint8' ); -var isUnityProbabilityArray = require( './../lib' ); - -var arr = [ 0.0, 1.0 ]; -console.log( isUnityProbabilityArray( arr ) ); -// => true - -arr = [ 0.5, 0.25, 0.25 ]; -console.log( isUnityProbabilityArray( arr ) ); -// => true - -arr = new Uint8Array( [ 0, 0, 1, 0 ] ); -console.log( isUnityProbabilityArray( arr ) ); -// => true - -arr = [ 0.4, 0.4, 0.4 ]; -console.log( isUnityProbabilityArray( arr ) ); -// => false - -arr = [ 3.14, -1.0 ]; -console.log( isUnityProbabilityArray( arr ) ); -// => false - -console.log( isUnityProbabilityArray( [] ) ); -// => false - -console.log( isUnityProbabilityArray( null ) ); -// => false diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..44ce222 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-typed-array@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array@esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-number@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/math-base-utils-absolute-difference@esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/constants-float64-sqrt-eps@esm/index.mjs";function n(n){var d,m;if(t(n)){for(d=0,m=0;m1||n[m]<0)return!1;d+=n[m]}return r(d,1)<=i}if(s(n)){for(d=0,m=0;m1||n[m]<0)return!1;d+=n[m]}return r(d,1)<=i}return!1}export{n as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..0e27c38 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isTypedArray from '@stdlib/assert-is-typed-array' ;\nimport isArray from '@stdlib/assert-is-array' ;\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number' ;\nimport absdiff from '@stdlib/math-base-utils-absolute-difference' ;\nimport FLOAT64_SQRT_EPS from '@stdlib/constants-float64-sqrt-eps' ;\n\n\n// MAIN //\n\n/**\n* Tests if a value is an array of probabilities that sum to one.\n*\n* @param {*} v - value to test\n* @returns {boolean} boolean indicating if a value is a probability array\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] );\n* // returns true\n*\n* @example\n* var bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) );\n* // returns true\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] );\n* // returns false\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 3.14, 0.0 ] );\n* // returns false\n*/\nfunction isUnityProbabilityArray( v ) {\n\tvar sum;\n\tvar i;\n\tif ( isArray( v ) ) {\n\t\tsum = 0.0;\n\t\tfor ( i = 0; i < v.length; i++ ) {\n\t\t\tif (\n\t\t\t\t!isNumber( v[ i ] ) ||\n\t\t\t\tv[ i ] > 1.0 ||\n\t\t\t\tv[ i ] < 0.0\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tsum += v[ i ];\n\t\t}\n\t\treturn ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS );\n\t}\n\tif ( isTypedArray( v ) ) {\n\t\tsum = 0.0;\n\t\tfor ( i = 0; i < v.length; i++ ) {\n\t\t\tif (\n\t\t\t\tv[ i ] > 1.0 ||\n\t\t\t\tv[ i ] < 0.0\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tsum += v[ i ];\n\t\t}\n\t\treturn ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS );\n\t}\n\treturn false;\n}\n\n\n// EXPORTS //\n\nexport default isUnityProbabilityArray;\n"],"names":["isUnityProbabilityArray","v","sum","i","isArray","length","isNumber","absdiff","FLOAT64_SQRT_EPS","isTypedArray"],"mappings":";;odAqDA,SAASA,EAAyBC,GACjC,IAAIC,EACAC,EACJ,GAAKC,EAASH,GAAM,CAEnB,IADAC,EAAM,EACAC,EAAI,EAAGA,EAAIF,EAAEI,OAAQF,IAAM,CAChC,IACEG,EAAUL,EAAGE,KACdF,EAAGE,GAAM,GACTF,EAAGE,GAAM,EAET,OAAO,EAERD,GAAOD,EAAGE,GAEX,OAASI,EAASL,EAAK,IAASM,EAEjC,GAAKC,EAAcR,GAAM,CAExB,IADAC,EAAM,EACAC,EAAI,EAAGA,EAAIF,EAAEI,OAAQF,IAAM,CAChC,GACCF,EAAGE,GAAM,GACTF,EAAGE,GAAM,EAET,OAAO,EAERD,GAAOD,EAAGE,GAEX,OAASI,EAASL,EAAK,IAASM,EAEjC,OAAO"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 6bd0b9d..0000000 --- a/lib/index.js +++ /dev/null @@ -1,49 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Test if a value is an array of probabilities that sum to one. -* -* @module @stdlib/assert-is-unity-probability-array -* -* @example -* var isUnityProbabilityArray = require( '@stdlib/assert-is-unity-probability-array' ); -* -* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] ); -* // returns true -* -* bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) ); -* // returns true -* -* bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] ); -* // returns false -* -* bool = isUnityProbabilityArray( [ 3.14, 0.0 ] ); -* // returns false -*/ - -// MODULES // - -var isUnityProbabilityArray = require( './main.js' ); - - -// EXPORTS // - -module.exports = isUnityProbabilityArray; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index d0bda40..0000000 --- a/lib/main.js +++ /dev/null @@ -1,90 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -var isArray = require( '@stdlib/assert-is-array' ); -var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var absdiff = require( '@stdlib/math-base-utils-absolute-difference' ); -var FLOAT64_SQRT_EPS = require( '@stdlib/constants-float64-sqrt-eps' ); - - -// MAIN // - -/** -* Tests if a value is an array of probabilities that sum to one. -* -* @param {*} v - value to test -* @returns {boolean} boolean indicating if a value is a probability array -* -* @example -* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] ); -* // returns true -* -* @example -* var bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) ); -* // returns true -* -* @example -* var bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] ); -* // returns false -* -* @example -* var bool = isUnityProbabilityArray( [ 3.14, 0.0 ] ); -* // returns false -*/ -function isUnityProbabilityArray( v ) { - var sum; - var i; - if ( isArray( v ) ) { - sum = 0.0; - for ( i = 0; i < v.length; i++ ) { - if ( - !isNumber( v[ i ] ) || - v[ i ] > 1.0 || - v[ i ] < 0.0 - ) { - return false; - } - sum += v[ i ]; - } - return ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS ); - } - if ( isTypedArray( v ) ) { - sum = 0.0; - for ( i = 0; i < v.length; i++ ) { - if ( - v[ i ] > 1.0 || - v[ i ] < 0.0 - ) { - return false; - } - sum += v[ i ]; - } - return ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS ); - } - return false; -} - - -// EXPORTS // - -module.exports = isUnityProbabilityArray; diff --git a/package.json b/package.json index 16e31f9..bf1e9c3 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.7", "description": "Test if a value is an array of probabilities that sum to one.", "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" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,47 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-array": "^0.0.x", - "@stdlib/assert-is-number": "^0.0.x", - "@stdlib/assert-is-typed-array": "^0.0.x", - "@stdlib/constants-float64-sqrt-eps": "^0.0.x", - "@stdlib/math-base-utils-absolute-difference": "^0.0.x", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x" - }, - "devDependencies": { - "@stdlib/array-float32": "^0.0.x", - "@stdlib/array-float64": "^0.0.x", - "@stdlib/array-int16": "^0.0.x", - "@stdlib/array-int32": "^0.0.x", - "@stdlib/array-int8": "^0.0.x", - "@stdlib/array-uint16": "^0.0.x", - "@stdlib/array-uint32": "^0.0.x", - "@stdlib/array-uint8": "^0.0.x", - "@stdlib/array-uint8c": "^0.0.x", - "@stdlib/assert-is-boolean": "^0.0.x", - "@stdlib/bench": "^0.0.x", - "@stdlib/buffer-from-array": "^0.0.x", - "@stdlib/math-base-special-pow": "^0.0.x", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-spec": "5.x.x" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdassert", @@ -105,4 +41,4 @@ "type": "patreon", "url": "https://www.patreon.com/athan" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..eae460e --- /dev/null +++ b/stats.html @@ -0,0 +1,2689 @@ + + + + + + + + RollUp Visualizer + + + +
+ + + + + diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 7f6a066..0000000 --- a/test/test.js +++ /dev/null @@ -1,106 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Int8Array = require( '@stdlib/array-int8' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Float64Array = require( '@stdlib/array-float64' ); -var array2buffer = require( '@stdlib/buffer-from-array' ); -var isUnityProbabilityArray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof isUnityProbabilityArray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns `true` if provided an array of probabilities that sum to one', function test( t ) { - var values; - var i; - - values = [ - new Int8Array( [ 0, 0, 1 ] ), - new Uint8Array( [ 1, 0, 0 ] ), - new Uint8ClampedArray( [ 0, 1 ] ), - new Int16Array( [ 0, 0, 1, 0 ] ), - new Uint16Array( [ 1 ] ), - new Int32Array( [ 1, 0, 0 ] ), - new Uint32Array( [ 0, 1, 0 ] ), - new Float32Array( [ 0.0, 0.5, 0.5 ] ), - new Float64Array( [ 0.25, 0.25, 0.5 ] ), - [ 0.5, 0.25, 0.25 ] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.strictEqual( isUnityProbabilityArray( values[i] ), true, 'returns true when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function allows a difference in sum within floating-point epsilon', function test( t ) { - var bool = isUnityProbabilityArray( [ 0.1, 0.2, 0.1, 0.1, 0.2, 0.2, 0.1 ] ); - t.strictEqual( bool, true, 'returns true' ); - t.end(); -}); - -tape( 'the function returns `false` if not provided an array of probabilities that sum to one', function test( t ) { - var values; - var i; - - values = [ - '10', - '01', - '0.5', - '5', - 5, - NaN, - null, - void 0, - true, - [], - [ 5, null ], - [ 5, '5' ], - [ 1.0, 3.14 ], - [ -1.0, 1.0, 1.0 ], - [ 0.25, 0.33, 0.5 ], - new Float64Array( [ 0.25, 0.33, 0.5 ] ), - new Float64Array( [ 0.25, 1.33, 0.5 ] ), - new Float64Array( [ 0.25, -0.33, 0.5 ] ), - {}, - function noop() {}, - array2buffer( [ 1, 1, 0 ] ) - ]; - - for ( i = 0; i < values.length; i++ ) { - t.strictEqual( isUnityProbabilityArray( values[i] ), false, 'returns false when provided '+values[i] ); - } - t.end(); -}); From 97c364628254f978003449ee62940efd0c08635a Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Sep 2022 03:43:17 +0000 Subject: [PATCH 012/133] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 3c769e3..16e31f9 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,8 @@ "@stdlib/assert-is-number": "^0.0.x", "@stdlib/assert-is-typed-array": "^0.0.x", "@stdlib/constants-float64-sqrt-eps": "^0.0.x", - "@stdlib/math-base-utils-absolute-difference": "^0.0.x" + "@stdlib/math-base-utils-absolute-difference": "^0.0.x", + "@stdlib/error-tools-fmtprodmsg": "^0.0.x" }, "devDependencies": { "@stdlib/array-float32": "^0.0.x", @@ -104,4 +105,4 @@ "type": "patreon", "url": "https://www.patreon.com/athan" } -} +} \ No newline at end of file From f8883aae24fa59167c96483a349c2f67acb66c87 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Sep 2022 11:04:03 +0000 Subject: [PATCH 013/133] Remove files --- index.d.ts | 48 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 2689 ------------------------------------------------- 4 files changed, 2742 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index f77442a..0000000 --- a/index.d.ts +++ /dev/null @@ -1,48 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 2.0 - -/** -* Tests if a value is an array of probabilities that sum to one. -* -* @param v - value to test -* @returns boolean indicating if a value is a probability array -* -* @example -* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] ); -* // returns true -* -* @example -* var bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) ); -* // returns true -* -* @example -* var bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] ); -* // returns false -* -* @example -* var bool = isUnityProbabilityArray( [ 3.14, 0.0 ] ); -* // returns false -*/ -declare function isUnityProbabilityArray( v: any ): boolean; - - -// EXPORTS // - -export = isUnityProbabilityArray; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 44ce222..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-typed-array@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array@esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-number@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/math-base-utils-absolute-difference@esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/constants-float64-sqrt-eps@esm/index.mjs";function n(n){var d,m;if(t(n)){for(d=0,m=0;m1||n[m]<0)return!1;d+=n[m]}return r(d,1)<=i}if(s(n)){for(d=0,m=0;m1||n[m]<0)return!1;d+=n[m]}return r(d,1)<=i}return!1}export{n as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 0e27c38..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isTypedArray from '@stdlib/assert-is-typed-array' ;\nimport isArray from '@stdlib/assert-is-array' ;\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number' ;\nimport absdiff from '@stdlib/math-base-utils-absolute-difference' ;\nimport FLOAT64_SQRT_EPS from '@stdlib/constants-float64-sqrt-eps' ;\n\n\n// MAIN //\n\n/**\n* Tests if a value is an array of probabilities that sum to one.\n*\n* @param {*} v - value to test\n* @returns {boolean} boolean indicating if a value is a probability array\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] );\n* // returns true\n*\n* @example\n* var bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) );\n* // returns true\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] );\n* // returns false\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 3.14, 0.0 ] );\n* // returns false\n*/\nfunction isUnityProbabilityArray( v ) {\n\tvar sum;\n\tvar i;\n\tif ( isArray( v ) ) {\n\t\tsum = 0.0;\n\t\tfor ( i = 0; i < v.length; i++ ) {\n\t\t\tif (\n\t\t\t\t!isNumber( v[ i ] ) ||\n\t\t\t\tv[ i ] > 1.0 ||\n\t\t\t\tv[ i ] < 0.0\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tsum += v[ i ];\n\t\t}\n\t\treturn ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS );\n\t}\n\tif ( isTypedArray( v ) ) {\n\t\tsum = 0.0;\n\t\tfor ( i = 0; i < v.length; i++ ) {\n\t\t\tif (\n\t\t\t\tv[ i ] > 1.0 ||\n\t\t\t\tv[ i ] < 0.0\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tsum += v[ i ];\n\t\t}\n\t\treturn ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS );\n\t}\n\treturn false;\n}\n\n\n// EXPORTS //\n\nexport default isUnityProbabilityArray;\n"],"names":["isUnityProbabilityArray","v","sum","i","isArray","length","isNumber","absdiff","FLOAT64_SQRT_EPS","isTypedArray"],"mappings":";;odAqDA,SAASA,EAAyBC,GACjC,IAAIC,EACAC,EACJ,GAAKC,EAASH,GAAM,CAEnB,IADAC,EAAM,EACAC,EAAI,EAAGA,EAAIF,EAAEI,OAAQF,IAAM,CAChC,IACEG,EAAUL,EAAGE,KACdF,EAAGE,GAAM,GACTF,EAAGE,GAAM,EAET,OAAO,EAERD,GAAOD,EAAGE,GAEX,OAASI,EAASL,EAAK,IAASM,EAEjC,GAAKC,EAAcR,GAAM,CAExB,IADAC,EAAM,EACAC,EAAI,EAAGA,EAAIF,EAAEI,OAAQF,IAAM,CAChC,GACCF,EAAGE,GAAM,GACTF,EAAGE,GAAM,EAET,OAAO,EAERD,GAAOD,EAAGE,GAEX,OAASI,EAASL,EAAK,IAASM,EAEjC,OAAO"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index eae460e..0000000 --- a/stats.html +++ /dev/null @@ -1,2689 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From 90dba1a77513d15176e54d1f899100a0aafdff9e Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Sep 2022 11:04:46 +0000 Subject: [PATCH 014/133] Auto-generated commit --- .editorconfig | 181 -- .eslintrc.js | 1 - .gitattributes | 49 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 62 - .github/workflows/cancel.yml | 56 - .github/workflows/close_pull_requests.yml | 44 - .github/workflows/examples.yml | 62 - .github/workflows/npm_downloads.yml | 108 - .github/workflows/productionize.yml | 760 ------ .github/workflows/publish.yml | 117 - .github/workflows/test.yml | 92 - .github/workflows/test_bundles.yml | 180 -- .github/workflows/test_coverage.yml | 123 - .github/workflows/test_install.yml | 83 - .gitignore | 178 -- .npmignore | 227 -- .npmrc | 28 - CHANGELOG.md | 5 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 ---- README.md | 41 +- benchmark/benchmark.js | 103 - branches.md | 53 - docs/repl.txt | 29 - docs/types/test.ts | 34 - examples/index.js | 48 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 49 - lib/main.js | 90 - package.json | 70 +- stats.html | 2689 +++++++++++++++++++++ test/test.js | 106 - 37 files changed, 2714 insertions(+), 3507 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 0fd4d6c..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 1001f1f..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2022-09-01T01:33:21.328Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 75a4c32..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/assert/is-unity-probability-array) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index 29bf533..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,62 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index a7a7f51..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,56 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - uses: styfle/cancel-workflow-action@0.9.0 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index a5cb54c..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/assert/is-unity-probability-array) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index 39b1613..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,62 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout the repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index 7ca169c..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,108 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '0 8 * * 6' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "::set-output name=package_name::$name" - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "::set-output name=data::$data" - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - uses: actions/upload-artifact@v2 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - uses: distributhor/workflow-webhook@v2 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 5094681..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,760 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - uses: actions/checkout@v3 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Format error messages: - - name: 'Replace double quotes with single quotes in rewritten format string error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\( \"([a-zA-Z0-9]+)\"/Error\( format\( '\1'/g" {} \; - - # Format string literal error messages: - - name: 'Replace double quotes with single quotes in rewritten string literal error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\(\"([a-zA-Z0-9]+)\"\)/Error\( format\( '\1' \)/g" {} \; - - # Format code: - - name: 'Replace double quotes with single quotes in inserted `require` calls' - run: | - find . -name "*.js" -exec sed -E -i "s/require\( ?\"@stdlib\/error-tools-fmtprodmsg\" ?\);/require\( '@stdlib\/error-tools-fmtprodmsg' \);/g" {} \; - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\"/\"@stdlib\/error-tools-fmtprodmsg\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^0.0.x'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "::set-output name=remote-exists::true" - else - echo "::set-output name=remote-exists::false" - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - uses: act10ns/slack@v1 - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "::set-output name=remote-exists::true" - else - echo "::set-output name=remote-exists::false" - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "::set-output name=alias::${alias}" - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -165,7 +158,7 @@ bool = isUnityProbabilityArray( null ); ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -229,9 +222,9 @@ Copyright © 2016-2022. The Stdlib [Authors][stdlib-authors]. -[@stdlib/assert/is-probability]: https://github.com/stdlib-js/assert-is-probability +[@stdlib/assert/is-probability]: https://github.com/stdlib-js/assert-is-probability/tree/esm -[@stdlib/assert/is-probability-array]: https://github.com/stdlib-js/assert-is-probability-array +[@stdlib/assert/is-probability-array]: https://github.com/stdlib-js/assert-is-probability-array/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 8974b71..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,103 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var isUnityProbabilityArray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x; - var i; - - x = []; - for ( i = 0; i < len; i++ ) { - x.push( 1.0/len ); - } - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: we are testing the worst case scenario where a function must scan the entire array before finding a failing value. - x[ len-1 ] = i * 3.14; - bool = isUnityProbabilityArray( x ); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( isBoolean( bool ) ) { - b.pass( 'benchmark finished' ); - } else { - b.fail( 'should return a boolean' ); - } - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':len='+len, f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index 6fcd715..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/assert/is-unity-probability-array" -click B href "https://github.com/stdlib-js/assert-is-unity-probability-array/tree/main" -click C href "https://github.com/stdlib-js/assert-is-unity-probability-array/tree/production" -click D href "https://github.com/stdlib-js/assert-is-unity-probability-array/tree/esm" -click E href "https://github.com/stdlib-js/assert-is-unity-probability-array/tree/deno" -click F href "https://github.com/stdlib-js/assert-is-unity-probability-array/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/assert/is-unity-probability-array -[production-url]: https://github.com/stdlib-js/assert-is-unity-probability-array/tree/production -[deno-url]: https://github.com/stdlib-js/assert-is-unity-probability-array/tree/deno -[umd-url]: https://github.com/stdlib-js/assert-is-unity-probability-array/tree/umd -[esm-url]: https://github.com/stdlib-js/assert-is-unity-probability-array/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index a2414be..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,29 +0,0 @@ - -{{alias}}( value ) - Tests if a value is an array of probabilities that sum to one. - - Parameters - ---------- - value: any - Value to test. - - Returns - ------- - bool: boolean - Boolean indicating whether value is an array of probabilities that sum - to one. - - Examples - -------- - > var bool = {{alias}}( [ 0.25, 0.5, 0.25 ] ) - true - > bool = {{alias}}( new {{alias:@stdlib/array/uint8}}( [ 0, 1 ] ) ) - true - > bool = {{alias}}( [ 0.4, 0.4, 0.4 ] ) - false - > bool = {{alias}}( [ 3.14, 0.0 ] ) - false - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 4e48f3e..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,34 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import isUnityProbabilityArray = require( './index' ); - - -// TESTS // - -// The function returns a boolean... -{ - isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] ); // $ExpectType boolean - isUnityProbabilityArray( [ 2, 3 ] ); // $ExpectType boolean -} - -// The function does not compile if provided an unsupported number of arguments... -{ - isUnityProbabilityArray(); // $ExpectError - isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ], 123 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index b0b6bbc..0000000 --- a/examples/index.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var Uint8Array = require( '@stdlib/array-uint8' ); -var isUnityProbabilityArray = require( './../lib' ); - -var arr = [ 0.0, 1.0 ]; -console.log( isUnityProbabilityArray( arr ) ); -// => true - -arr = [ 0.5, 0.25, 0.25 ]; -console.log( isUnityProbabilityArray( arr ) ); -// => true - -arr = new Uint8Array( [ 0, 0, 1, 0 ] ); -console.log( isUnityProbabilityArray( arr ) ); -// => true - -arr = [ 0.4, 0.4, 0.4 ]; -console.log( isUnityProbabilityArray( arr ) ); -// => false - -arr = [ 3.14, -1.0 ]; -console.log( isUnityProbabilityArray( arr ) ); -// => false - -console.log( isUnityProbabilityArray( [] ) ); -// => false - -console.log( isUnityProbabilityArray( null ) ); -// => false diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..44ce222 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-typed-array@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array@esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-number@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/math-base-utils-absolute-difference@esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/constants-float64-sqrt-eps@esm/index.mjs";function n(n){var d,m;if(t(n)){for(d=0,m=0;m1||n[m]<0)return!1;d+=n[m]}return r(d,1)<=i}if(s(n)){for(d=0,m=0;m1||n[m]<0)return!1;d+=n[m]}return r(d,1)<=i}return!1}export{n as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..0e27c38 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isTypedArray from '@stdlib/assert-is-typed-array' ;\nimport isArray from '@stdlib/assert-is-array' ;\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number' ;\nimport absdiff from '@stdlib/math-base-utils-absolute-difference' ;\nimport FLOAT64_SQRT_EPS from '@stdlib/constants-float64-sqrt-eps' ;\n\n\n// MAIN //\n\n/**\n* Tests if a value is an array of probabilities that sum to one.\n*\n* @param {*} v - value to test\n* @returns {boolean} boolean indicating if a value is a probability array\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] );\n* // returns true\n*\n* @example\n* var bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) );\n* // returns true\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] );\n* // returns false\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 3.14, 0.0 ] );\n* // returns false\n*/\nfunction isUnityProbabilityArray( v ) {\n\tvar sum;\n\tvar i;\n\tif ( isArray( v ) ) {\n\t\tsum = 0.0;\n\t\tfor ( i = 0; i < v.length; i++ ) {\n\t\t\tif (\n\t\t\t\t!isNumber( v[ i ] ) ||\n\t\t\t\tv[ i ] > 1.0 ||\n\t\t\t\tv[ i ] < 0.0\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tsum += v[ i ];\n\t\t}\n\t\treturn ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS );\n\t}\n\tif ( isTypedArray( v ) ) {\n\t\tsum = 0.0;\n\t\tfor ( i = 0; i < v.length; i++ ) {\n\t\t\tif (\n\t\t\t\tv[ i ] > 1.0 ||\n\t\t\t\tv[ i ] < 0.0\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tsum += v[ i ];\n\t\t}\n\t\treturn ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS );\n\t}\n\treturn false;\n}\n\n\n// EXPORTS //\n\nexport default isUnityProbabilityArray;\n"],"names":["isUnityProbabilityArray","v","sum","i","isArray","length","isNumber","absdiff","FLOAT64_SQRT_EPS","isTypedArray"],"mappings":";;odAqDA,SAASA,EAAyBC,GACjC,IAAIC,EACAC,EACJ,GAAKC,EAASH,GAAM,CAEnB,IADAC,EAAM,EACAC,EAAI,EAAGA,EAAIF,EAAEI,OAAQF,IAAM,CAChC,IACEG,EAAUL,EAAGE,KACdF,EAAGE,GAAM,GACTF,EAAGE,GAAM,EAET,OAAO,EAERD,GAAOD,EAAGE,GAEX,OAASI,EAASL,EAAK,IAASM,EAEjC,GAAKC,EAAcR,GAAM,CAExB,IADAC,EAAM,EACAC,EAAI,EAAGA,EAAIF,EAAEI,OAAQF,IAAM,CAChC,GACCF,EAAGE,GAAM,GACTF,EAAGE,GAAM,EAET,OAAO,EAERD,GAAOD,EAAGE,GAEX,OAASI,EAASL,EAAK,IAASM,EAEjC,OAAO"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 6bd0b9d..0000000 --- a/lib/index.js +++ /dev/null @@ -1,49 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Test if a value is an array of probabilities that sum to one. -* -* @module @stdlib/assert-is-unity-probability-array -* -* @example -* var isUnityProbabilityArray = require( '@stdlib/assert-is-unity-probability-array' ); -* -* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] ); -* // returns true -* -* bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) ); -* // returns true -* -* bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] ); -* // returns false -* -* bool = isUnityProbabilityArray( [ 3.14, 0.0 ] ); -* // returns false -*/ - -// MODULES // - -var isUnityProbabilityArray = require( './main.js' ); - - -// EXPORTS // - -module.exports = isUnityProbabilityArray; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index d0bda40..0000000 --- a/lib/main.js +++ /dev/null @@ -1,90 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -var isArray = require( '@stdlib/assert-is-array' ); -var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var absdiff = require( '@stdlib/math-base-utils-absolute-difference' ); -var FLOAT64_SQRT_EPS = require( '@stdlib/constants-float64-sqrt-eps' ); - - -// MAIN // - -/** -* Tests if a value is an array of probabilities that sum to one. -* -* @param {*} v - value to test -* @returns {boolean} boolean indicating if a value is a probability array -* -* @example -* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] ); -* // returns true -* -* @example -* var bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) ); -* // returns true -* -* @example -* var bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] ); -* // returns false -* -* @example -* var bool = isUnityProbabilityArray( [ 3.14, 0.0 ] ); -* // returns false -*/ -function isUnityProbabilityArray( v ) { - var sum; - var i; - if ( isArray( v ) ) { - sum = 0.0; - for ( i = 0; i < v.length; i++ ) { - if ( - !isNumber( v[ i ] ) || - v[ i ] > 1.0 || - v[ i ] < 0.0 - ) { - return false; - } - sum += v[ i ]; - } - return ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS ); - } - if ( isTypedArray( v ) ) { - sum = 0.0; - for ( i = 0; i < v.length; i++ ) { - if ( - v[ i ] > 1.0 || - v[ i ] < 0.0 - ) { - return false; - } - sum += v[ i ]; - } - return ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS ); - } - return false; -} - - -// EXPORTS // - -module.exports = isUnityProbabilityArray; diff --git a/package.json b/package.json index 16e31f9..bf1e9c3 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.7", "description": "Test if a value is an array of probabilities that sum to one.", "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" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,47 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-array": "^0.0.x", - "@stdlib/assert-is-number": "^0.0.x", - "@stdlib/assert-is-typed-array": "^0.0.x", - "@stdlib/constants-float64-sqrt-eps": "^0.0.x", - "@stdlib/math-base-utils-absolute-difference": "^0.0.x", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x" - }, - "devDependencies": { - "@stdlib/array-float32": "^0.0.x", - "@stdlib/array-float64": "^0.0.x", - "@stdlib/array-int16": "^0.0.x", - "@stdlib/array-int32": "^0.0.x", - "@stdlib/array-int8": "^0.0.x", - "@stdlib/array-uint16": "^0.0.x", - "@stdlib/array-uint32": "^0.0.x", - "@stdlib/array-uint8": "^0.0.x", - "@stdlib/array-uint8c": "^0.0.x", - "@stdlib/assert-is-boolean": "^0.0.x", - "@stdlib/bench": "^0.0.x", - "@stdlib/buffer-from-array": "^0.0.x", - "@stdlib/math-base-special-pow": "^0.0.x", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-spec": "5.x.x" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdassert", @@ -105,4 +41,4 @@ "type": "patreon", "url": "https://www.patreon.com/athan" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..93479b4 --- /dev/null +++ b/stats.html @@ -0,0 +1,2689 @@ + + + + + + + + RollUp Visualizer + + + +
+ + + + + diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 7f6a066..0000000 --- a/test/test.js +++ /dev/null @@ -1,106 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Int8Array = require( '@stdlib/array-int8' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Float64Array = require( '@stdlib/array-float64' ); -var array2buffer = require( '@stdlib/buffer-from-array' ); -var isUnityProbabilityArray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof isUnityProbabilityArray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns `true` if provided an array of probabilities that sum to one', function test( t ) { - var values; - var i; - - values = [ - new Int8Array( [ 0, 0, 1 ] ), - new Uint8Array( [ 1, 0, 0 ] ), - new Uint8ClampedArray( [ 0, 1 ] ), - new Int16Array( [ 0, 0, 1, 0 ] ), - new Uint16Array( [ 1 ] ), - new Int32Array( [ 1, 0, 0 ] ), - new Uint32Array( [ 0, 1, 0 ] ), - new Float32Array( [ 0.0, 0.5, 0.5 ] ), - new Float64Array( [ 0.25, 0.25, 0.5 ] ), - [ 0.5, 0.25, 0.25 ] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.strictEqual( isUnityProbabilityArray( values[i] ), true, 'returns true when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function allows a difference in sum within floating-point epsilon', function test( t ) { - var bool = isUnityProbabilityArray( [ 0.1, 0.2, 0.1, 0.1, 0.2, 0.2, 0.1 ] ); - t.strictEqual( bool, true, 'returns true' ); - t.end(); -}); - -tape( 'the function returns `false` if not provided an array of probabilities that sum to one', function test( t ) { - var values; - var i; - - values = [ - '10', - '01', - '0.5', - '5', - 5, - NaN, - null, - void 0, - true, - [], - [ 5, null ], - [ 5, '5' ], - [ 1.0, 3.14 ], - [ -1.0, 1.0, 1.0 ], - [ 0.25, 0.33, 0.5 ], - new Float64Array( [ 0.25, 0.33, 0.5 ] ), - new Float64Array( [ 0.25, 1.33, 0.5 ] ), - new Float64Array( [ 0.25, -0.33, 0.5 ] ), - {}, - function noop() {}, - array2buffer( [ 1, 1, 0 ] ) - ]; - - for ( i = 0; i < values.length; i++ ) { - t.strictEqual( isUnityProbabilityArray( values[i] ), false, 'returns false when provided '+values[i] ); - } - t.end(); -}); From ce0701502da793cf1abec6727f94d639b7bb39a7 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 26 Sep 2022 17:36:49 +0000 Subject: [PATCH 015/133] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 3c769e3..16e31f9 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,8 @@ "@stdlib/assert-is-number": "^0.0.x", "@stdlib/assert-is-typed-array": "^0.0.x", "@stdlib/constants-float64-sqrt-eps": "^0.0.x", - "@stdlib/math-base-utils-absolute-difference": "^0.0.x" + "@stdlib/math-base-utils-absolute-difference": "^0.0.x", + "@stdlib/error-tools-fmtprodmsg": "^0.0.x" }, "devDependencies": { "@stdlib/array-float32": "^0.0.x", @@ -104,4 +105,4 @@ "type": "patreon", "url": "https://www.patreon.com/athan" } -} +} \ No newline at end of file From bfc140520ea276179eccc26f9938303f1f795870 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 26 Sep 2022 18:24:30 +0000 Subject: [PATCH 016/133] Remove files --- index.d.ts | 48 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 2689 ------------------------------------------------- 4 files changed, 2742 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index f77442a..0000000 --- a/index.d.ts +++ /dev/null @@ -1,48 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 2.0 - -/** -* Tests if a value is an array of probabilities that sum to one. -* -* @param v - value to test -* @returns boolean indicating if a value is a probability array -* -* @example -* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] ); -* // returns true -* -* @example -* var bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) ); -* // returns true -* -* @example -* var bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] ); -* // returns false -* -* @example -* var bool = isUnityProbabilityArray( [ 3.14, 0.0 ] ); -* // returns false -*/ -declare function isUnityProbabilityArray( v: any ): boolean; - - -// EXPORTS // - -export = isUnityProbabilityArray; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 44ce222..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-typed-array@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array@esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-number@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/math-base-utils-absolute-difference@esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/constants-float64-sqrt-eps@esm/index.mjs";function n(n){var d,m;if(t(n)){for(d=0,m=0;m1||n[m]<0)return!1;d+=n[m]}return r(d,1)<=i}if(s(n)){for(d=0,m=0;m1||n[m]<0)return!1;d+=n[m]}return r(d,1)<=i}return!1}export{n as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 0e27c38..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isTypedArray from '@stdlib/assert-is-typed-array' ;\nimport isArray from '@stdlib/assert-is-array' ;\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number' ;\nimport absdiff from '@stdlib/math-base-utils-absolute-difference' ;\nimport FLOAT64_SQRT_EPS from '@stdlib/constants-float64-sqrt-eps' ;\n\n\n// MAIN //\n\n/**\n* Tests if a value is an array of probabilities that sum to one.\n*\n* @param {*} v - value to test\n* @returns {boolean} boolean indicating if a value is a probability array\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] );\n* // returns true\n*\n* @example\n* var bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) );\n* // returns true\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] );\n* // returns false\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 3.14, 0.0 ] );\n* // returns false\n*/\nfunction isUnityProbabilityArray( v ) {\n\tvar sum;\n\tvar i;\n\tif ( isArray( v ) ) {\n\t\tsum = 0.0;\n\t\tfor ( i = 0; i < v.length; i++ ) {\n\t\t\tif (\n\t\t\t\t!isNumber( v[ i ] ) ||\n\t\t\t\tv[ i ] > 1.0 ||\n\t\t\t\tv[ i ] < 0.0\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tsum += v[ i ];\n\t\t}\n\t\treturn ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS );\n\t}\n\tif ( isTypedArray( v ) ) {\n\t\tsum = 0.0;\n\t\tfor ( i = 0; i < v.length; i++ ) {\n\t\t\tif (\n\t\t\t\tv[ i ] > 1.0 ||\n\t\t\t\tv[ i ] < 0.0\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tsum += v[ i ];\n\t\t}\n\t\treturn ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS );\n\t}\n\treturn false;\n}\n\n\n// EXPORTS //\n\nexport default isUnityProbabilityArray;\n"],"names":["isUnityProbabilityArray","v","sum","i","isArray","length","isNumber","absdiff","FLOAT64_SQRT_EPS","isTypedArray"],"mappings":";;odAqDA,SAASA,EAAyBC,GACjC,IAAIC,EACAC,EACJ,GAAKC,EAASH,GAAM,CAEnB,IADAC,EAAM,EACAC,EAAI,EAAGA,EAAIF,EAAEI,OAAQF,IAAM,CAChC,IACEG,EAAUL,EAAGE,KACdF,EAAGE,GAAM,GACTF,EAAGE,GAAM,EAET,OAAO,EAERD,GAAOD,EAAGE,GAEX,OAASI,EAASL,EAAK,IAASM,EAEjC,GAAKC,EAAcR,GAAM,CAExB,IADAC,EAAM,EACAC,EAAI,EAAGA,EAAIF,EAAEI,OAAQF,IAAM,CAChC,GACCF,EAAGE,GAAM,GACTF,EAAGE,GAAM,EAET,OAAO,EAERD,GAAOD,EAAGE,GAEX,OAASI,EAASL,EAAK,IAASM,EAEjC,OAAO"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 93479b4..0000000 --- a/stats.html +++ /dev/null @@ -1,2689 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From 10a5c738589137daad676b10a9f4f55b036bb45d Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 26 Sep 2022 18:25:23 +0000 Subject: [PATCH 017/133] Auto-generated commit --- .editorconfig | 181 -- .eslintrc.js | 1 - .gitattributes | 49 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 62 - .github/workflows/cancel.yml | 56 - .github/workflows/close_pull_requests.yml | 44 - .github/workflows/examples.yml | 62 - .github/workflows/npm_downloads.yml | 108 - .github/workflows/productionize.yml | 760 ------ .github/workflows/publish.yml | 117 - .github/workflows/test.yml | 92 - .github/workflows/test_bundles.yml | 180 -- .github/workflows/test_coverage.yml | 123 - .github/workflows/test_install.yml | 83 - .gitignore | 178 -- .npmignore | 227 -- .npmrc | 28 - CHANGELOG.md | 5 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 ---- README.md | 41 +- benchmark/benchmark.js | 103 - branches.md | 53 - docs/repl.txt | 29 - docs/types/test.ts | 34 - examples/index.js | 48 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 49 - lib/main.js | 90 - package.json | 70 +- stats.html | 2689 +++++++++++++++++++++ test/test.js | 106 - 36 files changed, 2714 insertions(+), 3506 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 0fd4d6c..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 75a4c32..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/assert/is-unity-probability-array) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index 29bf533..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,62 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index a7a7f51..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,56 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - uses: styfle/cancel-workflow-action@0.9.0 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index a5cb54c..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/assert/is-unity-probability-array) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index 39b1613..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,62 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout the repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index 7ca169c..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,108 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '0 8 * * 6' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "::set-output name=package_name::$name" - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "::set-output name=data::$data" - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - uses: actions/upload-artifact@v2 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - uses: distributhor/workflow-webhook@v2 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 5094681..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,760 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - uses: actions/checkout@v3 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Format error messages: - - name: 'Replace double quotes with single quotes in rewritten format string error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\( \"([a-zA-Z0-9]+)\"/Error\( format\( '\1'/g" {} \; - - # Format string literal error messages: - - name: 'Replace double quotes with single quotes in rewritten string literal error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\(\"([a-zA-Z0-9]+)\"\)/Error\( format\( '\1' \)/g" {} \; - - # Format code: - - name: 'Replace double quotes with single quotes in inserted `require` calls' - run: | - find . -name "*.js" -exec sed -E -i "s/require\( ?\"@stdlib\/error-tools-fmtprodmsg\" ?\);/require\( '@stdlib\/error-tools-fmtprodmsg' \);/g" {} \; - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\"/\"@stdlib\/error-tools-fmtprodmsg\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^0.0.x'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "::set-output name=remote-exists::true" - else - echo "::set-output name=remote-exists::false" - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - uses: act10ns/slack@v1 - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "::set-output name=remote-exists::true" - else - echo "::set-output name=remote-exists::false" - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "::set-output name=alias::${alias}" - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -165,7 +158,7 @@ bool = isUnityProbabilityArray( null ); ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -229,9 +222,9 @@ Copyright © 2016-2022. The Stdlib [Authors][stdlib-authors]. -[@stdlib/assert/is-probability]: https://github.com/stdlib-js/assert-is-probability +[@stdlib/assert/is-probability]: https://github.com/stdlib-js/assert-is-probability/tree/esm -[@stdlib/assert/is-probability-array]: https://github.com/stdlib-js/assert-is-probability-array +[@stdlib/assert/is-probability-array]: https://github.com/stdlib-js/assert-is-probability-array/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 1121550..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,103 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var isUnityProbabilityArray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x; - var i; - - x = []; - for ( i = 0; i < len; i++ ) { - x.push( 1.0/len ); - } - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: we are testing the worst case scenario where a function must scan the entire array before finding a failing value. - x[ len-1 ] = i * 3.14; - bool = isUnityProbabilityArray( x ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( isBoolean( bool ) ) { - b.pass( 'benchmark finished' ); - } else { - b.fail( 'should return a boolean' ); - } - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':len='+len, f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index 6fcd715..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/assert/is-unity-probability-array" -click B href "https://github.com/stdlib-js/assert-is-unity-probability-array/tree/main" -click C href "https://github.com/stdlib-js/assert-is-unity-probability-array/tree/production" -click D href "https://github.com/stdlib-js/assert-is-unity-probability-array/tree/esm" -click E href "https://github.com/stdlib-js/assert-is-unity-probability-array/tree/deno" -click F href "https://github.com/stdlib-js/assert-is-unity-probability-array/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/assert/is-unity-probability-array -[production-url]: https://github.com/stdlib-js/assert-is-unity-probability-array/tree/production -[deno-url]: https://github.com/stdlib-js/assert-is-unity-probability-array/tree/deno -[umd-url]: https://github.com/stdlib-js/assert-is-unity-probability-array/tree/umd -[esm-url]: https://github.com/stdlib-js/assert-is-unity-probability-array/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index a2414be..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,29 +0,0 @@ - -{{alias}}( value ) - Tests if a value is an array of probabilities that sum to one. - - Parameters - ---------- - value: any - Value to test. - - Returns - ------- - bool: boolean - Boolean indicating whether value is an array of probabilities that sum - to one. - - Examples - -------- - > var bool = {{alias}}( [ 0.25, 0.5, 0.25 ] ) - true - > bool = {{alias}}( new {{alias:@stdlib/array/uint8}}( [ 0, 1 ] ) ) - true - > bool = {{alias}}( [ 0.4, 0.4, 0.4 ] ) - false - > bool = {{alias}}( [ 3.14, 0.0 ] ) - false - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 4e48f3e..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,34 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import isUnityProbabilityArray = require( './index' ); - - -// TESTS // - -// The function returns a boolean... -{ - isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] ); // $ExpectType boolean - isUnityProbabilityArray( [ 2, 3 ] ); // $ExpectType boolean -} - -// The function does not compile if provided an unsupported number of arguments... -{ - isUnityProbabilityArray(); // $ExpectError - isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ], 123 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index b0b6bbc..0000000 --- a/examples/index.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var Uint8Array = require( '@stdlib/array-uint8' ); -var isUnityProbabilityArray = require( './../lib' ); - -var arr = [ 0.0, 1.0 ]; -console.log( isUnityProbabilityArray( arr ) ); -// => true - -arr = [ 0.5, 0.25, 0.25 ]; -console.log( isUnityProbabilityArray( arr ) ); -// => true - -arr = new Uint8Array( [ 0, 0, 1, 0 ] ); -console.log( isUnityProbabilityArray( arr ) ); -// => true - -arr = [ 0.4, 0.4, 0.4 ]; -console.log( isUnityProbabilityArray( arr ) ); -// => false - -arr = [ 3.14, -1.0 ]; -console.log( isUnityProbabilityArray( arr ) ); -// => false - -console.log( isUnityProbabilityArray( [] ) ); -// => false - -console.log( isUnityProbabilityArray( null ) ); -// => false diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..44ce222 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-typed-array@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array@esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-number@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/math-base-utils-absolute-difference@esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/constants-float64-sqrt-eps@esm/index.mjs";function n(n){var d,m;if(t(n)){for(d=0,m=0;m1||n[m]<0)return!1;d+=n[m]}return r(d,1)<=i}if(s(n)){for(d=0,m=0;m1||n[m]<0)return!1;d+=n[m]}return r(d,1)<=i}return!1}export{n as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..0e27c38 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isTypedArray from '@stdlib/assert-is-typed-array' ;\nimport isArray from '@stdlib/assert-is-array' ;\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number' ;\nimport absdiff from '@stdlib/math-base-utils-absolute-difference' ;\nimport FLOAT64_SQRT_EPS from '@stdlib/constants-float64-sqrt-eps' ;\n\n\n// MAIN //\n\n/**\n* Tests if a value is an array of probabilities that sum to one.\n*\n* @param {*} v - value to test\n* @returns {boolean} boolean indicating if a value is a probability array\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] );\n* // returns true\n*\n* @example\n* var bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) );\n* // returns true\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] );\n* // returns false\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 3.14, 0.0 ] );\n* // returns false\n*/\nfunction isUnityProbabilityArray( v ) {\n\tvar sum;\n\tvar i;\n\tif ( isArray( v ) ) {\n\t\tsum = 0.0;\n\t\tfor ( i = 0; i < v.length; i++ ) {\n\t\t\tif (\n\t\t\t\t!isNumber( v[ i ] ) ||\n\t\t\t\tv[ i ] > 1.0 ||\n\t\t\t\tv[ i ] < 0.0\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tsum += v[ i ];\n\t\t}\n\t\treturn ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS );\n\t}\n\tif ( isTypedArray( v ) ) {\n\t\tsum = 0.0;\n\t\tfor ( i = 0; i < v.length; i++ ) {\n\t\t\tif (\n\t\t\t\tv[ i ] > 1.0 ||\n\t\t\t\tv[ i ] < 0.0\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tsum += v[ i ];\n\t\t}\n\t\treturn ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS );\n\t}\n\treturn false;\n}\n\n\n// EXPORTS //\n\nexport default isUnityProbabilityArray;\n"],"names":["isUnityProbabilityArray","v","sum","i","isArray","length","isNumber","absdiff","FLOAT64_SQRT_EPS","isTypedArray"],"mappings":";;odAqDA,SAASA,EAAyBC,GACjC,IAAIC,EACAC,EACJ,GAAKC,EAASH,GAAM,CAEnB,IADAC,EAAM,EACAC,EAAI,EAAGA,EAAIF,EAAEI,OAAQF,IAAM,CAChC,IACEG,EAAUL,EAAGE,KACdF,EAAGE,GAAM,GACTF,EAAGE,GAAM,EAET,OAAO,EAERD,GAAOD,EAAGE,GAEX,OAASI,EAASL,EAAK,IAASM,EAEjC,GAAKC,EAAcR,GAAM,CAExB,IADAC,EAAM,EACAC,EAAI,EAAGA,EAAIF,EAAEI,OAAQF,IAAM,CAChC,GACCF,EAAGE,GAAM,GACTF,EAAGE,GAAM,EAET,OAAO,EAERD,GAAOD,EAAGE,GAEX,OAASI,EAASL,EAAK,IAASM,EAEjC,OAAO"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 13a67d1..0000000 --- a/lib/index.js +++ /dev/null @@ -1,49 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Test if a value is an array of probabilities that sum to one. -* -* @module @stdlib/assert-is-unity-probability-array -* -* @example -* var isUnityProbabilityArray = require( '@stdlib/assert-is-unity-probability-array' ); -* -* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] ); -* // returns true -* -* bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) ); -* // returns true -* -* bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] ); -* // returns false -* -* bool = isUnityProbabilityArray( [ 3.14, 0.0 ] ); -* // returns false -*/ - -// 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 d0bda40..0000000 --- a/lib/main.js +++ /dev/null @@ -1,90 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -var isArray = require( '@stdlib/assert-is-array' ); -var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var absdiff = require( '@stdlib/math-base-utils-absolute-difference' ); -var FLOAT64_SQRT_EPS = require( '@stdlib/constants-float64-sqrt-eps' ); - - -// MAIN // - -/** -* Tests if a value is an array of probabilities that sum to one. -* -* @param {*} v - value to test -* @returns {boolean} boolean indicating if a value is a probability array -* -* @example -* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] ); -* // returns true -* -* @example -* var bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) ); -* // returns true -* -* @example -* var bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] ); -* // returns false -* -* @example -* var bool = isUnityProbabilityArray( [ 3.14, 0.0 ] ); -* // returns false -*/ -function isUnityProbabilityArray( v ) { - var sum; - var i; - if ( isArray( v ) ) { - sum = 0.0; - for ( i = 0; i < v.length; i++ ) { - if ( - !isNumber( v[ i ] ) || - v[ i ] > 1.0 || - v[ i ] < 0.0 - ) { - return false; - } - sum += v[ i ]; - } - return ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS ); - } - if ( isTypedArray( v ) ) { - sum = 0.0; - for ( i = 0; i < v.length; i++ ) { - if ( - v[ i ] > 1.0 || - v[ i ] < 0.0 - ) { - return false; - } - sum += v[ i ]; - } - return ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS ); - } - return false; -} - - -// EXPORTS // - -module.exports = isUnityProbabilityArray; diff --git a/package.json b/package.json index 16e31f9..bf1e9c3 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.7", "description": "Test if a value is an array of probabilities that sum to one.", "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" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,47 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-array": "^0.0.x", - "@stdlib/assert-is-number": "^0.0.x", - "@stdlib/assert-is-typed-array": "^0.0.x", - "@stdlib/constants-float64-sqrt-eps": "^0.0.x", - "@stdlib/math-base-utils-absolute-difference": "^0.0.x", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x" - }, - "devDependencies": { - "@stdlib/array-float32": "^0.0.x", - "@stdlib/array-float64": "^0.0.x", - "@stdlib/array-int16": "^0.0.x", - "@stdlib/array-int32": "^0.0.x", - "@stdlib/array-int8": "^0.0.x", - "@stdlib/array-uint16": "^0.0.x", - "@stdlib/array-uint32": "^0.0.x", - "@stdlib/array-uint8": "^0.0.x", - "@stdlib/array-uint8c": "^0.0.x", - "@stdlib/assert-is-boolean": "^0.0.x", - "@stdlib/bench": "^0.0.x", - "@stdlib/buffer-from-array": "^0.0.x", - "@stdlib/math-base-special-pow": "^0.0.x", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-spec": "5.x.x" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdassert", @@ -105,4 +41,4 @@ "type": "patreon", "url": "https://www.patreon.com/athan" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..b6ddb8b --- /dev/null +++ b/stats.html @@ -0,0 +1,2689 @@ + + + + + + + + RollUp Visualizer + + + +
+ + + + + diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 7f6a066..0000000 --- a/test/test.js +++ /dev/null @@ -1,106 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Int8Array = require( '@stdlib/array-int8' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Float64Array = require( '@stdlib/array-float64' ); -var array2buffer = require( '@stdlib/buffer-from-array' ); -var isUnityProbabilityArray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof isUnityProbabilityArray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns `true` if provided an array of probabilities that sum to one', function test( t ) { - var values; - var i; - - values = [ - new Int8Array( [ 0, 0, 1 ] ), - new Uint8Array( [ 1, 0, 0 ] ), - new Uint8ClampedArray( [ 0, 1 ] ), - new Int16Array( [ 0, 0, 1, 0 ] ), - new Uint16Array( [ 1 ] ), - new Int32Array( [ 1, 0, 0 ] ), - new Uint32Array( [ 0, 1, 0 ] ), - new Float32Array( [ 0.0, 0.5, 0.5 ] ), - new Float64Array( [ 0.25, 0.25, 0.5 ] ), - [ 0.5, 0.25, 0.25 ] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.strictEqual( isUnityProbabilityArray( values[i] ), true, 'returns true when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function allows a difference in sum within floating-point epsilon', function test( t ) { - var bool = isUnityProbabilityArray( [ 0.1, 0.2, 0.1, 0.1, 0.2, 0.2, 0.1 ] ); - t.strictEqual( bool, true, 'returns true' ); - t.end(); -}); - -tape( 'the function returns `false` if not provided an array of probabilities that sum to one', function test( t ) { - var values; - var i; - - values = [ - '10', - '01', - '0.5', - '5', - 5, - NaN, - null, - void 0, - true, - [], - [ 5, null ], - [ 5, '5' ], - [ 1.0, 3.14 ], - [ -1.0, 1.0, 1.0 ], - [ 0.25, 0.33, 0.5 ], - new Float64Array( [ 0.25, 0.33, 0.5 ] ), - new Float64Array( [ 0.25, 1.33, 0.5 ] ), - new Float64Array( [ 0.25, -0.33, 0.5 ] ), - {}, - function noop() {}, - array2buffer( [ 1, 1, 0 ] ) - ]; - - for ( i = 0; i < values.length; i++ ) { - t.strictEqual( isUnityProbabilityArray( values[i] ), false, 'returns false when provided '+values[i] ); - } - t.end(); -}); From 2473a244c2551fa5ede501f23cb537b2a3d4265a Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 27 Sep 2022 22:38:51 +0000 Subject: [PATCH 018/133] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 3c769e3..16e31f9 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,8 @@ "@stdlib/assert-is-number": "^0.0.x", "@stdlib/assert-is-typed-array": "^0.0.x", "@stdlib/constants-float64-sqrt-eps": "^0.0.x", - "@stdlib/math-base-utils-absolute-difference": "^0.0.x" + "@stdlib/math-base-utils-absolute-difference": "^0.0.x", + "@stdlib/error-tools-fmtprodmsg": "^0.0.x" }, "devDependencies": { "@stdlib/array-float32": "^0.0.x", @@ -104,4 +105,4 @@ "type": "patreon", "url": "https://www.patreon.com/athan" } -} +} \ No newline at end of file From 20f726d754e7bcfe8697cec696eb2a4717f39d56 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 27 Sep 2022 23:55:28 +0000 Subject: [PATCH 019/133] Remove files --- index.d.ts | 48 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 2689 ------------------------------------------------- 4 files changed, 2742 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index f77442a..0000000 --- a/index.d.ts +++ /dev/null @@ -1,48 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 2.0 - -/** -* Tests if a value is an array of probabilities that sum to one. -* -* @param v - value to test -* @returns boolean indicating if a value is a probability array -* -* @example -* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] ); -* // returns true -* -* @example -* var bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) ); -* // returns true -* -* @example -* var bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] ); -* // returns false -* -* @example -* var bool = isUnityProbabilityArray( [ 3.14, 0.0 ] ); -* // returns false -*/ -declare function isUnityProbabilityArray( v: any ): boolean; - - -// EXPORTS // - -export = isUnityProbabilityArray; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 44ce222..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-typed-array@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array@esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-number@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/math-base-utils-absolute-difference@esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/constants-float64-sqrt-eps@esm/index.mjs";function n(n){var d,m;if(t(n)){for(d=0,m=0;m1||n[m]<0)return!1;d+=n[m]}return r(d,1)<=i}if(s(n)){for(d=0,m=0;m1||n[m]<0)return!1;d+=n[m]}return r(d,1)<=i}return!1}export{n as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 0e27c38..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isTypedArray from '@stdlib/assert-is-typed-array' ;\nimport isArray from '@stdlib/assert-is-array' ;\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number' ;\nimport absdiff from '@stdlib/math-base-utils-absolute-difference' ;\nimport FLOAT64_SQRT_EPS from '@stdlib/constants-float64-sqrt-eps' ;\n\n\n// MAIN //\n\n/**\n* Tests if a value is an array of probabilities that sum to one.\n*\n* @param {*} v - value to test\n* @returns {boolean} boolean indicating if a value is a probability array\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] );\n* // returns true\n*\n* @example\n* var bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) );\n* // returns true\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] );\n* // returns false\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 3.14, 0.0 ] );\n* // returns false\n*/\nfunction isUnityProbabilityArray( v ) {\n\tvar sum;\n\tvar i;\n\tif ( isArray( v ) ) {\n\t\tsum = 0.0;\n\t\tfor ( i = 0; i < v.length; i++ ) {\n\t\t\tif (\n\t\t\t\t!isNumber( v[ i ] ) ||\n\t\t\t\tv[ i ] > 1.0 ||\n\t\t\t\tv[ i ] < 0.0\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tsum += v[ i ];\n\t\t}\n\t\treturn ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS );\n\t}\n\tif ( isTypedArray( v ) ) {\n\t\tsum = 0.0;\n\t\tfor ( i = 0; i < v.length; i++ ) {\n\t\t\tif (\n\t\t\t\tv[ i ] > 1.0 ||\n\t\t\t\tv[ i ] < 0.0\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tsum += v[ i ];\n\t\t}\n\t\treturn ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS );\n\t}\n\treturn false;\n}\n\n\n// EXPORTS //\n\nexport default isUnityProbabilityArray;\n"],"names":["isUnityProbabilityArray","v","sum","i","isArray","length","isNumber","absdiff","FLOAT64_SQRT_EPS","isTypedArray"],"mappings":";;odAqDA,SAASA,EAAyBC,GACjC,IAAIC,EACAC,EACJ,GAAKC,EAASH,GAAM,CAEnB,IADAC,EAAM,EACAC,EAAI,EAAGA,EAAIF,EAAEI,OAAQF,IAAM,CAChC,IACEG,EAAUL,EAAGE,KACdF,EAAGE,GAAM,GACTF,EAAGE,GAAM,EAET,OAAO,EAERD,GAAOD,EAAGE,GAEX,OAASI,EAASL,EAAK,IAASM,EAEjC,GAAKC,EAAcR,GAAM,CAExB,IADAC,EAAM,EACAC,EAAI,EAAGA,EAAIF,EAAEI,OAAQF,IAAM,CAChC,GACCF,EAAGE,GAAM,GACTF,EAAGE,GAAM,EAET,OAAO,EAERD,GAAOD,EAAGE,GAEX,OAASI,EAASL,EAAK,IAASM,EAEjC,OAAO"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index b6ddb8b..0000000 --- a/stats.html +++ /dev/null @@ -1,2689 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From 391ba49ae3734b51348002bf573e4fd8d745f16c Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 27 Sep 2022 23:56:19 +0000 Subject: [PATCH 020/133] Auto-generated commit --- .editorconfig | 181 -- .eslintrc.js | 1 - .gitattributes | 49 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 62 - .github/workflows/cancel.yml | 56 - .github/workflows/close_pull_requests.yml | 44 - .github/workflows/examples.yml | 62 - .github/workflows/npm_downloads.yml | 108 - .github/workflows/productionize.yml | 760 ------ .github/workflows/publish.yml | 117 - .github/workflows/test.yml | 92 - .github/workflows/test_bundles.yml | 180 -- .github/workflows/test_coverage.yml | 123 - .github/workflows/test_install.yml | 83 - .gitignore | 178 -- .npmignore | 227 -- .npmrc | 28 - CHANGELOG.md | 5 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 ---- README.md | 41 +- benchmark/benchmark.js | 103 - branches.md | 53 - docs/repl.txt | 29 - docs/types/test.ts | 34 - examples/index.js | 48 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 49 - lib/main.js | 90 - package.json | 70 +- stats.html | 2689 +++++++++++++++++++++ test/test.js | 106 - 36 files changed, 2714 insertions(+), 3506 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 0fd4d6c..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 75a4c32..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/assert/is-unity-probability-array) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index 29bf533..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,62 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index a7a7f51..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,56 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - uses: styfle/cancel-workflow-action@0.9.0 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index a5cb54c..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/assert/is-unity-probability-array) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index 39b1613..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,62 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout the repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index 7ca169c..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,108 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '0 8 * * 6' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "::set-output name=package_name::$name" - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "::set-output name=data::$data" - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - uses: actions/upload-artifact@v2 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - uses: distributhor/workflow-webhook@v2 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 5094681..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,760 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - uses: actions/checkout@v3 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Format error messages: - - name: 'Replace double quotes with single quotes in rewritten format string error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\( \"([a-zA-Z0-9]+)\"/Error\( format\( '\1'/g" {} \; - - # Format string literal error messages: - - name: 'Replace double quotes with single quotes in rewritten string literal error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\(\"([a-zA-Z0-9]+)\"\)/Error\( format\( '\1' \)/g" {} \; - - # Format code: - - name: 'Replace double quotes with single quotes in inserted `require` calls' - run: | - find . -name "*.js" -exec sed -E -i "s/require\( ?\"@stdlib\/error-tools-fmtprodmsg\" ?\);/require\( '@stdlib\/error-tools-fmtprodmsg' \);/g" {} \; - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\"/\"@stdlib\/error-tools-fmtprodmsg\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^0.0.x'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "::set-output name=remote-exists::true" - else - echo "::set-output name=remote-exists::false" - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - uses: act10ns/slack@v1 - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "::set-output name=remote-exists::true" - else - echo "::set-output name=remote-exists::false" - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "::set-output name=alias::${alias}" - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -165,7 +158,7 @@ bool = isUnityProbabilityArray( null ); ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -229,9 +222,9 @@ Copyright © 2016-2022. The Stdlib [Authors][stdlib-authors]. -[@stdlib/assert/is-probability]: https://github.com/stdlib-js/assert-is-probability +[@stdlib/assert/is-probability]: https://github.com/stdlib-js/assert-is-probability/tree/esm -[@stdlib/assert/is-probability-array]: https://github.com/stdlib-js/assert-is-probability-array +[@stdlib/assert/is-probability-array]: https://github.com/stdlib-js/assert-is-probability-array/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 1121550..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,103 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var isUnityProbabilityArray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x; - var i; - - x = []; - for ( i = 0; i < len; i++ ) { - x.push( 1.0/len ); - } - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: we are testing the worst case scenario where a function must scan the entire array before finding a failing value. - x[ len-1 ] = i * 3.14; - bool = isUnityProbabilityArray( x ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( isBoolean( bool ) ) { - b.pass( 'benchmark finished' ); - } else { - b.fail( 'should return a boolean' ); - } - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':len='+len, f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index 6fcd715..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/assert/is-unity-probability-array" -click B href "https://github.com/stdlib-js/assert-is-unity-probability-array/tree/main" -click C href "https://github.com/stdlib-js/assert-is-unity-probability-array/tree/production" -click D href "https://github.com/stdlib-js/assert-is-unity-probability-array/tree/esm" -click E href "https://github.com/stdlib-js/assert-is-unity-probability-array/tree/deno" -click F href "https://github.com/stdlib-js/assert-is-unity-probability-array/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/assert/is-unity-probability-array -[production-url]: https://github.com/stdlib-js/assert-is-unity-probability-array/tree/production -[deno-url]: https://github.com/stdlib-js/assert-is-unity-probability-array/tree/deno -[umd-url]: https://github.com/stdlib-js/assert-is-unity-probability-array/tree/umd -[esm-url]: https://github.com/stdlib-js/assert-is-unity-probability-array/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index a2414be..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,29 +0,0 @@ - -{{alias}}( value ) - Tests if a value is an array of probabilities that sum to one. - - Parameters - ---------- - value: any - Value to test. - - Returns - ------- - bool: boolean - Boolean indicating whether value is an array of probabilities that sum - to one. - - Examples - -------- - > var bool = {{alias}}( [ 0.25, 0.5, 0.25 ] ) - true - > bool = {{alias}}( new {{alias:@stdlib/array/uint8}}( [ 0, 1 ] ) ) - true - > bool = {{alias}}( [ 0.4, 0.4, 0.4 ] ) - false - > bool = {{alias}}( [ 3.14, 0.0 ] ) - false - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 6b41658..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,34 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import isUnityProbabilityArray = require( './index' ); - - -// TESTS // - -// The function returns a boolean... -{ - isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] ); // $ExpectType boolean - isUnityProbabilityArray( [ 2, 3 ] ); // $ExpectType boolean -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - isUnityProbabilityArray(); // $ExpectError - isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ], 123 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index b0b6bbc..0000000 --- a/examples/index.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var Uint8Array = require( '@stdlib/array-uint8' ); -var isUnityProbabilityArray = require( './../lib' ); - -var arr = [ 0.0, 1.0 ]; -console.log( isUnityProbabilityArray( arr ) ); -// => true - -arr = [ 0.5, 0.25, 0.25 ]; -console.log( isUnityProbabilityArray( arr ) ); -// => true - -arr = new Uint8Array( [ 0, 0, 1, 0 ] ); -console.log( isUnityProbabilityArray( arr ) ); -// => true - -arr = [ 0.4, 0.4, 0.4 ]; -console.log( isUnityProbabilityArray( arr ) ); -// => false - -arr = [ 3.14, -1.0 ]; -console.log( isUnityProbabilityArray( arr ) ); -// => false - -console.log( isUnityProbabilityArray( [] ) ); -// => false - -console.log( isUnityProbabilityArray( null ) ); -// => false diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..44ce222 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-typed-array@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array@esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-number@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/math-base-utils-absolute-difference@esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/constants-float64-sqrt-eps@esm/index.mjs";function n(n){var d,m;if(t(n)){for(d=0,m=0;m1||n[m]<0)return!1;d+=n[m]}return r(d,1)<=i}if(s(n)){for(d=0,m=0;m1||n[m]<0)return!1;d+=n[m]}return r(d,1)<=i}return!1}export{n as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..0e27c38 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isTypedArray from '@stdlib/assert-is-typed-array' ;\nimport isArray from '@stdlib/assert-is-array' ;\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number' ;\nimport absdiff from '@stdlib/math-base-utils-absolute-difference' ;\nimport FLOAT64_SQRT_EPS from '@stdlib/constants-float64-sqrt-eps' ;\n\n\n// MAIN //\n\n/**\n* Tests if a value is an array of probabilities that sum to one.\n*\n* @param {*} v - value to test\n* @returns {boolean} boolean indicating if a value is a probability array\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] );\n* // returns true\n*\n* @example\n* var bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) );\n* // returns true\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] );\n* // returns false\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 3.14, 0.0 ] );\n* // returns false\n*/\nfunction isUnityProbabilityArray( v ) {\n\tvar sum;\n\tvar i;\n\tif ( isArray( v ) ) {\n\t\tsum = 0.0;\n\t\tfor ( i = 0; i < v.length; i++ ) {\n\t\t\tif (\n\t\t\t\t!isNumber( v[ i ] ) ||\n\t\t\t\tv[ i ] > 1.0 ||\n\t\t\t\tv[ i ] < 0.0\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tsum += v[ i ];\n\t\t}\n\t\treturn ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS );\n\t}\n\tif ( isTypedArray( v ) ) {\n\t\tsum = 0.0;\n\t\tfor ( i = 0; i < v.length; i++ ) {\n\t\t\tif (\n\t\t\t\tv[ i ] > 1.0 ||\n\t\t\t\tv[ i ] < 0.0\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tsum += v[ i ];\n\t\t}\n\t\treturn ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS );\n\t}\n\treturn false;\n}\n\n\n// EXPORTS //\n\nexport default isUnityProbabilityArray;\n"],"names":["isUnityProbabilityArray","v","sum","i","isArray","length","isNumber","absdiff","FLOAT64_SQRT_EPS","isTypedArray"],"mappings":";;odAqDA,SAASA,EAAyBC,GACjC,IAAIC,EACAC,EACJ,GAAKC,EAASH,GAAM,CAEnB,IADAC,EAAM,EACAC,EAAI,EAAGA,EAAIF,EAAEI,OAAQF,IAAM,CAChC,IACEG,EAAUL,EAAGE,KACdF,EAAGE,GAAM,GACTF,EAAGE,GAAM,EAET,OAAO,EAERD,GAAOD,EAAGE,GAEX,OAASI,EAASL,EAAK,IAASM,EAEjC,GAAKC,EAAcR,GAAM,CAExB,IADAC,EAAM,EACAC,EAAI,EAAGA,EAAIF,EAAEI,OAAQF,IAAM,CAChC,GACCF,EAAGE,GAAM,GACTF,EAAGE,GAAM,EAET,OAAO,EAERD,GAAOD,EAAGE,GAEX,OAASI,EAASL,EAAK,IAASM,EAEjC,OAAO"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 13a67d1..0000000 --- a/lib/index.js +++ /dev/null @@ -1,49 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Test if a value is an array of probabilities that sum to one. -* -* @module @stdlib/assert-is-unity-probability-array -* -* @example -* var isUnityProbabilityArray = require( '@stdlib/assert-is-unity-probability-array' ); -* -* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] ); -* // returns true -* -* bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) ); -* // returns true -* -* bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] ); -* // returns false -* -* bool = isUnityProbabilityArray( [ 3.14, 0.0 ] ); -* // returns false -*/ - -// 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 d0bda40..0000000 --- a/lib/main.js +++ /dev/null @@ -1,90 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -var isArray = require( '@stdlib/assert-is-array' ); -var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var absdiff = require( '@stdlib/math-base-utils-absolute-difference' ); -var FLOAT64_SQRT_EPS = require( '@stdlib/constants-float64-sqrt-eps' ); - - -// MAIN // - -/** -* Tests if a value is an array of probabilities that sum to one. -* -* @param {*} v - value to test -* @returns {boolean} boolean indicating if a value is a probability array -* -* @example -* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] ); -* // returns true -* -* @example -* var bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) ); -* // returns true -* -* @example -* var bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] ); -* // returns false -* -* @example -* var bool = isUnityProbabilityArray( [ 3.14, 0.0 ] ); -* // returns false -*/ -function isUnityProbabilityArray( v ) { - var sum; - var i; - if ( isArray( v ) ) { - sum = 0.0; - for ( i = 0; i < v.length; i++ ) { - if ( - !isNumber( v[ i ] ) || - v[ i ] > 1.0 || - v[ i ] < 0.0 - ) { - return false; - } - sum += v[ i ]; - } - return ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS ); - } - if ( isTypedArray( v ) ) { - sum = 0.0; - for ( i = 0; i < v.length; i++ ) { - if ( - v[ i ] > 1.0 || - v[ i ] < 0.0 - ) { - return false; - } - sum += v[ i ]; - } - return ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS ); - } - return false; -} - - -// EXPORTS // - -module.exports = isUnityProbabilityArray; diff --git a/package.json b/package.json index 16e31f9..bf1e9c3 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.7", "description": "Test if a value is an array of probabilities that sum to one.", "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" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,47 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-array": "^0.0.x", - "@stdlib/assert-is-number": "^0.0.x", - "@stdlib/assert-is-typed-array": "^0.0.x", - "@stdlib/constants-float64-sqrt-eps": "^0.0.x", - "@stdlib/math-base-utils-absolute-difference": "^0.0.x", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x" - }, - "devDependencies": { - "@stdlib/array-float32": "^0.0.x", - "@stdlib/array-float64": "^0.0.x", - "@stdlib/array-int16": "^0.0.x", - "@stdlib/array-int32": "^0.0.x", - "@stdlib/array-int8": "^0.0.x", - "@stdlib/array-uint16": "^0.0.x", - "@stdlib/array-uint32": "^0.0.x", - "@stdlib/array-uint8": "^0.0.x", - "@stdlib/array-uint8c": "^0.0.x", - "@stdlib/assert-is-boolean": "^0.0.x", - "@stdlib/bench": "^0.0.x", - "@stdlib/buffer-from-array": "^0.0.x", - "@stdlib/math-base-special-pow": "^0.0.x", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-spec": "5.x.x" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdassert", @@ -105,4 +41,4 @@ "type": "patreon", "url": "https://www.patreon.com/athan" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..ef862a7 --- /dev/null +++ b/stats.html @@ -0,0 +1,2689 @@ + + + + + + + + RollUp Visualizer + + + +
+ + + + + diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 7f6a066..0000000 --- a/test/test.js +++ /dev/null @@ -1,106 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Int8Array = require( '@stdlib/array-int8' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Float64Array = require( '@stdlib/array-float64' ); -var array2buffer = require( '@stdlib/buffer-from-array' ); -var isUnityProbabilityArray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof isUnityProbabilityArray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns `true` if provided an array of probabilities that sum to one', function test( t ) { - var values; - var i; - - values = [ - new Int8Array( [ 0, 0, 1 ] ), - new Uint8Array( [ 1, 0, 0 ] ), - new Uint8ClampedArray( [ 0, 1 ] ), - new Int16Array( [ 0, 0, 1, 0 ] ), - new Uint16Array( [ 1 ] ), - new Int32Array( [ 1, 0, 0 ] ), - new Uint32Array( [ 0, 1, 0 ] ), - new Float32Array( [ 0.0, 0.5, 0.5 ] ), - new Float64Array( [ 0.25, 0.25, 0.5 ] ), - [ 0.5, 0.25, 0.25 ] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.strictEqual( isUnityProbabilityArray( values[i] ), true, 'returns true when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function allows a difference in sum within floating-point epsilon', function test( t ) { - var bool = isUnityProbabilityArray( [ 0.1, 0.2, 0.1, 0.1, 0.2, 0.2, 0.1 ] ); - t.strictEqual( bool, true, 'returns true' ); - t.end(); -}); - -tape( 'the function returns `false` if not provided an array of probabilities that sum to one', function test( t ) { - var values; - var i; - - values = [ - '10', - '01', - '0.5', - '5', - 5, - NaN, - null, - void 0, - true, - [], - [ 5, null ], - [ 5, '5' ], - [ 1.0, 3.14 ], - [ -1.0, 1.0, 1.0 ], - [ 0.25, 0.33, 0.5 ], - new Float64Array( [ 0.25, 0.33, 0.5 ] ), - new Float64Array( [ 0.25, 1.33, 0.5 ] ), - new Float64Array( [ 0.25, -0.33, 0.5 ] ), - {}, - function noop() {}, - array2buffer( [ 1, 1, 0 ] ) - ]; - - for ( i = 0; i < values.length; i++ ) { - t.strictEqual( isUnityProbabilityArray( values[i] ), false, 'returns false when provided '+values[i] ); - } - t.end(); -}); From 04bb4cf52a0c776a2a3006778fb06872728c58bd Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 1 Oct 2022 04:57:27 +0000 Subject: [PATCH 021/133] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 3c769e3..16e31f9 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,8 @@ "@stdlib/assert-is-number": "^0.0.x", "@stdlib/assert-is-typed-array": "^0.0.x", "@stdlib/constants-float64-sqrt-eps": "^0.0.x", - "@stdlib/math-base-utils-absolute-difference": "^0.0.x" + "@stdlib/math-base-utils-absolute-difference": "^0.0.x", + "@stdlib/error-tools-fmtprodmsg": "^0.0.x" }, "devDependencies": { "@stdlib/array-float32": "^0.0.x", @@ -104,4 +105,4 @@ "type": "patreon", "url": "https://www.patreon.com/athan" } -} +} \ No newline at end of file From 8683308f18254a7e250348933b7de70565aceb79 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 1 Oct 2022 22:16:15 +0000 Subject: [PATCH 022/133] Remove files --- index.d.ts | 48 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 2689 ------------------------------------------------- 4 files changed, 2742 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index f77442a..0000000 --- a/index.d.ts +++ /dev/null @@ -1,48 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 2.0 - -/** -* Tests if a value is an array of probabilities that sum to one. -* -* @param v - value to test -* @returns boolean indicating if a value is a probability array -* -* @example -* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] ); -* // returns true -* -* @example -* var bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) ); -* // returns true -* -* @example -* var bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] ); -* // returns false -* -* @example -* var bool = isUnityProbabilityArray( [ 3.14, 0.0 ] ); -* // returns false -*/ -declare function isUnityProbabilityArray( v: any ): boolean; - - -// EXPORTS // - -export = isUnityProbabilityArray; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 44ce222..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-typed-array@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array@esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-number@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/math-base-utils-absolute-difference@esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/constants-float64-sqrt-eps@esm/index.mjs";function n(n){var d,m;if(t(n)){for(d=0,m=0;m1||n[m]<0)return!1;d+=n[m]}return r(d,1)<=i}if(s(n)){for(d=0,m=0;m1||n[m]<0)return!1;d+=n[m]}return r(d,1)<=i}return!1}export{n as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 0e27c38..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isTypedArray from '@stdlib/assert-is-typed-array' ;\nimport isArray from '@stdlib/assert-is-array' ;\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number' ;\nimport absdiff from '@stdlib/math-base-utils-absolute-difference' ;\nimport FLOAT64_SQRT_EPS from '@stdlib/constants-float64-sqrt-eps' ;\n\n\n// MAIN //\n\n/**\n* Tests if a value is an array of probabilities that sum to one.\n*\n* @param {*} v - value to test\n* @returns {boolean} boolean indicating if a value is a probability array\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] );\n* // returns true\n*\n* @example\n* var bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) );\n* // returns true\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] );\n* // returns false\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 3.14, 0.0 ] );\n* // returns false\n*/\nfunction isUnityProbabilityArray( v ) {\n\tvar sum;\n\tvar i;\n\tif ( isArray( v ) ) {\n\t\tsum = 0.0;\n\t\tfor ( i = 0; i < v.length; i++ ) {\n\t\t\tif (\n\t\t\t\t!isNumber( v[ i ] ) ||\n\t\t\t\tv[ i ] > 1.0 ||\n\t\t\t\tv[ i ] < 0.0\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tsum += v[ i ];\n\t\t}\n\t\treturn ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS );\n\t}\n\tif ( isTypedArray( v ) ) {\n\t\tsum = 0.0;\n\t\tfor ( i = 0; i < v.length; i++ ) {\n\t\t\tif (\n\t\t\t\tv[ i ] > 1.0 ||\n\t\t\t\tv[ i ] < 0.0\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tsum += v[ i ];\n\t\t}\n\t\treturn ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS );\n\t}\n\treturn false;\n}\n\n\n// EXPORTS //\n\nexport default isUnityProbabilityArray;\n"],"names":["isUnityProbabilityArray","v","sum","i","isArray","length","isNumber","absdiff","FLOAT64_SQRT_EPS","isTypedArray"],"mappings":";;odAqDA,SAASA,EAAyBC,GACjC,IAAIC,EACAC,EACJ,GAAKC,EAASH,GAAM,CAEnB,IADAC,EAAM,EACAC,EAAI,EAAGA,EAAIF,EAAEI,OAAQF,IAAM,CAChC,IACEG,EAAUL,EAAGE,KACdF,EAAGE,GAAM,GACTF,EAAGE,GAAM,EAET,OAAO,EAERD,GAAOD,EAAGE,GAEX,OAASI,EAASL,EAAK,IAASM,EAEjC,GAAKC,EAAcR,GAAM,CAExB,IADAC,EAAM,EACAC,EAAI,EAAGA,EAAIF,EAAEI,OAAQF,IAAM,CAChC,GACCF,EAAGE,GAAM,GACTF,EAAGE,GAAM,EAET,OAAO,EAERD,GAAOD,EAAGE,GAEX,OAASI,EAASL,EAAK,IAASM,EAEjC,OAAO"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index ef862a7..0000000 --- a/stats.html +++ /dev/null @@ -1,2689 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From e9eabc0e18480f4097027b0723ca40a7f7ed44d0 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 1 Oct 2022 22:17:06 +0000 Subject: [PATCH 023/133] Auto-generated commit --- .editorconfig | 181 -- .eslintrc.js | 1 - .gitattributes | 49 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 62 - .github/workflows/cancel.yml | 56 - .github/workflows/close_pull_requests.yml | 44 - .github/workflows/examples.yml | 62 - .github/workflows/npm_downloads.yml | 108 - .github/workflows/productionize.yml | 760 ------ .github/workflows/publish.yml | 117 - .github/workflows/test.yml | 92 - .github/workflows/test_bundles.yml | 180 -- .github/workflows/test_coverage.yml | 123 - .github/workflows/test_install.yml | 83 - .gitignore | 178 -- .npmignore | 227 -- .npmrc | 28 - CHANGELOG.md | 5 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 ---- README.md | 41 +- benchmark/benchmark.js | 103 - branches.md | 53 - docs/repl.txt | 29 - docs/types/test.ts | 34 - examples/index.js | 48 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 49 - lib/main.js | 90 - package.json | 70 +- stats.html | 2689 +++++++++++++++++++++ test/test.js | 106 - 37 files changed, 2714 insertions(+), 3507 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 0fd4d6c..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 490810c..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2022-10-01T02:00:21.192Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 75a4c32..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/assert/is-unity-probability-array) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index 29bf533..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,62 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index a7a7f51..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,56 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - uses: styfle/cancel-workflow-action@0.9.0 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index a5cb54c..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/assert/is-unity-probability-array) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index 39b1613..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,62 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout the repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index 7ca169c..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,108 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '0 8 * * 6' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "::set-output name=package_name::$name" - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "::set-output name=data::$data" - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - uses: actions/upload-artifact@v2 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - uses: distributhor/workflow-webhook@v2 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 5094681..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,760 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - uses: actions/checkout@v3 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Format error messages: - - name: 'Replace double quotes with single quotes in rewritten format string error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\( \"([a-zA-Z0-9]+)\"/Error\( format\( '\1'/g" {} \; - - # Format string literal error messages: - - name: 'Replace double quotes with single quotes in rewritten string literal error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\(\"([a-zA-Z0-9]+)\"\)/Error\( format\( '\1' \)/g" {} \; - - # Format code: - - name: 'Replace double quotes with single quotes in inserted `require` calls' - run: | - find . -name "*.js" -exec sed -E -i "s/require\( ?\"@stdlib\/error-tools-fmtprodmsg\" ?\);/require\( '@stdlib\/error-tools-fmtprodmsg' \);/g" {} \; - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\"/\"@stdlib\/error-tools-fmtprodmsg\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^0.0.x'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "::set-output name=remote-exists::true" - else - echo "::set-output name=remote-exists::false" - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - uses: act10ns/slack@v1 - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "::set-output name=remote-exists::true" - else - echo "::set-output name=remote-exists::false" - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - uses: actions/setup-node@v2 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "::set-output name=alias::${alias}" - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -165,7 +158,7 @@ bool = isUnityProbabilityArray( null ); ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -229,9 +222,9 @@ Copyright © 2016-2022. The Stdlib [Authors][stdlib-authors]. -[@stdlib/assert/is-probability]: https://github.com/stdlib-js/assert-is-probability +[@stdlib/assert/is-probability]: https://github.com/stdlib-js/assert-is-probability/tree/esm -[@stdlib/assert/is-probability-array]: https://github.com/stdlib-js/assert-is-probability-array +[@stdlib/assert/is-probability-array]: https://github.com/stdlib-js/assert-is-probability-array/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 1121550..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,103 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var isUnityProbabilityArray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x; - var i; - - x = []; - for ( i = 0; i < len; i++ ) { - x.push( 1.0/len ); - } - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: we are testing the worst case scenario where a function must scan the entire array before finding a failing value. - x[ len-1 ] = i * 3.14; - bool = isUnityProbabilityArray( x ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( isBoolean( bool ) ) { - b.pass( 'benchmark finished' ); - } else { - b.fail( 'should return a boolean' ); - } - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':len='+len, f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index 6fcd715..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/assert/is-unity-probability-array" -click B href "https://github.com/stdlib-js/assert-is-unity-probability-array/tree/main" -click C href "https://github.com/stdlib-js/assert-is-unity-probability-array/tree/production" -click D href "https://github.com/stdlib-js/assert-is-unity-probability-array/tree/esm" -click E href "https://github.com/stdlib-js/assert-is-unity-probability-array/tree/deno" -click F href "https://github.com/stdlib-js/assert-is-unity-probability-array/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/assert/is-unity-probability-array -[production-url]: https://github.com/stdlib-js/assert-is-unity-probability-array/tree/production -[deno-url]: https://github.com/stdlib-js/assert-is-unity-probability-array/tree/deno -[umd-url]: https://github.com/stdlib-js/assert-is-unity-probability-array/tree/umd -[esm-url]: https://github.com/stdlib-js/assert-is-unity-probability-array/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index a2414be..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,29 +0,0 @@ - -{{alias}}( value ) - Tests if a value is an array of probabilities that sum to one. - - Parameters - ---------- - value: any - Value to test. - - Returns - ------- - bool: boolean - Boolean indicating whether value is an array of probabilities that sum - to one. - - Examples - -------- - > var bool = {{alias}}( [ 0.25, 0.5, 0.25 ] ) - true - > bool = {{alias}}( new {{alias:@stdlib/array/uint8}}( [ 0, 1 ] ) ) - true - > bool = {{alias}}( [ 0.4, 0.4, 0.4 ] ) - false - > bool = {{alias}}( [ 3.14, 0.0 ] ) - false - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 6b41658..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,34 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import isUnityProbabilityArray = require( './index' ); - - -// TESTS // - -// The function returns a boolean... -{ - isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] ); // $ExpectType boolean - isUnityProbabilityArray( [ 2, 3 ] ); // $ExpectType boolean -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - isUnityProbabilityArray(); // $ExpectError - isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ], 123 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index b0b6bbc..0000000 --- a/examples/index.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var Uint8Array = require( '@stdlib/array-uint8' ); -var isUnityProbabilityArray = require( './../lib' ); - -var arr = [ 0.0, 1.0 ]; -console.log( isUnityProbabilityArray( arr ) ); -// => true - -arr = [ 0.5, 0.25, 0.25 ]; -console.log( isUnityProbabilityArray( arr ) ); -// => true - -arr = new Uint8Array( [ 0, 0, 1, 0 ] ); -console.log( isUnityProbabilityArray( arr ) ); -// => true - -arr = [ 0.4, 0.4, 0.4 ]; -console.log( isUnityProbabilityArray( arr ) ); -// => false - -arr = [ 3.14, -1.0 ]; -console.log( isUnityProbabilityArray( arr ) ); -// => false - -console.log( isUnityProbabilityArray( [] ) ); -// => false - -console.log( isUnityProbabilityArray( null ) ); -// => false diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..44ce222 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-typed-array@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array@esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-number@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/math-base-utils-absolute-difference@esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/constants-float64-sqrt-eps@esm/index.mjs";function n(n){var d,m;if(t(n)){for(d=0,m=0;m1||n[m]<0)return!1;d+=n[m]}return r(d,1)<=i}if(s(n)){for(d=0,m=0;m1||n[m]<0)return!1;d+=n[m]}return r(d,1)<=i}return!1}export{n as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..0e27c38 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isTypedArray from '@stdlib/assert-is-typed-array' ;\nimport isArray from '@stdlib/assert-is-array' ;\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number' ;\nimport absdiff from '@stdlib/math-base-utils-absolute-difference' ;\nimport FLOAT64_SQRT_EPS from '@stdlib/constants-float64-sqrt-eps' ;\n\n\n// MAIN //\n\n/**\n* Tests if a value is an array of probabilities that sum to one.\n*\n* @param {*} v - value to test\n* @returns {boolean} boolean indicating if a value is a probability array\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] );\n* // returns true\n*\n* @example\n* var bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) );\n* // returns true\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] );\n* // returns false\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 3.14, 0.0 ] );\n* // returns false\n*/\nfunction isUnityProbabilityArray( v ) {\n\tvar sum;\n\tvar i;\n\tif ( isArray( v ) ) {\n\t\tsum = 0.0;\n\t\tfor ( i = 0; i < v.length; i++ ) {\n\t\t\tif (\n\t\t\t\t!isNumber( v[ i ] ) ||\n\t\t\t\tv[ i ] > 1.0 ||\n\t\t\t\tv[ i ] < 0.0\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tsum += v[ i ];\n\t\t}\n\t\treturn ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS );\n\t}\n\tif ( isTypedArray( v ) ) {\n\t\tsum = 0.0;\n\t\tfor ( i = 0; i < v.length; i++ ) {\n\t\t\tif (\n\t\t\t\tv[ i ] > 1.0 ||\n\t\t\t\tv[ i ] < 0.0\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tsum += v[ i ];\n\t\t}\n\t\treturn ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS );\n\t}\n\treturn false;\n}\n\n\n// EXPORTS //\n\nexport default isUnityProbabilityArray;\n"],"names":["isUnityProbabilityArray","v","sum","i","isArray","length","isNumber","absdiff","FLOAT64_SQRT_EPS","isTypedArray"],"mappings":";;odAqDA,SAASA,EAAyBC,GACjC,IAAIC,EACAC,EACJ,GAAKC,EAASH,GAAM,CAEnB,IADAC,EAAM,EACAC,EAAI,EAAGA,EAAIF,EAAEI,OAAQF,IAAM,CAChC,IACEG,EAAUL,EAAGE,KACdF,EAAGE,GAAM,GACTF,EAAGE,GAAM,EAET,OAAO,EAERD,GAAOD,EAAGE,GAEX,OAASI,EAASL,EAAK,IAASM,EAEjC,GAAKC,EAAcR,GAAM,CAExB,IADAC,EAAM,EACAC,EAAI,EAAGA,EAAIF,EAAEI,OAAQF,IAAM,CAChC,GACCF,EAAGE,GAAM,GACTF,EAAGE,GAAM,EAET,OAAO,EAERD,GAAOD,EAAGE,GAEX,OAASI,EAASL,EAAK,IAASM,EAEjC,OAAO"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 13a67d1..0000000 --- a/lib/index.js +++ /dev/null @@ -1,49 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Test if a value is an array of probabilities that sum to one. -* -* @module @stdlib/assert-is-unity-probability-array -* -* @example -* var isUnityProbabilityArray = require( '@stdlib/assert-is-unity-probability-array' ); -* -* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] ); -* // returns true -* -* bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) ); -* // returns true -* -* bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] ); -* // returns false -* -* bool = isUnityProbabilityArray( [ 3.14, 0.0 ] ); -* // returns false -*/ - -// 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 d0bda40..0000000 --- a/lib/main.js +++ /dev/null @@ -1,90 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -var isArray = require( '@stdlib/assert-is-array' ); -var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var absdiff = require( '@stdlib/math-base-utils-absolute-difference' ); -var FLOAT64_SQRT_EPS = require( '@stdlib/constants-float64-sqrt-eps' ); - - -// MAIN // - -/** -* Tests if a value is an array of probabilities that sum to one. -* -* @param {*} v - value to test -* @returns {boolean} boolean indicating if a value is a probability array -* -* @example -* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] ); -* // returns true -* -* @example -* var bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) ); -* // returns true -* -* @example -* var bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] ); -* // returns false -* -* @example -* var bool = isUnityProbabilityArray( [ 3.14, 0.0 ] ); -* // returns false -*/ -function isUnityProbabilityArray( v ) { - var sum; - var i; - if ( isArray( v ) ) { - sum = 0.0; - for ( i = 0; i < v.length; i++ ) { - if ( - !isNumber( v[ i ] ) || - v[ i ] > 1.0 || - v[ i ] < 0.0 - ) { - return false; - } - sum += v[ i ]; - } - return ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS ); - } - if ( isTypedArray( v ) ) { - sum = 0.0; - for ( i = 0; i < v.length; i++ ) { - if ( - v[ i ] > 1.0 || - v[ i ] < 0.0 - ) { - return false; - } - sum += v[ i ]; - } - return ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS ); - } - return false; -} - - -// EXPORTS // - -module.exports = isUnityProbabilityArray; diff --git a/package.json b/package.json index 16e31f9..bf1e9c3 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.7", "description": "Test if a value is an array of probabilities that sum to one.", "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" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,47 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-array": "^0.0.x", - "@stdlib/assert-is-number": "^0.0.x", - "@stdlib/assert-is-typed-array": "^0.0.x", - "@stdlib/constants-float64-sqrt-eps": "^0.0.x", - "@stdlib/math-base-utils-absolute-difference": "^0.0.x", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x" - }, - "devDependencies": { - "@stdlib/array-float32": "^0.0.x", - "@stdlib/array-float64": "^0.0.x", - "@stdlib/array-int16": "^0.0.x", - "@stdlib/array-int32": "^0.0.x", - "@stdlib/array-int8": "^0.0.x", - "@stdlib/array-uint16": "^0.0.x", - "@stdlib/array-uint32": "^0.0.x", - "@stdlib/array-uint8": "^0.0.x", - "@stdlib/array-uint8c": "^0.0.x", - "@stdlib/assert-is-boolean": "^0.0.x", - "@stdlib/bench": "^0.0.x", - "@stdlib/buffer-from-array": "^0.0.x", - "@stdlib/math-base-special-pow": "^0.0.x", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-spec": "5.x.x" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdassert", @@ -105,4 +41,4 @@ "type": "patreon", "url": "https://www.patreon.com/athan" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..03becbe --- /dev/null +++ b/stats.html @@ -0,0 +1,2689 @@ + + + + + + + + RollUp Visualizer + + + +
+ + + + + diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 7f6a066..0000000 --- a/test/test.js +++ /dev/null @@ -1,106 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Int8Array = require( '@stdlib/array-int8' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Float64Array = require( '@stdlib/array-float64' ); -var array2buffer = require( '@stdlib/buffer-from-array' ); -var isUnityProbabilityArray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof isUnityProbabilityArray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns `true` if provided an array of probabilities that sum to one', function test( t ) { - var values; - var i; - - values = [ - new Int8Array( [ 0, 0, 1 ] ), - new Uint8Array( [ 1, 0, 0 ] ), - new Uint8ClampedArray( [ 0, 1 ] ), - new Int16Array( [ 0, 0, 1, 0 ] ), - new Uint16Array( [ 1 ] ), - new Int32Array( [ 1, 0, 0 ] ), - new Uint32Array( [ 0, 1, 0 ] ), - new Float32Array( [ 0.0, 0.5, 0.5 ] ), - new Float64Array( [ 0.25, 0.25, 0.5 ] ), - [ 0.5, 0.25, 0.25 ] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.strictEqual( isUnityProbabilityArray( values[i] ), true, 'returns true when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function allows a difference in sum within floating-point epsilon', function test( t ) { - var bool = isUnityProbabilityArray( [ 0.1, 0.2, 0.1, 0.1, 0.2, 0.2, 0.1 ] ); - t.strictEqual( bool, true, 'returns true' ); - t.end(); -}); - -tape( 'the function returns `false` if not provided an array of probabilities that sum to one', function test( t ) { - var values; - var i; - - values = [ - '10', - '01', - '0.5', - '5', - 5, - NaN, - null, - void 0, - true, - [], - [ 5, null ], - [ 5, '5' ], - [ 1.0, 3.14 ], - [ -1.0, 1.0, 1.0 ], - [ 0.25, 0.33, 0.5 ], - new Float64Array( [ 0.25, 0.33, 0.5 ] ), - new Float64Array( [ 0.25, 1.33, 0.5 ] ), - new Float64Array( [ 0.25, -0.33, 0.5 ] ), - {}, - function noop() {}, - array2buffer( [ 1, 1, 0 ] ) - ]; - - for ( i = 0; i < values.length; i++ ) { - t.strictEqual( isUnityProbabilityArray( values[i] ), false, 'returns false when provided '+values[i] ); - } - t.end(); -}); From 6316297207ff1bda0b3eb7f3261fadf325e65f63 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 1 Nov 2022 04:28:28 +0000 Subject: [PATCH 024/133] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 3c769e3..16e31f9 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,8 @@ "@stdlib/assert-is-number": "^0.0.x", "@stdlib/assert-is-typed-array": "^0.0.x", "@stdlib/constants-float64-sqrt-eps": "^0.0.x", - "@stdlib/math-base-utils-absolute-difference": "^0.0.x" + "@stdlib/math-base-utils-absolute-difference": "^0.0.x", + "@stdlib/error-tools-fmtprodmsg": "^0.0.x" }, "devDependencies": { "@stdlib/array-float32": "^0.0.x", @@ -104,4 +105,4 @@ "type": "patreon", "url": "https://www.patreon.com/athan" } -} +} \ No newline at end of file From daf51e5ea1e7a22ca63c00202007996f52084e0a Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 1 Nov 2022 19:10:30 +0000 Subject: [PATCH 025/133] Remove files --- index.d.ts | 48 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 2689 ------------------------------------------------- 4 files changed, 2742 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index f77442a..0000000 --- a/index.d.ts +++ /dev/null @@ -1,48 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 2.0 - -/** -* Tests if a value is an array of probabilities that sum to one. -* -* @param v - value to test -* @returns boolean indicating if a value is a probability array -* -* @example -* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] ); -* // returns true -* -* @example -* var bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) ); -* // returns true -* -* @example -* var bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] ); -* // returns false -* -* @example -* var bool = isUnityProbabilityArray( [ 3.14, 0.0 ] ); -* // returns false -*/ -declare function isUnityProbabilityArray( v: any ): boolean; - - -// EXPORTS // - -export = isUnityProbabilityArray; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 44ce222..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-typed-array@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array@esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-number@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/math-base-utils-absolute-difference@esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/constants-float64-sqrt-eps@esm/index.mjs";function n(n){var d,m;if(t(n)){for(d=0,m=0;m1||n[m]<0)return!1;d+=n[m]}return r(d,1)<=i}if(s(n)){for(d=0,m=0;m1||n[m]<0)return!1;d+=n[m]}return r(d,1)<=i}return!1}export{n as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 0e27c38..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isTypedArray from '@stdlib/assert-is-typed-array' ;\nimport isArray from '@stdlib/assert-is-array' ;\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number' ;\nimport absdiff from '@stdlib/math-base-utils-absolute-difference' ;\nimport FLOAT64_SQRT_EPS from '@stdlib/constants-float64-sqrt-eps' ;\n\n\n// MAIN //\n\n/**\n* Tests if a value is an array of probabilities that sum to one.\n*\n* @param {*} v - value to test\n* @returns {boolean} boolean indicating if a value is a probability array\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] );\n* // returns true\n*\n* @example\n* var bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) );\n* // returns true\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] );\n* // returns false\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 3.14, 0.0 ] );\n* // returns false\n*/\nfunction isUnityProbabilityArray( v ) {\n\tvar sum;\n\tvar i;\n\tif ( isArray( v ) ) {\n\t\tsum = 0.0;\n\t\tfor ( i = 0; i < v.length; i++ ) {\n\t\t\tif (\n\t\t\t\t!isNumber( v[ i ] ) ||\n\t\t\t\tv[ i ] > 1.0 ||\n\t\t\t\tv[ i ] < 0.0\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tsum += v[ i ];\n\t\t}\n\t\treturn ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS );\n\t}\n\tif ( isTypedArray( v ) ) {\n\t\tsum = 0.0;\n\t\tfor ( i = 0; i < v.length; i++ ) {\n\t\t\tif (\n\t\t\t\tv[ i ] > 1.0 ||\n\t\t\t\tv[ i ] < 0.0\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tsum += v[ i ];\n\t\t}\n\t\treturn ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS );\n\t}\n\treturn false;\n}\n\n\n// EXPORTS //\n\nexport default isUnityProbabilityArray;\n"],"names":["isUnityProbabilityArray","v","sum","i","isArray","length","isNumber","absdiff","FLOAT64_SQRT_EPS","isTypedArray"],"mappings":";;odAqDA,SAASA,EAAyBC,GACjC,IAAIC,EACAC,EACJ,GAAKC,EAASH,GAAM,CAEnB,IADAC,EAAM,EACAC,EAAI,EAAGA,EAAIF,EAAEI,OAAQF,IAAM,CAChC,IACEG,EAAUL,EAAGE,KACdF,EAAGE,GAAM,GACTF,EAAGE,GAAM,EAET,OAAO,EAERD,GAAOD,EAAGE,GAEX,OAASI,EAASL,EAAK,IAASM,EAEjC,GAAKC,EAAcR,GAAM,CAExB,IADAC,EAAM,EACAC,EAAI,EAAGA,EAAIF,EAAEI,OAAQF,IAAM,CAChC,GACCF,EAAGE,GAAM,GACTF,EAAGE,GAAM,EAET,OAAO,EAERD,GAAOD,EAAGE,GAEX,OAASI,EAASL,EAAK,IAASM,EAEjC,OAAO"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 03becbe..0000000 --- a/stats.html +++ /dev/null @@ -1,2689 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From 50c2ff54f1b3624321022cfae245839c1a979abc Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 1 Nov 2022 19:11:18 +0000 Subject: [PATCH 026/133] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 62 - .github/workflows/cancel.yml | 56 - .github/workflows/close_pull_requests.yml | 44 - .github/workflows/examples.yml | 62 - .github/workflows/npm_downloads.yml | 108 - .github/workflows/productionize.yml | 760 ---- .github/workflows/publish.yml | 117 - .github/workflows/test.yml | 92 - .github/workflows/test_bundles.yml | 180 - .github/workflows/test_coverage.yml | 123 - .github/workflows/test_install.yml | 83 - .gitignore | 178 - .npmignore | 227 -- .npmrc | 28 - CHANGELOG.md | 5 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 41 +- benchmark/benchmark.js | 103 - branches.md | 53 - docs/repl.txt | 29 - docs/types/test.ts | 34 - examples/index.js | 48 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 49 - lib/main.js | 90 - package.json | 70 +- stats.html | 4044 +++++++++++++++++++++ test/test.js | 106 - 37 files changed, 4069 insertions(+), 3507 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 0fd4d6c..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index ca9a8d9..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2022-11-01T01:46:37.510Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 75a4c32..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/assert/is-unity-probability-array) 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 a5cb54c..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/assert/is-unity-probability-array) 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 0e5537b..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: '49 1 * * 1' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - uses: actions/upload-artifact@v3 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - uses: distributhor/workflow-webhook@v3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 9113bfe..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,760 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - uses: actions/checkout@v3 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Format error messages: - - name: 'Replace double quotes with single quotes in rewritten format string error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\( \"([a-zA-Z0-9]+)\"/Error\( format\( '\1'/g" {} \; - - # Format string literal error messages: - - name: 'Replace double quotes with single quotes in rewritten string literal error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\(\"([a-zA-Z0-9]+)\"\)/Error\( format\( '\1' \)/g" {} \; - - # Format code: - - name: 'Replace double quotes with single quotes in inserted `require` calls' - run: | - find . -name "*.js" -exec sed -E -i "s/require\( ?\"@stdlib\/error-tools-fmtprodmsg\" ?\);/require\( '@stdlib\/error-tools-fmtprodmsg' \);/g" {} \; - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\"/\"@stdlib\/error-tools-fmtprodmsg\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^0.0.x'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - uses: act10ns/slack@v1 - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -165,7 +158,7 @@ bool = isUnityProbabilityArray( null ); ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -229,9 +222,9 @@ Copyright © 2016-2022. The Stdlib [Authors][stdlib-authors]. -[@stdlib/assert/is-probability]: https://github.com/stdlib-js/assert-is-probability +[@stdlib/assert/is-probability]: https://github.com/stdlib-js/assert-is-probability/tree/esm -[@stdlib/assert/is-probability-array]: https://github.com/stdlib-js/assert-is-probability-array +[@stdlib/assert/is-probability-array]: https://github.com/stdlib-js/assert-is-probability-array/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 1121550..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,103 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var isUnityProbabilityArray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x; - var i; - - x = []; - for ( i = 0; i < len; i++ ) { - x.push( 1.0/len ); - } - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: we are testing the worst case scenario where a function must scan the entire array before finding a failing value. - x[ len-1 ] = i * 3.14; - bool = isUnityProbabilityArray( x ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( isBoolean( bool ) ) { - b.pass( 'benchmark finished' ); - } else { - b.fail( 'should return a boolean' ); - } - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':len='+len, f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index 6fcd715..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/assert/is-unity-probability-array" -click B href "https://github.com/stdlib-js/assert-is-unity-probability-array/tree/main" -click C href "https://github.com/stdlib-js/assert-is-unity-probability-array/tree/production" -click D href "https://github.com/stdlib-js/assert-is-unity-probability-array/tree/esm" -click E href "https://github.com/stdlib-js/assert-is-unity-probability-array/tree/deno" -click F href "https://github.com/stdlib-js/assert-is-unity-probability-array/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/assert/is-unity-probability-array -[production-url]: https://github.com/stdlib-js/assert-is-unity-probability-array/tree/production -[deno-url]: https://github.com/stdlib-js/assert-is-unity-probability-array/tree/deno -[umd-url]: https://github.com/stdlib-js/assert-is-unity-probability-array/tree/umd -[esm-url]: https://github.com/stdlib-js/assert-is-unity-probability-array/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index a2414be..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,29 +0,0 @@ - -{{alias}}( value ) - Tests if a value is an array of probabilities that sum to one. - - Parameters - ---------- - value: any - Value to test. - - Returns - ------- - bool: boolean - Boolean indicating whether value is an array of probabilities that sum - to one. - - Examples - -------- - > var bool = {{alias}}( [ 0.25, 0.5, 0.25 ] ) - true - > bool = {{alias}}( new {{alias:@stdlib/array/uint8}}( [ 0, 1 ] ) ) - true - > bool = {{alias}}( [ 0.4, 0.4, 0.4 ] ) - false - > bool = {{alias}}( [ 3.14, 0.0 ] ) - false - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 6b41658..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,34 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import isUnityProbabilityArray = require( './index' ); - - -// TESTS // - -// The function returns a boolean... -{ - isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] ); // $ExpectType boolean - isUnityProbabilityArray( [ 2, 3 ] ); // $ExpectType boolean -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - isUnityProbabilityArray(); // $ExpectError - isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ], 123 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index b0b6bbc..0000000 --- a/examples/index.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var Uint8Array = require( '@stdlib/array-uint8' ); -var isUnityProbabilityArray = require( './../lib' ); - -var arr = [ 0.0, 1.0 ]; -console.log( isUnityProbabilityArray( arr ) ); -// => true - -arr = [ 0.5, 0.25, 0.25 ]; -console.log( isUnityProbabilityArray( arr ) ); -// => true - -arr = new Uint8Array( [ 0, 0, 1, 0 ] ); -console.log( isUnityProbabilityArray( arr ) ); -// => true - -arr = [ 0.4, 0.4, 0.4 ]; -console.log( isUnityProbabilityArray( arr ) ); -// => false - -arr = [ 3.14, -1.0 ]; -console.log( isUnityProbabilityArray( arr ) ); -// => false - -console.log( isUnityProbabilityArray( [] ) ); -// => false - -console.log( isUnityProbabilityArray( null ) ); -// => false diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..44ce222 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-typed-array@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array@esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-number@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/math-base-utils-absolute-difference@esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/constants-float64-sqrt-eps@esm/index.mjs";function n(n){var d,m;if(t(n)){for(d=0,m=0;m1||n[m]<0)return!1;d+=n[m]}return r(d,1)<=i}if(s(n)){for(d=0,m=0;m1||n[m]<0)return!1;d+=n[m]}return r(d,1)<=i}return!1}export{n as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..0faf02c --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isTypedArray from '@stdlib/assert-is-typed-array' ;\nimport isArray from '@stdlib/assert-is-array' ;\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number' ;\nimport absdiff from '@stdlib/math-base-utils-absolute-difference' ;\nimport FLOAT64_SQRT_EPS from '@stdlib/constants-float64-sqrt-eps' ;\n\n\n// MAIN //\n\n/**\n* Tests if a value is an array of probabilities that sum to one.\n*\n* @param {*} v - value to test\n* @returns {boolean} boolean indicating if a value is a probability array\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] );\n* // returns true\n*\n* @example\n* var bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) );\n* // returns true\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] );\n* // returns false\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 3.14, 0.0 ] );\n* // returns false\n*/\nfunction isUnityProbabilityArray( v ) {\n\tvar sum;\n\tvar i;\n\tif ( isArray( v ) ) {\n\t\tsum = 0.0;\n\t\tfor ( i = 0; i < v.length; i++ ) {\n\t\t\tif (\n\t\t\t\t!isNumber( v[ i ] ) ||\n\t\t\t\tv[ i ] > 1.0 ||\n\t\t\t\tv[ i ] < 0.0\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tsum += v[ i ];\n\t\t}\n\t\treturn ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS );\n\t}\n\tif ( isTypedArray( v ) ) {\n\t\tsum = 0.0;\n\t\tfor ( i = 0; i < v.length; i++ ) {\n\t\t\tif (\n\t\t\t\tv[ i ] > 1.0 ||\n\t\t\t\tv[ i ] < 0.0\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tsum += v[ i ];\n\t\t}\n\t\treturn ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS );\n\t}\n\treturn false;\n}\n\n\n// EXPORTS //\n\nexport default isUnityProbabilityArray;\n"],"names":["isUnityProbabilityArray","v","sum","i","isArray","length","isNumber","absdiff","FLOAT64_SQRT_EPS","isTypedArray"],"mappings":";;odAqDA,SAASA,EAAyBC,GACjC,IAAIC,EACAC,EACJ,GAAKC,EAASH,GAAM,CAEnB,IADAC,EAAM,EACAC,EAAI,EAAGA,EAAIF,EAAEI,OAAQF,IAAM,CAChC,IACEG,EAAUL,EAAGE,KACdF,EAAGE,GAAM,GACTF,EAAGE,GAAM,EAET,OAAO,EAERD,GAAOD,EAAGE,EACV,CACD,OAASI,EAASL,EAAK,IAASM,CAChC,CACD,GAAKC,EAAcR,GAAM,CAExB,IADAC,EAAM,EACAC,EAAI,EAAGA,EAAIF,EAAEI,OAAQF,IAAM,CAChC,GACCF,EAAGE,GAAM,GACTF,EAAGE,GAAM,EAET,OAAO,EAERD,GAAOD,EAAGE,EACV,CACD,OAASI,EAASL,EAAK,IAASM,CAChC,CACD,OAAO,CACR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 13a67d1..0000000 --- a/lib/index.js +++ /dev/null @@ -1,49 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Test if a value is an array of probabilities that sum to one. -* -* @module @stdlib/assert-is-unity-probability-array -* -* @example -* var isUnityProbabilityArray = require( '@stdlib/assert-is-unity-probability-array' ); -* -* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] ); -* // returns true -* -* bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) ); -* // returns true -* -* bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] ); -* // returns false -* -* bool = isUnityProbabilityArray( [ 3.14, 0.0 ] ); -* // returns false -*/ - -// 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 d0bda40..0000000 --- a/lib/main.js +++ /dev/null @@ -1,90 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -var isArray = require( '@stdlib/assert-is-array' ); -var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var absdiff = require( '@stdlib/math-base-utils-absolute-difference' ); -var FLOAT64_SQRT_EPS = require( '@stdlib/constants-float64-sqrt-eps' ); - - -// MAIN // - -/** -* Tests if a value is an array of probabilities that sum to one. -* -* @param {*} v - value to test -* @returns {boolean} boolean indicating if a value is a probability array -* -* @example -* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] ); -* // returns true -* -* @example -* var bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) ); -* // returns true -* -* @example -* var bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] ); -* // returns false -* -* @example -* var bool = isUnityProbabilityArray( [ 3.14, 0.0 ] ); -* // returns false -*/ -function isUnityProbabilityArray( v ) { - var sum; - var i; - if ( isArray( v ) ) { - sum = 0.0; - for ( i = 0; i < v.length; i++ ) { - if ( - !isNumber( v[ i ] ) || - v[ i ] > 1.0 || - v[ i ] < 0.0 - ) { - return false; - } - sum += v[ i ]; - } - return ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS ); - } - if ( isTypedArray( v ) ) { - sum = 0.0; - for ( i = 0; i < v.length; i++ ) { - if ( - v[ i ] > 1.0 || - v[ i ] < 0.0 - ) { - return false; - } - sum += v[ i ]; - } - return ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS ); - } - return false; -} - - -// EXPORTS // - -module.exports = isUnityProbabilityArray; diff --git a/package.json b/package.json index 16e31f9..bf1e9c3 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.7", "description": "Test if a value is an array of probabilities that sum to one.", "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" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,47 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-array": "^0.0.x", - "@stdlib/assert-is-number": "^0.0.x", - "@stdlib/assert-is-typed-array": "^0.0.x", - "@stdlib/constants-float64-sqrt-eps": "^0.0.x", - "@stdlib/math-base-utils-absolute-difference": "^0.0.x", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x" - }, - "devDependencies": { - "@stdlib/array-float32": "^0.0.x", - "@stdlib/array-float64": "^0.0.x", - "@stdlib/array-int16": "^0.0.x", - "@stdlib/array-int32": "^0.0.x", - "@stdlib/array-int8": "^0.0.x", - "@stdlib/array-uint16": "^0.0.x", - "@stdlib/array-uint32": "^0.0.x", - "@stdlib/array-uint8": "^0.0.x", - "@stdlib/array-uint8c": "^0.0.x", - "@stdlib/assert-is-boolean": "^0.0.x", - "@stdlib/bench": "^0.0.x", - "@stdlib/buffer-from-array": "^0.0.x", - "@stdlib/math-base-special-pow": "^0.0.x", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-spec": "5.x.x" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdassert", @@ -105,4 +41,4 @@ "type": "patreon", "url": "https://www.patreon.com/athan" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..8e9ad2e --- /dev/null +++ b/stats.html @@ -0,0 +1,4044 @@ + + + + + + + + RollUp Visualizer + + + +
+ + + + + diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 7f6a066..0000000 --- a/test/test.js +++ /dev/null @@ -1,106 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Int8Array = require( '@stdlib/array-int8' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Float64Array = require( '@stdlib/array-float64' ); -var array2buffer = require( '@stdlib/buffer-from-array' ); -var isUnityProbabilityArray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof isUnityProbabilityArray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns `true` if provided an array of probabilities that sum to one', function test( t ) { - var values; - var i; - - values = [ - new Int8Array( [ 0, 0, 1 ] ), - new Uint8Array( [ 1, 0, 0 ] ), - new Uint8ClampedArray( [ 0, 1 ] ), - new Int16Array( [ 0, 0, 1, 0 ] ), - new Uint16Array( [ 1 ] ), - new Int32Array( [ 1, 0, 0 ] ), - new Uint32Array( [ 0, 1, 0 ] ), - new Float32Array( [ 0.0, 0.5, 0.5 ] ), - new Float64Array( [ 0.25, 0.25, 0.5 ] ), - [ 0.5, 0.25, 0.25 ] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.strictEqual( isUnityProbabilityArray( values[i] ), true, 'returns true when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function allows a difference in sum within floating-point epsilon', function test( t ) { - var bool = isUnityProbabilityArray( [ 0.1, 0.2, 0.1, 0.1, 0.2, 0.2, 0.1 ] ); - t.strictEqual( bool, true, 'returns true' ); - t.end(); -}); - -tape( 'the function returns `false` if not provided an array of probabilities that sum to one', function test( t ) { - var values; - var i; - - values = [ - '10', - '01', - '0.5', - '5', - 5, - NaN, - null, - void 0, - true, - [], - [ 5, null ], - [ 5, '5' ], - [ 1.0, 3.14 ], - [ -1.0, 1.0, 1.0 ], - [ 0.25, 0.33, 0.5 ], - new Float64Array( [ 0.25, 0.33, 0.5 ] ), - new Float64Array( [ 0.25, 1.33, 0.5 ] ), - new Float64Array( [ 0.25, -0.33, 0.5 ] ), - {}, - function noop() {}, - array2buffer( [ 1, 1, 0 ] ) - ]; - - for ( i = 0; i < values.length; i++ ) { - t.strictEqual( isUnityProbabilityArray( values[i] ), false, 'returns false when provided '+values[i] ); - } - t.end(); -}); From 3ff17cc6c7435af4fa134f33ae9289d8b783d0d7 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 4 Nov 2022 00:31:12 +0000 Subject: [PATCH 027/133] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 3c769e3..16e31f9 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,8 @@ "@stdlib/assert-is-number": "^0.0.x", "@stdlib/assert-is-typed-array": "^0.0.x", "@stdlib/constants-float64-sqrt-eps": "^0.0.x", - "@stdlib/math-base-utils-absolute-difference": "^0.0.x" + "@stdlib/math-base-utils-absolute-difference": "^0.0.x", + "@stdlib/error-tools-fmtprodmsg": "^0.0.x" }, "devDependencies": { "@stdlib/array-float32": "^0.0.x", @@ -104,4 +105,4 @@ "type": "patreon", "url": "https://www.patreon.com/athan" } -} +} \ No newline at end of file From d2dbfe84bc337c86f7859246809a0d877652c4ed Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 4 Nov 2022 14:18:18 +0000 Subject: [PATCH 028/133] Remove files --- index.d.ts | 48 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4044 ------------------------------------------------- 4 files changed, 4097 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index f77442a..0000000 --- a/index.d.ts +++ /dev/null @@ -1,48 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 2.0 - -/** -* Tests if a value is an array of probabilities that sum to one. -* -* @param v - value to test -* @returns boolean indicating if a value is a probability array -* -* @example -* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] ); -* // returns true -* -* @example -* var bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) ); -* // returns true -* -* @example -* var bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] ); -* // returns false -* -* @example -* var bool = isUnityProbabilityArray( [ 3.14, 0.0 ] ); -* // returns false -*/ -declare function isUnityProbabilityArray( v: any ): boolean; - - -// EXPORTS // - -export = isUnityProbabilityArray; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 44ce222..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-typed-array@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array@esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-number@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/math-base-utils-absolute-difference@esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/constants-float64-sqrt-eps@esm/index.mjs";function n(n){var d,m;if(t(n)){for(d=0,m=0;m1||n[m]<0)return!1;d+=n[m]}return r(d,1)<=i}if(s(n)){for(d=0,m=0;m1||n[m]<0)return!1;d+=n[m]}return r(d,1)<=i}return!1}export{n as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 0faf02c..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isTypedArray from '@stdlib/assert-is-typed-array' ;\nimport isArray from '@stdlib/assert-is-array' ;\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number' ;\nimport absdiff from '@stdlib/math-base-utils-absolute-difference' ;\nimport FLOAT64_SQRT_EPS from '@stdlib/constants-float64-sqrt-eps' ;\n\n\n// MAIN //\n\n/**\n* Tests if a value is an array of probabilities that sum to one.\n*\n* @param {*} v - value to test\n* @returns {boolean} boolean indicating if a value is a probability array\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] );\n* // returns true\n*\n* @example\n* var bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) );\n* // returns true\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] );\n* // returns false\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 3.14, 0.0 ] );\n* // returns false\n*/\nfunction isUnityProbabilityArray( v ) {\n\tvar sum;\n\tvar i;\n\tif ( isArray( v ) ) {\n\t\tsum = 0.0;\n\t\tfor ( i = 0; i < v.length; i++ ) {\n\t\t\tif (\n\t\t\t\t!isNumber( v[ i ] ) ||\n\t\t\t\tv[ i ] > 1.0 ||\n\t\t\t\tv[ i ] < 0.0\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tsum += v[ i ];\n\t\t}\n\t\treturn ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS );\n\t}\n\tif ( isTypedArray( v ) ) {\n\t\tsum = 0.0;\n\t\tfor ( i = 0; i < v.length; i++ ) {\n\t\t\tif (\n\t\t\t\tv[ i ] > 1.0 ||\n\t\t\t\tv[ i ] < 0.0\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tsum += v[ i ];\n\t\t}\n\t\treturn ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS );\n\t}\n\treturn false;\n}\n\n\n// EXPORTS //\n\nexport default isUnityProbabilityArray;\n"],"names":["isUnityProbabilityArray","v","sum","i","isArray","length","isNumber","absdiff","FLOAT64_SQRT_EPS","isTypedArray"],"mappings":";;odAqDA,SAASA,EAAyBC,GACjC,IAAIC,EACAC,EACJ,GAAKC,EAASH,GAAM,CAEnB,IADAC,EAAM,EACAC,EAAI,EAAGA,EAAIF,EAAEI,OAAQF,IAAM,CAChC,IACEG,EAAUL,EAAGE,KACdF,EAAGE,GAAM,GACTF,EAAGE,GAAM,EAET,OAAO,EAERD,GAAOD,EAAGE,EACV,CACD,OAASI,EAASL,EAAK,IAASM,CAChC,CACD,GAAKC,EAAcR,GAAM,CAExB,IADAC,EAAM,EACAC,EAAI,EAAGA,EAAIF,EAAEI,OAAQF,IAAM,CAChC,GACCF,EAAGE,GAAM,GACTF,EAAGE,GAAM,EAET,OAAO,EAERD,GAAOD,EAAGE,EACV,CACD,OAASI,EAASL,EAAK,IAASM,CAChC,CACD,OAAO,CACR"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 8e9ad2e..0000000 --- a/stats.html +++ /dev/null @@ -1,4044 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From 6c6cabd238961913b9c96b40017d9a2711e8c0c4 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 4 Nov 2022 14:19:07 +0000 Subject: [PATCH 029/133] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 62 - .github/workflows/cancel.yml | 56 - .github/workflows/close_pull_requests.yml | 44 - .github/workflows/examples.yml | 62 - .github/workflows/npm_downloads.yml | 108 - .github/workflows/productionize.yml | 781 ---- .github/workflows/publish.yml | 117 - .github/workflows/test.yml | 92 - .github/workflows/test_bundles.yml | 180 - .github/workflows/test_coverage.yml | 123 - .github/workflows/test_install.yml | 83 - .gitignore | 178 - .npmignore | 227 -- .npmrc | 28 - CHANGELOG.md | 5 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 41 +- benchmark/benchmark.js | 103 - branches.md | 53 - docs/repl.txt | 29 - docs/types/test.ts | 34 - examples/index.js | 48 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 49 - lib/main.js | 90 - package.json | 70 +- stats.html | 4044 +++++++++++++++++++++ test/test.js | 106 - 37 files changed, 4069 insertions(+), 3528 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 0fd4d6c..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 4700d3b..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2022-11-03T22:39:50.380Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 75a4c32..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/assert/is-unity-probability-array) 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 a5cb54c..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/assert/is-unity-probability-array) 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 0e5537b..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: '49 1 * * 1' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - uses: actions/upload-artifact@v3 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - uses: distributhor/workflow-webhook@v3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 37ddb4f..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,781 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - uses: actions/checkout@v3 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Format error messages: - - name: 'Replace double quotes with single quotes in rewritten format string error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\( \"([a-zA-Z0-9]+)\"/Error\( format\( '\1'/g" {} \; - - # Format string literal error messages: - - name: 'Replace double quotes with single quotes in rewritten string literal error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\(\"([a-zA-Z0-9]+)\"\)/Error\( format\( '\1' \)/g" {} \; - - # Format code: - - name: 'Replace double quotes with single quotes in inserted `require` calls' - run: | - find . -name "*.js" -exec sed -E -i "s/require\( ?\"@stdlib\/error-tools-fmtprodmsg\" ?\);/require\( '@stdlib\/error-tools-fmtprodmsg' \);/g" {} \; - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\"/\"@stdlib\/error-tools-fmtprodmsg\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^0.0.x'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - uses: act10ns/slack@v1 - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -165,7 +158,7 @@ bool = isUnityProbabilityArray( null ); ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -229,9 +222,9 @@ Copyright © 2016-2022. The Stdlib [Authors][stdlib-authors]. -[@stdlib/assert/is-probability]: https://github.com/stdlib-js/assert-is-probability +[@stdlib/assert/is-probability]: https://github.com/stdlib-js/assert-is-probability/tree/esm -[@stdlib/assert/is-probability-array]: https://github.com/stdlib-js/assert-is-probability-array +[@stdlib/assert/is-probability-array]: https://github.com/stdlib-js/assert-is-probability-array/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 1121550..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,103 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var isUnityProbabilityArray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x; - var i; - - x = []; - for ( i = 0; i < len; i++ ) { - x.push( 1.0/len ); - } - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: we are testing the worst case scenario where a function must scan the entire array before finding a failing value. - x[ len-1 ] = i * 3.14; - bool = isUnityProbabilityArray( x ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( isBoolean( bool ) ) { - b.pass( 'benchmark finished' ); - } else { - b.fail( 'should return a boolean' ); - } - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':len='+len, f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index 6fcd715..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/assert/is-unity-probability-array" -click B href "https://github.com/stdlib-js/assert-is-unity-probability-array/tree/main" -click C href "https://github.com/stdlib-js/assert-is-unity-probability-array/tree/production" -click D href "https://github.com/stdlib-js/assert-is-unity-probability-array/tree/esm" -click E href "https://github.com/stdlib-js/assert-is-unity-probability-array/tree/deno" -click F href "https://github.com/stdlib-js/assert-is-unity-probability-array/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/assert/is-unity-probability-array -[production-url]: https://github.com/stdlib-js/assert-is-unity-probability-array/tree/production -[deno-url]: https://github.com/stdlib-js/assert-is-unity-probability-array/tree/deno -[umd-url]: https://github.com/stdlib-js/assert-is-unity-probability-array/tree/umd -[esm-url]: https://github.com/stdlib-js/assert-is-unity-probability-array/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index a2414be..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,29 +0,0 @@ - -{{alias}}( value ) - Tests if a value is an array of probabilities that sum to one. - - Parameters - ---------- - value: any - Value to test. - - Returns - ------- - bool: boolean - Boolean indicating whether value is an array of probabilities that sum - to one. - - Examples - -------- - > var bool = {{alias}}( [ 0.25, 0.5, 0.25 ] ) - true - > bool = {{alias}}( new {{alias:@stdlib/array/uint8}}( [ 0, 1 ] ) ) - true - > bool = {{alias}}( [ 0.4, 0.4, 0.4 ] ) - false - > bool = {{alias}}( [ 3.14, 0.0 ] ) - false - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 6b41658..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,34 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import isUnityProbabilityArray = require( './index' ); - - -// TESTS // - -// The function returns a boolean... -{ - isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] ); // $ExpectType boolean - isUnityProbabilityArray( [ 2, 3 ] ); // $ExpectType boolean -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - isUnityProbabilityArray(); // $ExpectError - isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ], 123 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index b0b6bbc..0000000 --- a/examples/index.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var Uint8Array = require( '@stdlib/array-uint8' ); -var isUnityProbabilityArray = require( './../lib' ); - -var arr = [ 0.0, 1.0 ]; -console.log( isUnityProbabilityArray( arr ) ); -// => true - -arr = [ 0.5, 0.25, 0.25 ]; -console.log( isUnityProbabilityArray( arr ) ); -// => true - -arr = new Uint8Array( [ 0, 0, 1, 0 ] ); -console.log( isUnityProbabilityArray( arr ) ); -// => true - -arr = [ 0.4, 0.4, 0.4 ]; -console.log( isUnityProbabilityArray( arr ) ); -// => false - -arr = [ 3.14, -1.0 ]; -console.log( isUnityProbabilityArray( arr ) ); -// => false - -console.log( isUnityProbabilityArray( [] ) ); -// => false - -console.log( isUnityProbabilityArray( null ) ); -// => false diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..10d3444 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-typed-array@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array@esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-number@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/math-base-utils-absolute-difference@esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/constants-float64-sqrt-eps@v0.0.8-esm/index.mjs";function n(n){var d,m;if(t(n)){for(d=0,m=0;m1||n[m]<0)return!1;d+=n[m]}return r(d,1)<=i}if(s(n)){for(d=0,m=0;m1||n[m]<0)return!1;d+=n[m]}return r(d,1)<=i}return!1}export{n as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..78b17ca --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isTypedArray from '@stdlib/assert-is-typed-array' ;\nimport isArray from '@stdlib/assert-is-array' ;\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number' ;\nimport absdiff from '@stdlib/math-base-utils-absolute-difference' ;\nimport FLOAT64_SQRT_EPS from '@stdlib/constants-float64-sqrt-eps' ;\n\n\n// MAIN //\n\n/**\n* Tests if a value is an array of probabilities that sum to one.\n*\n* @param {*} v - value to test\n* @returns {boolean} boolean indicating if a value is a probability array\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] );\n* // returns true\n*\n* @example\n* var bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) );\n* // returns true\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] );\n* // returns false\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 3.14, 0.0 ] );\n* // returns false\n*/\nfunction isUnityProbabilityArray( v ) {\n\tvar sum;\n\tvar i;\n\tif ( isArray( v ) ) {\n\t\tsum = 0.0;\n\t\tfor ( i = 0; i < v.length; i++ ) {\n\t\t\tif (\n\t\t\t\t!isNumber( v[ i ] ) ||\n\t\t\t\tv[ i ] > 1.0 ||\n\t\t\t\tv[ i ] < 0.0\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tsum += v[ i ];\n\t\t}\n\t\treturn ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS );\n\t}\n\tif ( isTypedArray( v ) ) {\n\t\tsum = 0.0;\n\t\tfor ( i = 0; i < v.length; i++ ) {\n\t\t\tif (\n\t\t\t\tv[ i ] > 1.0 ||\n\t\t\t\tv[ i ] < 0.0\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tsum += v[ i ];\n\t\t}\n\t\treturn ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS );\n\t}\n\treturn false;\n}\n\n\n// EXPORTS //\n\nexport default isUnityProbabilityArray;\n"],"names":["isUnityProbabilityArray","v","sum","i","isArray","length","isNumber","absdiff","FLOAT64_SQRT_EPS","isTypedArray"],"mappings":";;2dAqDA,SAASA,EAAyBC,GACjC,IAAIC,EACAC,EACJ,GAAKC,EAASH,GAAM,CAEnB,IADAC,EAAM,EACAC,EAAI,EAAGA,EAAIF,EAAEI,OAAQF,IAAM,CAChC,IACEG,EAAUL,EAAGE,KACdF,EAAGE,GAAM,GACTF,EAAGE,GAAM,EAET,OAAO,EAERD,GAAOD,EAAGE,EACV,CACD,OAASI,EAASL,EAAK,IAASM,CAChC,CACD,GAAKC,EAAcR,GAAM,CAExB,IADAC,EAAM,EACAC,EAAI,EAAGA,EAAIF,EAAEI,OAAQF,IAAM,CAChC,GACCF,EAAGE,GAAM,GACTF,EAAGE,GAAM,EAET,OAAO,EAERD,GAAOD,EAAGE,EACV,CACD,OAASI,EAASL,EAAK,IAASM,CAChC,CACD,OAAO,CACR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 13a67d1..0000000 --- a/lib/index.js +++ /dev/null @@ -1,49 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Test if a value is an array of probabilities that sum to one. -* -* @module @stdlib/assert-is-unity-probability-array -* -* @example -* var isUnityProbabilityArray = require( '@stdlib/assert-is-unity-probability-array' ); -* -* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] ); -* // returns true -* -* bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) ); -* // returns true -* -* bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] ); -* // returns false -* -* bool = isUnityProbabilityArray( [ 3.14, 0.0 ] ); -* // returns false -*/ - -// 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 d0bda40..0000000 --- a/lib/main.js +++ /dev/null @@ -1,90 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -var isArray = require( '@stdlib/assert-is-array' ); -var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var absdiff = require( '@stdlib/math-base-utils-absolute-difference' ); -var FLOAT64_SQRT_EPS = require( '@stdlib/constants-float64-sqrt-eps' ); - - -// MAIN // - -/** -* Tests if a value is an array of probabilities that sum to one. -* -* @param {*} v - value to test -* @returns {boolean} boolean indicating if a value is a probability array -* -* @example -* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] ); -* // returns true -* -* @example -* var bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) ); -* // returns true -* -* @example -* var bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] ); -* // returns false -* -* @example -* var bool = isUnityProbabilityArray( [ 3.14, 0.0 ] ); -* // returns false -*/ -function isUnityProbabilityArray( v ) { - var sum; - var i; - if ( isArray( v ) ) { - sum = 0.0; - for ( i = 0; i < v.length; i++ ) { - if ( - !isNumber( v[ i ] ) || - v[ i ] > 1.0 || - v[ i ] < 0.0 - ) { - return false; - } - sum += v[ i ]; - } - return ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS ); - } - if ( isTypedArray( v ) ) { - sum = 0.0; - for ( i = 0; i < v.length; i++ ) { - if ( - v[ i ] > 1.0 || - v[ i ] < 0.0 - ) { - return false; - } - sum += v[ i ]; - } - return ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS ); - } - return false; -} - - -// EXPORTS // - -module.exports = isUnityProbabilityArray; diff --git a/package.json b/package.json index 16e31f9..bf1e9c3 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.7", "description": "Test if a value is an array of probabilities that sum to one.", "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" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,47 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-array": "^0.0.x", - "@stdlib/assert-is-number": "^0.0.x", - "@stdlib/assert-is-typed-array": "^0.0.x", - "@stdlib/constants-float64-sqrt-eps": "^0.0.x", - "@stdlib/math-base-utils-absolute-difference": "^0.0.x", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x" - }, - "devDependencies": { - "@stdlib/array-float32": "^0.0.x", - "@stdlib/array-float64": "^0.0.x", - "@stdlib/array-int16": "^0.0.x", - "@stdlib/array-int32": "^0.0.x", - "@stdlib/array-int8": "^0.0.x", - "@stdlib/array-uint16": "^0.0.x", - "@stdlib/array-uint32": "^0.0.x", - "@stdlib/array-uint8": "^0.0.x", - "@stdlib/array-uint8c": "^0.0.x", - "@stdlib/assert-is-boolean": "^0.0.x", - "@stdlib/bench": "^0.0.x", - "@stdlib/buffer-from-array": "^0.0.x", - "@stdlib/math-base-special-pow": "^0.0.x", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-spec": "5.x.x" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdassert", @@ -105,4 +41,4 @@ "type": "patreon", "url": "https://www.patreon.com/athan" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..662e5c5 --- /dev/null +++ b/stats.html @@ -0,0 +1,4044 @@ + + + + + + + + RollUp Visualizer + + + +
+ + + + + diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 7f6a066..0000000 --- a/test/test.js +++ /dev/null @@ -1,106 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Int8Array = require( '@stdlib/array-int8' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Float64Array = require( '@stdlib/array-float64' ); -var array2buffer = require( '@stdlib/buffer-from-array' ); -var isUnityProbabilityArray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof isUnityProbabilityArray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns `true` if provided an array of probabilities that sum to one', function test( t ) { - var values; - var i; - - values = [ - new Int8Array( [ 0, 0, 1 ] ), - new Uint8Array( [ 1, 0, 0 ] ), - new Uint8ClampedArray( [ 0, 1 ] ), - new Int16Array( [ 0, 0, 1, 0 ] ), - new Uint16Array( [ 1 ] ), - new Int32Array( [ 1, 0, 0 ] ), - new Uint32Array( [ 0, 1, 0 ] ), - new Float32Array( [ 0.0, 0.5, 0.5 ] ), - new Float64Array( [ 0.25, 0.25, 0.5 ] ), - [ 0.5, 0.25, 0.25 ] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.strictEqual( isUnityProbabilityArray( values[i] ), true, 'returns true when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function allows a difference in sum within floating-point epsilon', function test( t ) { - var bool = isUnityProbabilityArray( [ 0.1, 0.2, 0.1, 0.1, 0.2, 0.2, 0.1 ] ); - t.strictEqual( bool, true, 'returns true' ); - t.end(); -}); - -tape( 'the function returns `false` if not provided an array of probabilities that sum to one', function test( t ) { - var values; - var i; - - values = [ - '10', - '01', - '0.5', - '5', - 5, - NaN, - null, - void 0, - true, - [], - [ 5, null ], - [ 5, '5' ], - [ 1.0, 3.14 ], - [ -1.0, 1.0, 1.0 ], - [ 0.25, 0.33, 0.5 ], - new Float64Array( [ 0.25, 0.33, 0.5 ] ), - new Float64Array( [ 0.25, 1.33, 0.5 ] ), - new Float64Array( [ 0.25, -0.33, 0.5 ] ), - {}, - function noop() {}, - array2buffer( [ 1, 1, 0 ] ) - ]; - - for ( i = 0; i < values.length; i++ ) { - t.strictEqual( isUnityProbabilityArray( values[i] ), false, 'returns false when provided '+values[i] ); - } - t.end(); -}); From bca54475ddd0a2baf22d43a2a145ee792add7880 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Dec 2022 04:28:16 +0000 Subject: [PATCH 030/133] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 85201ae..949865c 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,8 @@ "@stdlib/assert-is-number": "^0.0.x", "@stdlib/assert-is-typed-array": "^0.0.x", "@stdlib/constants-float64-sqrt-eps": "^0.0.x", - "@stdlib/math-base-utils-absolute-difference": "^0.0.x" + "@stdlib/math-base-utils-absolute-difference": "^0.0.x", + "@stdlib/error-tools-fmtprodmsg": "^0.0.x" }, "devDependencies": { "@stdlib/array-float32": "^0.0.x", @@ -104,4 +105,4 @@ "type": "patreon", "url": "https://www.patreon.com/athan" } -} +} \ No newline at end of file From 575216b53e1f4bfc72fbe7f74d4757afe077c74c Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Dec 2022 12:20:22 +0000 Subject: [PATCH 031/133] Remove files --- index.d.ts | 48 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4044 ------------------------------------------------- 4 files changed, 4097 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index f77442a..0000000 --- a/index.d.ts +++ /dev/null @@ -1,48 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 2.0 - -/** -* Tests if a value is an array of probabilities that sum to one. -* -* @param v - value to test -* @returns boolean indicating if a value is a probability array -* -* @example -* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] ); -* // returns true -* -* @example -* var bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) ); -* // returns true -* -* @example -* var bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] ); -* // returns false -* -* @example -* var bool = isUnityProbabilityArray( [ 3.14, 0.0 ] ); -* // returns false -*/ -declare function isUnityProbabilityArray( v: any ): boolean; - - -// EXPORTS // - -export = isUnityProbabilityArray; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 10d3444..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-typed-array@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array@esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-number@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/math-base-utils-absolute-difference@esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/constants-float64-sqrt-eps@v0.0.8-esm/index.mjs";function n(n){var d,m;if(t(n)){for(d=0,m=0;m1||n[m]<0)return!1;d+=n[m]}return r(d,1)<=i}if(s(n)){for(d=0,m=0;m1||n[m]<0)return!1;d+=n[m]}return r(d,1)<=i}return!1}export{n as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 78b17ca..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isTypedArray from '@stdlib/assert-is-typed-array' ;\nimport isArray from '@stdlib/assert-is-array' ;\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number' ;\nimport absdiff from '@stdlib/math-base-utils-absolute-difference' ;\nimport FLOAT64_SQRT_EPS from '@stdlib/constants-float64-sqrt-eps' ;\n\n\n// MAIN //\n\n/**\n* Tests if a value is an array of probabilities that sum to one.\n*\n* @param {*} v - value to test\n* @returns {boolean} boolean indicating if a value is a probability array\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] );\n* // returns true\n*\n* @example\n* var bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) );\n* // returns true\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] );\n* // returns false\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 3.14, 0.0 ] );\n* // returns false\n*/\nfunction isUnityProbabilityArray( v ) {\n\tvar sum;\n\tvar i;\n\tif ( isArray( v ) ) {\n\t\tsum = 0.0;\n\t\tfor ( i = 0; i < v.length; i++ ) {\n\t\t\tif (\n\t\t\t\t!isNumber( v[ i ] ) ||\n\t\t\t\tv[ i ] > 1.0 ||\n\t\t\t\tv[ i ] < 0.0\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tsum += v[ i ];\n\t\t}\n\t\treturn ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS );\n\t}\n\tif ( isTypedArray( v ) ) {\n\t\tsum = 0.0;\n\t\tfor ( i = 0; i < v.length; i++ ) {\n\t\t\tif (\n\t\t\t\tv[ i ] > 1.0 ||\n\t\t\t\tv[ i ] < 0.0\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tsum += v[ i ];\n\t\t}\n\t\treturn ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS );\n\t}\n\treturn false;\n}\n\n\n// EXPORTS //\n\nexport default isUnityProbabilityArray;\n"],"names":["isUnityProbabilityArray","v","sum","i","isArray","length","isNumber","absdiff","FLOAT64_SQRT_EPS","isTypedArray"],"mappings":";;2dAqDA,SAASA,EAAyBC,GACjC,IAAIC,EACAC,EACJ,GAAKC,EAASH,GAAM,CAEnB,IADAC,EAAM,EACAC,EAAI,EAAGA,EAAIF,EAAEI,OAAQF,IAAM,CAChC,IACEG,EAAUL,EAAGE,KACdF,EAAGE,GAAM,GACTF,EAAGE,GAAM,EAET,OAAO,EAERD,GAAOD,EAAGE,EACV,CACD,OAASI,EAASL,EAAK,IAASM,CAChC,CACD,GAAKC,EAAcR,GAAM,CAExB,IADAC,EAAM,EACAC,EAAI,EAAGA,EAAIF,EAAEI,OAAQF,IAAM,CAChC,GACCF,EAAGE,GAAM,GACTF,EAAGE,GAAM,EAET,OAAO,EAERD,GAAOD,EAAGE,EACV,CACD,OAASI,EAASL,EAAK,IAASM,CAChC,CACD,OAAO,CACR"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 662e5c5..0000000 --- a/stats.html +++ /dev/null @@ -1,4044 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From 10e49abfcb24da04828355d639c1c644796d3558 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Dec 2022 12:21:24 +0000 Subject: [PATCH 032/133] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 62 - .github/workflows/cancel.yml | 56 - .github/workflows/close_pull_requests.yml | 44 - .github/workflows/examples.yml | 62 - .github/workflows/npm_downloads.yml | 108 - .github/workflows/productionize.yml | 781 ---- .github/workflows/publish.yml | 117 - .github/workflows/test.yml | 92 - .github/workflows/test_bundles.yml | 180 - .github/workflows/test_coverage.yml | 123 - .github/workflows/test_install.yml | 83 - .gitignore | 183 - .npmignore | 227 -- .npmrc | 28 - CHANGELOG.md | 5 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 41 +- benchmark/benchmark.js | 103 - branches.md | 53 - docs/repl.txt | 29 - docs/types/test.ts | 34 - examples/index.js | 48 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 49 - lib/main.js | 90 - package.json | 70 +- stats.html | 4044 +++++++++++++++++++++ test/test.js | 106 - 37 files changed, 4069 insertions(+), 3533 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 0fd4d6c..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 726b56c..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2022-12-01T02:29:05.212Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 75a4c32..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/assert/is-unity-probability-array) 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 a5cb54c..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/assert/is-unity-probability-array) 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 0e5537b..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: '49 1 * * 1' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - uses: actions/upload-artifact@v3 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - uses: distributhor/workflow-webhook@v3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 37ddb4f..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,781 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - uses: actions/checkout@v3 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Format error messages: - - name: 'Replace double quotes with single quotes in rewritten format string error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\( \"([a-zA-Z0-9]+)\"/Error\( format\( '\1'/g" {} \; - - # Format string literal error messages: - - name: 'Replace double quotes with single quotes in rewritten string literal error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\(\"([a-zA-Z0-9]+)\"\)/Error\( format\( '\1' \)/g" {} \; - - # Format code: - - name: 'Replace double quotes with single quotes in inserted `require` calls' - run: | - find . -name "*.js" -exec sed -E -i "s/require\( ?\"@stdlib\/error-tools-fmtprodmsg\" ?\);/require\( '@stdlib\/error-tools-fmtprodmsg' \);/g" {} \; - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\"/\"@stdlib\/error-tools-fmtprodmsg\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^0.0.x'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - uses: act10ns/slack@v1 - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -165,7 +158,7 @@ bool = isUnityProbabilityArray( null ); ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -229,9 +222,9 @@ Copyright © 2016-2022. The Stdlib [Authors][stdlib-authors]. -[@stdlib/assert/is-probability]: https://github.com/stdlib-js/assert-is-probability +[@stdlib/assert/is-probability]: https://github.com/stdlib-js/assert-is-probability/tree/esm -[@stdlib/assert/is-probability-array]: https://github.com/stdlib-js/assert-is-probability-array +[@stdlib/assert/is-probability-array]: https://github.com/stdlib-js/assert-is-probability-array/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 1121550..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,103 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var isUnityProbabilityArray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x; - var i; - - x = []; - for ( i = 0; i < len; i++ ) { - x.push( 1.0/len ); - } - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: we are testing the worst case scenario where a function must scan the entire array before finding a failing value. - x[ len-1 ] = i * 3.14; - bool = isUnityProbabilityArray( x ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( isBoolean( bool ) ) { - b.pass( 'benchmark finished' ); - } else { - b.fail( 'should return a boolean' ); - } - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':len='+len, f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index 6fcd715..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/assert/is-unity-probability-array" -click B href "https://github.com/stdlib-js/assert-is-unity-probability-array/tree/main" -click C href "https://github.com/stdlib-js/assert-is-unity-probability-array/tree/production" -click D href "https://github.com/stdlib-js/assert-is-unity-probability-array/tree/esm" -click E href "https://github.com/stdlib-js/assert-is-unity-probability-array/tree/deno" -click F href "https://github.com/stdlib-js/assert-is-unity-probability-array/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/assert/is-unity-probability-array -[production-url]: https://github.com/stdlib-js/assert-is-unity-probability-array/tree/production -[deno-url]: https://github.com/stdlib-js/assert-is-unity-probability-array/tree/deno -[umd-url]: https://github.com/stdlib-js/assert-is-unity-probability-array/tree/umd -[esm-url]: https://github.com/stdlib-js/assert-is-unity-probability-array/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index a2414be..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,29 +0,0 @@ - -{{alias}}( value ) - Tests if a value is an array of probabilities that sum to one. - - Parameters - ---------- - value: any - Value to test. - - Returns - ------- - bool: boolean - Boolean indicating whether value is an array of probabilities that sum - to one. - - Examples - -------- - > var bool = {{alias}}( [ 0.25, 0.5, 0.25 ] ) - true - > bool = {{alias}}( new {{alias:@stdlib/array/uint8}}( [ 0, 1 ] ) ) - true - > bool = {{alias}}( [ 0.4, 0.4, 0.4 ] ) - false - > bool = {{alias}}( [ 3.14, 0.0 ] ) - false - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 6b41658..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,34 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import isUnityProbabilityArray = require( './index' ); - - -// TESTS // - -// The function returns a boolean... -{ - isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] ); // $ExpectType boolean - isUnityProbabilityArray( [ 2, 3 ] ); // $ExpectType boolean -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - isUnityProbabilityArray(); // $ExpectError - isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ], 123 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index b0b6bbc..0000000 --- a/examples/index.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var Uint8Array = require( '@stdlib/array-uint8' ); -var isUnityProbabilityArray = require( './../lib' ); - -var arr = [ 0.0, 1.0 ]; -console.log( isUnityProbabilityArray( arr ) ); -// => true - -arr = [ 0.5, 0.25, 0.25 ]; -console.log( isUnityProbabilityArray( arr ) ); -// => true - -arr = new Uint8Array( [ 0, 0, 1, 0 ] ); -console.log( isUnityProbabilityArray( arr ) ); -// => true - -arr = [ 0.4, 0.4, 0.4 ]; -console.log( isUnityProbabilityArray( arr ) ); -// => false - -arr = [ 3.14, -1.0 ]; -console.log( isUnityProbabilityArray( arr ) ); -// => false - -console.log( isUnityProbabilityArray( [] ) ); -// => false - -console.log( isUnityProbabilityArray( null ) ); -// => false diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..10d3444 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-typed-array@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array@esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-number@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/math-base-utils-absolute-difference@esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/constants-float64-sqrt-eps@v0.0.8-esm/index.mjs";function n(n){var d,m;if(t(n)){for(d=0,m=0;m1||n[m]<0)return!1;d+=n[m]}return r(d,1)<=i}if(s(n)){for(d=0,m=0;m1||n[m]<0)return!1;d+=n[m]}return r(d,1)<=i}return!1}export{n as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..9e78080 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isTypedArray from '@stdlib/assert-is-typed-array';\nimport isArray from '@stdlib/assert-is-array';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport absdiff from '@stdlib/math-base-utils-absolute-difference';\nimport FLOAT64_SQRT_EPS from '@stdlib/constants-float64-sqrt-eps';\n\n\n// MAIN //\n\n/**\n* Tests if a value is an array of probabilities that sum to one.\n*\n* @param {*} v - value to test\n* @returns {boolean} boolean indicating if a value is a probability array\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] );\n* // returns true\n*\n* @example\n* var bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) );\n* // returns true\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] );\n* // returns false\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 3.14, 0.0 ] );\n* // returns false\n*/\nfunction isUnityProbabilityArray( v ) {\n\tvar sum;\n\tvar i;\n\tif ( isArray( v ) ) {\n\t\tsum = 0.0;\n\t\tfor ( i = 0; i < v.length; i++ ) {\n\t\t\tif (\n\t\t\t\t!isNumber( v[ i ] ) ||\n\t\t\t\tv[ i ] > 1.0 ||\n\t\t\t\tv[ i ] < 0.0\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tsum += v[ i ];\n\t\t}\n\t\treturn ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS );\n\t}\n\tif ( isTypedArray( v ) ) {\n\t\tsum = 0.0;\n\t\tfor ( i = 0; i < v.length; i++ ) {\n\t\t\tif (\n\t\t\t\tv[ i ] > 1.0 ||\n\t\t\t\tv[ i ] < 0.0\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tsum += v[ i ];\n\t\t}\n\t\treturn ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS );\n\t}\n\treturn false;\n}\n\n\n// EXPORTS //\n\nexport default isUnityProbabilityArray;\n"],"names":["isUnityProbabilityArray","v","sum","i","isArray","length","isNumber","absdiff","FLOAT64_SQRT_EPS","isTypedArray"],"mappings":";;2dAqDA,SAASA,EAAyBC,GACjC,IAAIC,EACAC,EACJ,GAAKC,EAASH,GAAM,CAEnB,IADAC,EAAM,EACAC,EAAI,EAAGA,EAAIF,EAAEI,OAAQF,IAAM,CAChC,IACEG,EAAUL,EAAGE,KACdF,EAAGE,GAAM,GACTF,EAAGE,GAAM,EAET,OAAO,EAERD,GAAOD,EAAGE,EACV,CACD,OAASI,EAASL,EAAK,IAASM,CAChC,CACD,GAAKC,EAAcR,GAAM,CAExB,IADAC,EAAM,EACAC,EAAI,EAAGA,EAAIF,EAAEI,OAAQF,IAAM,CAChC,GACCF,EAAGE,GAAM,GACTF,EAAGE,GAAM,EAET,OAAO,EAERD,GAAOD,EAAGE,EACV,CACD,OAASI,EAASL,EAAK,IAASM,CAChC,CACD,OAAO,CACR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 13a67d1..0000000 --- a/lib/index.js +++ /dev/null @@ -1,49 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Test if a value is an array of probabilities that sum to one. -* -* @module @stdlib/assert-is-unity-probability-array -* -* @example -* var isUnityProbabilityArray = require( '@stdlib/assert-is-unity-probability-array' ); -* -* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] ); -* // returns true -* -* bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) ); -* // returns true -* -* bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] ); -* // returns false -* -* bool = isUnityProbabilityArray( [ 3.14, 0.0 ] ); -* // returns false -*/ - -// 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 d0bda40..0000000 --- a/lib/main.js +++ /dev/null @@ -1,90 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -var isArray = require( '@stdlib/assert-is-array' ); -var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var absdiff = require( '@stdlib/math-base-utils-absolute-difference' ); -var FLOAT64_SQRT_EPS = require( '@stdlib/constants-float64-sqrt-eps' ); - - -// MAIN // - -/** -* Tests if a value is an array of probabilities that sum to one. -* -* @param {*} v - value to test -* @returns {boolean} boolean indicating if a value is a probability array -* -* @example -* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] ); -* // returns true -* -* @example -* var bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) ); -* // returns true -* -* @example -* var bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] ); -* // returns false -* -* @example -* var bool = isUnityProbabilityArray( [ 3.14, 0.0 ] ); -* // returns false -*/ -function isUnityProbabilityArray( v ) { - var sum; - var i; - if ( isArray( v ) ) { - sum = 0.0; - for ( i = 0; i < v.length; i++ ) { - if ( - !isNumber( v[ i ] ) || - v[ i ] > 1.0 || - v[ i ] < 0.0 - ) { - return false; - } - sum += v[ i ]; - } - return ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS ); - } - if ( isTypedArray( v ) ) { - sum = 0.0; - for ( i = 0; i < v.length; i++ ) { - if ( - v[ i ] > 1.0 || - v[ i ] < 0.0 - ) { - return false; - } - sum += v[ i ]; - } - return ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS ); - } - return false; -} - - -// EXPORTS // - -module.exports = isUnityProbabilityArray; diff --git a/package.json b/package.json index 949865c..bf1e9c3 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.7", "description": "Test if a value is an array of probabilities that sum to one.", "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" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,47 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-array": "^0.0.x", - "@stdlib/assert-is-number": "^0.0.x", - "@stdlib/assert-is-typed-array": "^0.0.x", - "@stdlib/constants-float64-sqrt-eps": "^0.0.x", - "@stdlib/math-base-utils-absolute-difference": "^0.0.x", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x" - }, - "devDependencies": { - "@stdlib/array-float32": "^0.0.x", - "@stdlib/array-float64": "^0.0.x", - "@stdlib/array-int16": "^0.0.x", - "@stdlib/array-int32": "^0.0.x", - "@stdlib/array-int8": "^0.0.x", - "@stdlib/array-uint16": "^0.0.x", - "@stdlib/array-uint32": "^0.0.x", - "@stdlib/array-uint8": "^0.0.x", - "@stdlib/array-uint8c": "^0.0.x", - "@stdlib/assert-is-boolean": "^0.0.x", - "@stdlib/bench": "^0.0.x", - "@stdlib/buffer-from-array": "^0.0.x", - "@stdlib/math-base-special-pow": "^0.0.x", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "2.x.x" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdassert", @@ -105,4 +41,4 @@ "type": "patreon", "url": "https://www.patreon.com/athan" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..ed0fdaa --- /dev/null +++ b/stats.html @@ -0,0 +1,4044 @@ + + + + + + + + RollUp Visualizer + + + +
+ + + + + diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 7f6a066..0000000 --- a/test/test.js +++ /dev/null @@ -1,106 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Int8Array = require( '@stdlib/array-int8' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Float64Array = require( '@stdlib/array-float64' ); -var array2buffer = require( '@stdlib/buffer-from-array' ); -var isUnityProbabilityArray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof isUnityProbabilityArray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns `true` if provided an array of probabilities that sum to one', function test( t ) { - var values; - var i; - - values = [ - new Int8Array( [ 0, 0, 1 ] ), - new Uint8Array( [ 1, 0, 0 ] ), - new Uint8ClampedArray( [ 0, 1 ] ), - new Int16Array( [ 0, 0, 1, 0 ] ), - new Uint16Array( [ 1 ] ), - new Int32Array( [ 1, 0, 0 ] ), - new Uint32Array( [ 0, 1, 0 ] ), - new Float32Array( [ 0.0, 0.5, 0.5 ] ), - new Float64Array( [ 0.25, 0.25, 0.5 ] ), - [ 0.5, 0.25, 0.25 ] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.strictEqual( isUnityProbabilityArray( values[i] ), true, 'returns true when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function allows a difference in sum within floating-point epsilon', function test( t ) { - var bool = isUnityProbabilityArray( [ 0.1, 0.2, 0.1, 0.1, 0.2, 0.2, 0.1 ] ); - t.strictEqual( bool, true, 'returns true' ); - t.end(); -}); - -tape( 'the function returns `false` if not provided an array of probabilities that sum to one', function test( t ) { - var values; - var i; - - values = [ - '10', - '01', - '0.5', - '5', - 5, - NaN, - null, - void 0, - true, - [], - [ 5, null ], - [ 5, '5' ], - [ 1.0, 3.14 ], - [ -1.0, 1.0, 1.0 ], - [ 0.25, 0.33, 0.5 ], - new Float64Array( [ 0.25, 0.33, 0.5 ] ), - new Float64Array( [ 0.25, 1.33, 0.5 ] ), - new Float64Array( [ 0.25, -0.33, 0.5 ] ), - {}, - function noop() {}, - array2buffer( [ 1, 1, 0 ] ) - ]; - - for ( i = 0; i < values.length; i++ ) { - t.strictEqual( isUnityProbabilityArray( values[i] ), false, 'returns false when provided '+values[i] ); - } - t.end(); -}); From 0d69551f82f43aab5a3ff4d10ba5086dd460fbce Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Jan 2023 03:11:24 +0000 Subject: [PATCH 033/133] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 8b45927..ecc5f04 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,8 @@ "@stdlib/assert-is-number": "^0.0.x", "@stdlib/assert-is-typed-array": "^0.0.x", "@stdlib/constants-float64-sqrt-eps": "^0.0.x", - "@stdlib/math-base-utils-absolute-difference": "^0.0.x" + "@stdlib/math-base-utils-absolute-difference": "^0.0.x", + "@stdlib/error-tools-fmtprodmsg": "^0.0.x" }, "devDependencies": { "@stdlib/array-float32": "^0.0.x", @@ -104,4 +105,4 @@ "type": "patreon", "url": "https://www.patreon.com/athan" } -} +} \ No newline at end of file From bc630891d7a831f1407eee71a74b1ecac8cca093 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Jan 2023 13:01:13 +0000 Subject: [PATCH 034/133] Remove files --- index.d.ts | 48 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4044 ------------------------------------------------- 4 files changed, 4097 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index f77442a..0000000 --- a/index.d.ts +++ /dev/null @@ -1,48 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 2.0 - -/** -* Tests if a value is an array of probabilities that sum to one. -* -* @param v - value to test -* @returns boolean indicating if a value is a probability array -* -* @example -* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] ); -* // returns true -* -* @example -* var bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) ); -* // returns true -* -* @example -* var bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] ); -* // returns false -* -* @example -* var bool = isUnityProbabilityArray( [ 3.14, 0.0 ] ); -* // returns false -*/ -declare function isUnityProbabilityArray( v: any ): boolean; - - -// EXPORTS // - -export = isUnityProbabilityArray; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 10d3444..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-typed-array@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array@esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-number@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/math-base-utils-absolute-difference@esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/constants-float64-sqrt-eps@v0.0.8-esm/index.mjs";function n(n){var d,m;if(t(n)){for(d=0,m=0;m1||n[m]<0)return!1;d+=n[m]}return r(d,1)<=i}if(s(n)){for(d=0,m=0;m1||n[m]<0)return!1;d+=n[m]}return r(d,1)<=i}return!1}export{n as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 9e78080..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isTypedArray from '@stdlib/assert-is-typed-array';\nimport isArray from '@stdlib/assert-is-array';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport absdiff from '@stdlib/math-base-utils-absolute-difference';\nimport FLOAT64_SQRT_EPS from '@stdlib/constants-float64-sqrt-eps';\n\n\n// MAIN //\n\n/**\n* Tests if a value is an array of probabilities that sum to one.\n*\n* @param {*} v - value to test\n* @returns {boolean} boolean indicating if a value is a probability array\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] );\n* // returns true\n*\n* @example\n* var bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) );\n* // returns true\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] );\n* // returns false\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 3.14, 0.0 ] );\n* // returns false\n*/\nfunction isUnityProbabilityArray( v ) {\n\tvar sum;\n\tvar i;\n\tif ( isArray( v ) ) {\n\t\tsum = 0.0;\n\t\tfor ( i = 0; i < v.length; i++ ) {\n\t\t\tif (\n\t\t\t\t!isNumber( v[ i ] ) ||\n\t\t\t\tv[ i ] > 1.0 ||\n\t\t\t\tv[ i ] < 0.0\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tsum += v[ i ];\n\t\t}\n\t\treturn ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS );\n\t}\n\tif ( isTypedArray( v ) ) {\n\t\tsum = 0.0;\n\t\tfor ( i = 0; i < v.length; i++ ) {\n\t\t\tif (\n\t\t\t\tv[ i ] > 1.0 ||\n\t\t\t\tv[ i ] < 0.0\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tsum += v[ i ];\n\t\t}\n\t\treturn ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS );\n\t}\n\treturn false;\n}\n\n\n// EXPORTS //\n\nexport default isUnityProbabilityArray;\n"],"names":["isUnityProbabilityArray","v","sum","i","isArray","length","isNumber","absdiff","FLOAT64_SQRT_EPS","isTypedArray"],"mappings":";;2dAqDA,SAASA,EAAyBC,GACjC,IAAIC,EACAC,EACJ,GAAKC,EAASH,GAAM,CAEnB,IADAC,EAAM,EACAC,EAAI,EAAGA,EAAIF,EAAEI,OAAQF,IAAM,CAChC,IACEG,EAAUL,EAAGE,KACdF,EAAGE,GAAM,GACTF,EAAGE,GAAM,EAET,OAAO,EAERD,GAAOD,EAAGE,EACV,CACD,OAASI,EAASL,EAAK,IAASM,CAChC,CACD,GAAKC,EAAcR,GAAM,CAExB,IADAC,EAAM,EACAC,EAAI,EAAGA,EAAIF,EAAEI,OAAQF,IAAM,CAChC,GACCF,EAAGE,GAAM,GACTF,EAAGE,GAAM,EAET,OAAO,EAERD,GAAOD,EAAGE,EACV,CACD,OAASI,EAASL,EAAK,IAASM,CAChC,CACD,OAAO,CACR"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index ed0fdaa..0000000 --- a/stats.html +++ /dev/null @@ -1,4044 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From d9f97ffd7fc7096b1d16b6c0067be730c5281c65 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Jan 2023 13:01:51 +0000 Subject: [PATCH 035/133] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 62 - .github/workflows/cancel.yml | 56 - .github/workflows/close_pull_requests.yml | 44 - .github/workflows/examples.yml | 62 - .github/workflows/npm_downloads.yml | 108 - .github/workflows/productionize.yml | 791 ---- .github/workflows/publish.yml | 117 - .github/workflows/test.yml | 92 - .github/workflows/test_bundles.yml | 180 - .github/workflows/test_coverage.yml | 123 - .github/workflows/test_install.yml | 83 - .gitignore | 184 - .npmignore | 227 -- .npmrc | 28 - CHANGELOG.md | 5 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 41 +- benchmark/benchmark.js | 103 - branches.md | 53 - docs/repl.txt | 29 - docs/types/test.ts | 34 - examples/index.js | 48 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 49 - lib/main.js | 90 - package.json | 70 +- stats.html | 4044 +++++++++++++++++++++ test/test.js | 106 - 37 files changed, 4069 insertions(+), 3544 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 0fd4d6c..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index c2be811..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-01-01T01:38:35.713Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 75a4c32..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/assert/is-unity-probability-array) 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 a5cb54c..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/assert/is-unity-probability-array) 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 0e5537b..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: '49 1 * * 1' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - uses: actions/upload-artifact@v3 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - uses: distributhor/workflow-webhook@v3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index f4eea88..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,791 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - uses: actions/checkout@v3 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Format error messages: - - name: 'Replace double quotes with single quotes in rewritten format string error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\( \"([a-zA-Z0-9]+)\"/Error\( format\( '\1'/g" {} \; - - # Format string literal error messages: - - name: 'Replace double quotes with single quotes in rewritten string literal error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\(\"([a-zA-Z0-9]+)\"\)/Error\( format\( '\1' \)/g" {} \; - - # Format code: - - name: 'Replace double quotes with single quotes in inserted `require` calls' - run: | - find . -name "*.js" -exec sed -E -i "s/require\( ?\"@stdlib\/error-tools-fmtprodmsg\" ?\);/require\( '@stdlib\/error-tools-fmtprodmsg' \);/g" {} \; - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\"/\"@stdlib\/error-tools-fmtprodmsg\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^0.0.x'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - uses: actions/checkout@v3 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - uses: act10ns/slack@v1 - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -165,7 +158,7 @@ bool = isUnityProbabilityArray( null ); ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -229,9 +222,9 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. -[@stdlib/assert/is-probability]: https://github.com/stdlib-js/assert-is-probability +[@stdlib/assert/is-probability]: https://github.com/stdlib-js/assert-is-probability/tree/esm -[@stdlib/assert/is-probability-array]: https://github.com/stdlib-js/assert-is-probability-array +[@stdlib/assert/is-probability-array]: https://github.com/stdlib-js/assert-is-probability-array/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 1121550..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,103 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var isUnityProbabilityArray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x; - var i; - - x = []; - for ( i = 0; i < len; i++ ) { - x.push( 1.0/len ); - } - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: we are testing the worst case scenario where a function must scan the entire array before finding a failing value. - x[ len-1 ] = i * 3.14; - bool = isUnityProbabilityArray( x ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( isBoolean( bool ) ) { - b.pass( 'benchmark finished' ); - } else { - b.fail( 'should return a boolean' ); - } - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':len='+len, f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index 6fcd715..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/assert/is-unity-probability-array" -click B href "https://github.com/stdlib-js/assert-is-unity-probability-array/tree/main" -click C href "https://github.com/stdlib-js/assert-is-unity-probability-array/tree/production" -click D href "https://github.com/stdlib-js/assert-is-unity-probability-array/tree/esm" -click E href "https://github.com/stdlib-js/assert-is-unity-probability-array/tree/deno" -click F href "https://github.com/stdlib-js/assert-is-unity-probability-array/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/assert/is-unity-probability-array -[production-url]: https://github.com/stdlib-js/assert-is-unity-probability-array/tree/production -[deno-url]: https://github.com/stdlib-js/assert-is-unity-probability-array/tree/deno -[umd-url]: https://github.com/stdlib-js/assert-is-unity-probability-array/tree/umd -[esm-url]: https://github.com/stdlib-js/assert-is-unity-probability-array/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index a2414be..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,29 +0,0 @@ - -{{alias}}( value ) - Tests if a value is an array of probabilities that sum to one. - - Parameters - ---------- - value: any - Value to test. - - Returns - ------- - bool: boolean - Boolean indicating whether value is an array of probabilities that sum - to one. - - Examples - -------- - > var bool = {{alias}}( [ 0.25, 0.5, 0.25 ] ) - true - > bool = {{alias}}( new {{alias:@stdlib/array/uint8}}( [ 0, 1 ] ) ) - true - > bool = {{alias}}( [ 0.4, 0.4, 0.4 ] ) - false - > bool = {{alias}}( [ 3.14, 0.0 ] ) - false - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 6b41658..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,34 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import isUnityProbabilityArray = require( './index' ); - - -// TESTS // - -// The function returns a boolean... -{ - isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] ); // $ExpectType boolean - isUnityProbabilityArray( [ 2, 3 ] ); // $ExpectType boolean -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - isUnityProbabilityArray(); // $ExpectError - isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ], 123 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index b0b6bbc..0000000 --- a/examples/index.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var Uint8Array = require( '@stdlib/array-uint8' ); -var isUnityProbabilityArray = require( './../lib' ); - -var arr = [ 0.0, 1.0 ]; -console.log( isUnityProbabilityArray( arr ) ); -// => true - -arr = [ 0.5, 0.25, 0.25 ]; -console.log( isUnityProbabilityArray( arr ) ); -// => true - -arr = new Uint8Array( [ 0, 0, 1, 0 ] ); -console.log( isUnityProbabilityArray( arr ) ); -// => true - -arr = [ 0.4, 0.4, 0.4 ]; -console.log( isUnityProbabilityArray( arr ) ); -// => false - -arr = [ 3.14, -1.0 ]; -console.log( isUnityProbabilityArray( arr ) ); -// => false - -console.log( isUnityProbabilityArray( [] ) ); -// => false - -console.log( isUnityProbabilityArray( null ) ); -// => false diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..b43d098 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-typed-array@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array@esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-number@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/math-base-utils-absolute-difference@esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/constants-float64-sqrt-eps@v0.0.8-esm/index.mjs";function n(n){var d,m;if(t(n)){for(d=0,m=0;m1||n[m]<0)return!1;d+=n[m]}return r(d,1)<=i}if(s(n)){for(d=0,m=0;m1||n[m]<0)return!1;d+=n[m]}return r(d,1)<=i}return!1}export{n as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..9e78080 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isTypedArray from '@stdlib/assert-is-typed-array';\nimport isArray from '@stdlib/assert-is-array';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport absdiff from '@stdlib/math-base-utils-absolute-difference';\nimport FLOAT64_SQRT_EPS from '@stdlib/constants-float64-sqrt-eps';\n\n\n// MAIN //\n\n/**\n* Tests if a value is an array of probabilities that sum to one.\n*\n* @param {*} v - value to test\n* @returns {boolean} boolean indicating if a value is a probability array\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] );\n* // returns true\n*\n* @example\n* var bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) );\n* // returns true\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] );\n* // returns false\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 3.14, 0.0 ] );\n* // returns false\n*/\nfunction isUnityProbabilityArray( v ) {\n\tvar sum;\n\tvar i;\n\tif ( isArray( v ) ) {\n\t\tsum = 0.0;\n\t\tfor ( i = 0; i < v.length; i++ ) {\n\t\t\tif (\n\t\t\t\t!isNumber( v[ i ] ) ||\n\t\t\t\tv[ i ] > 1.0 ||\n\t\t\t\tv[ i ] < 0.0\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tsum += v[ i ];\n\t\t}\n\t\treturn ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS );\n\t}\n\tif ( isTypedArray( v ) ) {\n\t\tsum = 0.0;\n\t\tfor ( i = 0; i < v.length; i++ ) {\n\t\t\tif (\n\t\t\t\tv[ i ] > 1.0 ||\n\t\t\t\tv[ i ] < 0.0\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tsum += v[ i ];\n\t\t}\n\t\treturn ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS );\n\t}\n\treturn false;\n}\n\n\n// EXPORTS //\n\nexport default isUnityProbabilityArray;\n"],"names":["isUnityProbabilityArray","v","sum","i","isArray","length","isNumber","absdiff","FLOAT64_SQRT_EPS","isTypedArray"],"mappings":";;2dAqDA,SAASA,EAAyBC,GACjC,IAAIC,EACAC,EACJ,GAAKC,EAASH,GAAM,CAEnB,IADAC,EAAM,EACAC,EAAI,EAAGA,EAAIF,EAAEI,OAAQF,IAAM,CAChC,IACEG,EAAUL,EAAGE,KACdF,EAAGE,GAAM,GACTF,EAAGE,GAAM,EAET,OAAO,EAERD,GAAOD,EAAGE,EACV,CACD,OAASI,EAASL,EAAK,IAASM,CAChC,CACD,GAAKC,EAAcR,GAAM,CAExB,IADAC,EAAM,EACAC,EAAI,EAAGA,EAAIF,EAAEI,OAAQF,IAAM,CAChC,GACCF,EAAGE,GAAM,GACTF,EAAGE,GAAM,EAET,OAAO,EAERD,GAAOD,EAAGE,EACV,CACD,OAASI,EAASL,EAAK,IAASM,CAChC,CACD,OAAO,CACR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 13a67d1..0000000 --- a/lib/index.js +++ /dev/null @@ -1,49 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Test if a value is an array of probabilities that sum to one. -* -* @module @stdlib/assert-is-unity-probability-array -* -* @example -* var isUnityProbabilityArray = require( '@stdlib/assert-is-unity-probability-array' ); -* -* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] ); -* // returns true -* -* bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) ); -* // returns true -* -* bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] ); -* // returns false -* -* bool = isUnityProbabilityArray( [ 3.14, 0.0 ] ); -* // returns false -*/ - -// 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 d0bda40..0000000 --- a/lib/main.js +++ /dev/null @@ -1,90 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -var isArray = require( '@stdlib/assert-is-array' ); -var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var absdiff = require( '@stdlib/math-base-utils-absolute-difference' ); -var FLOAT64_SQRT_EPS = require( '@stdlib/constants-float64-sqrt-eps' ); - - -// MAIN // - -/** -* Tests if a value is an array of probabilities that sum to one. -* -* @param {*} v - value to test -* @returns {boolean} boolean indicating if a value is a probability array -* -* @example -* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] ); -* // returns true -* -* @example -* var bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) ); -* // returns true -* -* @example -* var bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] ); -* // returns false -* -* @example -* var bool = isUnityProbabilityArray( [ 3.14, 0.0 ] ); -* // returns false -*/ -function isUnityProbabilityArray( v ) { - var sum; - var i; - if ( isArray( v ) ) { - sum = 0.0; - for ( i = 0; i < v.length; i++ ) { - if ( - !isNumber( v[ i ] ) || - v[ i ] > 1.0 || - v[ i ] < 0.0 - ) { - return false; - } - sum += v[ i ]; - } - return ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS ); - } - if ( isTypedArray( v ) ) { - sum = 0.0; - for ( i = 0; i < v.length; i++ ) { - if ( - v[ i ] > 1.0 || - v[ i ] < 0.0 - ) { - return false; - } - sum += v[ i ]; - } - return ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS ); - } - return false; -} - - -// EXPORTS // - -module.exports = isUnityProbabilityArray; diff --git a/package.json b/package.json index ecc5f04..bf1e9c3 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.7", "description": "Test if a value is an array of probabilities that sum to one.", "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" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,47 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-array": "^0.0.x", - "@stdlib/assert-is-number": "^0.0.x", - "@stdlib/assert-is-typed-array": "^0.0.x", - "@stdlib/constants-float64-sqrt-eps": "^0.0.x", - "@stdlib/math-base-utils-absolute-difference": "^0.0.x", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x" - }, - "devDependencies": { - "@stdlib/array-float32": "^0.0.x", - "@stdlib/array-float64": "^0.0.x", - "@stdlib/array-int16": "^0.0.x", - "@stdlib/array-int32": "^0.0.x", - "@stdlib/array-int8": "^0.0.x", - "@stdlib/array-uint16": "^0.0.x", - "@stdlib/array-uint32": "^0.0.x", - "@stdlib/array-uint8": "^0.0.x", - "@stdlib/array-uint8c": "^0.0.x", - "@stdlib/assert-is-boolean": "^0.0.x", - "@stdlib/bench": "^0.0.x", - "@stdlib/buffer-from-array": "^0.0.x", - "@stdlib/math-base-special-pow": "^0.0.x", - "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", "stdassert", @@ -105,4 +41,4 @@ "type": "patreon", "url": "https://www.patreon.com/athan" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..7a4032d --- /dev/null +++ b/stats.html @@ -0,0 +1,4044 @@ + + + + + + + + RollUp Visualizer + + + +
+ + + + + diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 7f6a066..0000000 --- a/test/test.js +++ /dev/null @@ -1,106 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Int8Array = require( '@stdlib/array-int8' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Float64Array = require( '@stdlib/array-float64' ); -var array2buffer = require( '@stdlib/buffer-from-array' ); -var isUnityProbabilityArray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof isUnityProbabilityArray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns `true` if provided an array of probabilities that sum to one', function test( t ) { - var values; - var i; - - values = [ - new Int8Array( [ 0, 0, 1 ] ), - new Uint8Array( [ 1, 0, 0 ] ), - new Uint8ClampedArray( [ 0, 1 ] ), - new Int16Array( [ 0, 0, 1, 0 ] ), - new Uint16Array( [ 1 ] ), - new Int32Array( [ 1, 0, 0 ] ), - new Uint32Array( [ 0, 1, 0 ] ), - new Float32Array( [ 0.0, 0.5, 0.5 ] ), - new Float64Array( [ 0.25, 0.25, 0.5 ] ), - [ 0.5, 0.25, 0.25 ] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.strictEqual( isUnityProbabilityArray( values[i] ), true, 'returns true when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function allows a difference in sum within floating-point epsilon', function test( t ) { - var bool = isUnityProbabilityArray( [ 0.1, 0.2, 0.1, 0.1, 0.2, 0.2, 0.1 ] ); - t.strictEqual( bool, true, 'returns true' ); - t.end(); -}); - -tape( 'the function returns `false` if not provided an array of probabilities that sum to one', function test( t ) { - var values; - var i; - - values = [ - '10', - '01', - '0.5', - '5', - 5, - NaN, - null, - void 0, - true, - [], - [ 5, null ], - [ 5, '5' ], - [ 1.0, 3.14 ], - [ -1.0, 1.0, 1.0 ], - [ 0.25, 0.33, 0.5 ], - new Float64Array( [ 0.25, 0.33, 0.5 ] ), - new Float64Array( [ 0.25, 1.33, 0.5 ] ), - new Float64Array( [ 0.25, -0.33, 0.5 ] ), - {}, - function noop() {}, - array2buffer( [ 1, 1, 0 ] ) - ]; - - for ( i = 0; i < values.length; i++ ) { - t.strictEqual( isUnityProbabilityArray( values[i] ), false, 'returns false when provided '+values[i] ); - } - t.end(); -}); From c13c157119cd334bcb25d9809d7522a7b2f1ebf3 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 1 Feb 2023 04:07:36 +0000 Subject: [PATCH 036/133] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 8b45927..ecc5f04 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,8 @@ "@stdlib/assert-is-number": "^0.0.x", "@stdlib/assert-is-typed-array": "^0.0.x", "@stdlib/constants-float64-sqrt-eps": "^0.0.x", - "@stdlib/math-base-utils-absolute-difference": "^0.0.x" + "@stdlib/math-base-utils-absolute-difference": "^0.0.x", + "@stdlib/error-tools-fmtprodmsg": "^0.0.x" }, "devDependencies": { "@stdlib/array-float32": "^0.0.x", @@ -104,4 +105,4 @@ "type": "patreon", "url": "https://www.patreon.com/athan" } -} +} \ No newline at end of file From 0975a6c916e3dbcfd3f911dd6cffc7fb7eec777f Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 1 Feb 2023 12:47:19 +0000 Subject: [PATCH 037/133] Remove files --- index.d.ts | 48 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4044 ------------------------------------------------- 4 files changed, 4097 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index f77442a..0000000 --- a/index.d.ts +++ /dev/null @@ -1,48 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 2.0 - -/** -* Tests if a value is an array of probabilities that sum to one. -* -* @param v - value to test -* @returns boolean indicating if a value is a probability array -* -* @example -* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] ); -* // returns true -* -* @example -* var bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) ); -* // returns true -* -* @example -* var bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] ); -* // returns false -* -* @example -* var bool = isUnityProbabilityArray( [ 3.14, 0.0 ] ); -* // returns false -*/ -declare function isUnityProbabilityArray( v: any ): boolean; - - -// EXPORTS // - -export = isUnityProbabilityArray; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index b43d098..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-typed-array@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array@esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-number@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/math-base-utils-absolute-difference@esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/constants-float64-sqrt-eps@v0.0.8-esm/index.mjs";function n(n){var d,m;if(t(n)){for(d=0,m=0;m1||n[m]<0)return!1;d+=n[m]}return r(d,1)<=i}if(s(n)){for(d=0,m=0;m1||n[m]<0)return!1;d+=n[m]}return r(d,1)<=i}return!1}export{n as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 9e78080..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isTypedArray from '@stdlib/assert-is-typed-array';\nimport isArray from '@stdlib/assert-is-array';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport absdiff from '@stdlib/math-base-utils-absolute-difference';\nimport FLOAT64_SQRT_EPS from '@stdlib/constants-float64-sqrt-eps';\n\n\n// MAIN //\n\n/**\n* Tests if a value is an array of probabilities that sum to one.\n*\n* @param {*} v - value to test\n* @returns {boolean} boolean indicating if a value is a probability array\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] );\n* // returns true\n*\n* @example\n* var bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) );\n* // returns true\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] );\n* // returns false\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 3.14, 0.0 ] );\n* // returns false\n*/\nfunction isUnityProbabilityArray( v ) {\n\tvar sum;\n\tvar i;\n\tif ( isArray( v ) ) {\n\t\tsum = 0.0;\n\t\tfor ( i = 0; i < v.length; i++ ) {\n\t\t\tif (\n\t\t\t\t!isNumber( v[ i ] ) ||\n\t\t\t\tv[ i ] > 1.0 ||\n\t\t\t\tv[ i ] < 0.0\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tsum += v[ i ];\n\t\t}\n\t\treturn ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS );\n\t}\n\tif ( isTypedArray( v ) ) {\n\t\tsum = 0.0;\n\t\tfor ( i = 0; i < v.length; i++ ) {\n\t\t\tif (\n\t\t\t\tv[ i ] > 1.0 ||\n\t\t\t\tv[ i ] < 0.0\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tsum += v[ i ];\n\t\t}\n\t\treturn ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS );\n\t}\n\treturn false;\n}\n\n\n// EXPORTS //\n\nexport default isUnityProbabilityArray;\n"],"names":["isUnityProbabilityArray","v","sum","i","isArray","length","isNumber","absdiff","FLOAT64_SQRT_EPS","isTypedArray"],"mappings":";;2dAqDA,SAASA,EAAyBC,GACjC,IAAIC,EACAC,EACJ,GAAKC,EAASH,GAAM,CAEnB,IADAC,EAAM,EACAC,EAAI,EAAGA,EAAIF,EAAEI,OAAQF,IAAM,CAChC,IACEG,EAAUL,EAAGE,KACdF,EAAGE,GAAM,GACTF,EAAGE,GAAM,EAET,OAAO,EAERD,GAAOD,EAAGE,EACV,CACD,OAASI,EAASL,EAAK,IAASM,CAChC,CACD,GAAKC,EAAcR,GAAM,CAExB,IADAC,EAAM,EACAC,EAAI,EAAGA,EAAIF,EAAEI,OAAQF,IAAM,CAChC,GACCF,EAAGE,GAAM,GACTF,EAAGE,GAAM,EAET,OAAO,EAERD,GAAOD,EAAGE,EACV,CACD,OAASI,EAASL,EAAK,IAASM,CAChC,CACD,OAAO,CACR"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 7a4032d..0000000 --- a/stats.html +++ /dev/null @@ -1,4044 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From c32fca9fa459c3857dacc7158707f057342c6309 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 1 Feb 2023 12:48:05 +0000 Subject: [PATCH 038/133] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 62 - .github/workflows/cancel.yml | 56 - .github/workflows/close_pull_requests.yml | 44 - .github/workflows/examples.yml | 62 - .github/workflows/npm_downloads.yml | 108 - .github/workflows/productionize.yml | 791 --- .github/workflows/publish.yml | 117 - .github/workflows/test.yml | 92 - .github/workflows/test_bundles.yml | 180 - .github/workflows/test_coverage.yml | 123 - .github/workflows/test_install.yml | 83 - .gitignore | 184 - .npmignore | 227 - .npmrc | 28 - CHANGELOG.md | 5 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 41 +- benchmark/benchmark.js | 103 - branches.md | 53 - docs/repl.txt | 29 - docs/types/test.ts | 34 - examples/index.js | 48 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 49 - lib/main.js | 90 - package.json | 70 +- stats.html | 6177 +++++++++++++++++++++ test/test.js | 106 - 37 files changed, 6202 insertions(+), 3544 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 0fd4d6c..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 6b484b3..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-02-01T02:13:46.187Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 75a4c32..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/assert/is-unity-probability-array) 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 a5cb54c..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/assert/is-unity-probability-array) 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 0e5537b..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: '49 1 * * 1' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - uses: actions/upload-artifact@v3 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - uses: distributhor/workflow-webhook@v3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index f4eea88..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,791 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - uses: actions/checkout@v3 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Format error messages: - - name: 'Replace double quotes with single quotes in rewritten format string error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\( \"([a-zA-Z0-9]+)\"/Error\( format\( '\1'/g" {} \; - - # Format string literal error messages: - - name: 'Replace double quotes with single quotes in rewritten string literal error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\(\"([a-zA-Z0-9]+)\"\)/Error\( format\( '\1' \)/g" {} \; - - # Format code: - - name: 'Replace double quotes with single quotes in inserted `require` calls' - run: | - find . -name "*.js" -exec sed -E -i "s/require\( ?\"@stdlib\/error-tools-fmtprodmsg\" ?\);/require\( '@stdlib\/error-tools-fmtprodmsg' \);/g" {} \; - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\"/\"@stdlib\/error-tools-fmtprodmsg\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^0.0.x'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - uses: actions/checkout@v3 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - uses: act10ns/slack@v1 - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -165,7 +158,7 @@ bool = isUnityProbabilityArray( null ); ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -229,9 +222,9 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. -[@stdlib/assert/is-probability]: https://github.com/stdlib-js/assert-is-probability +[@stdlib/assert/is-probability]: https://github.com/stdlib-js/assert-is-probability/tree/esm -[@stdlib/assert/is-probability-array]: https://github.com/stdlib-js/assert-is-probability-array +[@stdlib/assert/is-probability-array]: https://github.com/stdlib-js/assert-is-probability-array/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 1121550..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,103 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var isUnityProbabilityArray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x; - var i; - - x = []; - for ( i = 0; i < len; i++ ) { - x.push( 1.0/len ); - } - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: we are testing the worst case scenario where a function must scan the entire array before finding a failing value. - x[ len-1 ] = i * 3.14; - bool = isUnityProbabilityArray( x ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( isBoolean( bool ) ) { - b.pass( 'benchmark finished' ); - } else { - b.fail( 'should return a boolean' ); - } - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':len='+len, f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index 6fcd715..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/assert/is-unity-probability-array" -click B href "https://github.com/stdlib-js/assert-is-unity-probability-array/tree/main" -click C href "https://github.com/stdlib-js/assert-is-unity-probability-array/tree/production" -click D href "https://github.com/stdlib-js/assert-is-unity-probability-array/tree/esm" -click E href "https://github.com/stdlib-js/assert-is-unity-probability-array/tree/deno" -click F href "https://github.com/stdlib-js/assert-is-unity-probability-array/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/assert/is-unity-probability-array -[production-url]: https://github.com/stdlib-js/assert-is-unity-probability-array/tree/production -[deno-url]: https://github.com/stdlib-js/assert-is-unity-probability-array/tree/deno -[umd-url]: https://github.com/stdlib-js/assert-is-unity-probability-array/tree/umd -[esm-url]: https://github.com/stdlib-js/assert-is-unity-probability-array/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index a2414be..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,29 +0,0 @@ - -{{alias}}( value ) - Tests if a value is an array of probabilities that sum to one. - - Parameters - ---------- - value: any - Value to test. - - Returns - ------- - bool: boolean - Boolean indicating whether value is an array of probabilities that sum - to one. - - Examples - -------- - > var bool = {{alias}}( [ 0.25, 0.5, 0.25 ] ) - true - > bool = {{alias}}( new {{alias:@stdlib/array/uint8}}( [ 0, 1 ] ) ) - true - > bool = {{alias}}( [ 0.4, 0.4, 0.4 ] ) - false - > bool = {{alias}}( [ 3.14, 0.0 ] ) - false - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 6b41658..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,34 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import isUnityProbabilityArray = require( './index' ); - - -// TESTS // - -// The function returns a boolean... -{ - isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] ); // $ExpectType boolean - isUnityProbabilityArray( [ 2, 3 ] ); // $ExpectType boolean -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - isUnityProbabilityArray(); // $ExpectError - isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ], 123 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index b0b6bbc..0000000 --- a/examples/index.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var Uint8Array = require( '@stdlib/array-uint8' ); -var isUnityProbabilityArray = require( './../lib' ); - -var arr = [ 0.0, 1.0 ]; -console.log( isUnityProbabilityArray( arr ) ); -// => true - -arr = [ 0.5, 0.25, 0.25 ]; -console.log( isUnityProbabilityArray( arr ) ); -// => true - -arr = new Uint8Array( [ 0, 0, 1, 0 ] ); -console.log( isUnityProbabilityArray( arr ) ); -// => true - -arr = [ 0.4, 0.4, 0.4 ]; -console.log( isUnityProbabilityArray( arr ) ); -// => false - -arr = [ 3.14, -1.0 ]; -console.log( isUnityProbabilityArray( arr ) ); -// => false - -console.log( isUnityProbabilityArray( [] ) ); -// => false - -console.log( isUnityProbabilityArray( null ) ); -// => false diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..b43d098 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-typed-array@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array@esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-number@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/math-base-utils-absolute-difference@esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/constants-float64-sqrt-eps@v0.0.8-esm/index.mjs";function n(n){var d,m;if(t(n)){for(d=0,m=0;m1||n[m]<0)return!1;d+=n[m]}return r(d,1)<=i}if(s(n)){for(d=0,m=0;m1||n[m]<0)return!1;d+=n[m]}return r(d,1)<=i}return!1}export{n as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..9e78080 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isTypedArray from '@stdlib/assert-is-typed-array';\nimport isArray from '@stdlib/assert-is-array';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport absdiff from '@stdlib/math-base-utils-absolute-difference';\nimport FLOAT64_SQRT_EPS from '@stdlib/constants-float64-sqrt-eps';\n\n\n// MAIN //\n\n/**\n* Tests if a value is an array of probabilities that sum to one.\n*\n* @param {*} v - value to test\n* @returns {boolean} boolean indicating if a value is a probability array\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] );\n* // returns true\n*\n* @example\n* var bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) );\n* // returns true\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] );\n* // returns false\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 3.14, 0.0 ] );\n* // returns false\n*/\nfunction isUnityProbabilityArray( v ) {\n\tvar sum;\n\tvar i;\n\tif ( isArray( v ) ) {\n\t\tsum = 0.0;\n\t\tfor ( i = 0; i < v.length; i++ ) {\n\t\t\tif (\n\t\t\t\t!isNumber( v[ i ] ) ||\n\t\t\t\tv[ i ] > 1.0 ||\n\t\t\t\tv[ i ] < 0.0\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tsum += v[ i ];\n\t\t}\n\t\treturn ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS );\n\t}\n\tif ( isTypedArray( v ) ) {\n\t\tsum = 0.0;\n\t\tfor ( i = 0; i < v.length; i++ ) {\n\t\t\tif (\n\t\t\t\tv[ i ] > 1.0 ||\n\t\t\t\tv[ i ] < 0.0\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tsum += v[ i ];\n\t\t}\n\t\treturn ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS );\n\t}\n\treturn false;\n}\n\n\n// EXPORTS //\n\nexport default isUnityProbabilityArray;\n"],"names":["isUnityProbabilityArray","v","sum","i","isArray","length","isNumber","absdiff","FLOAT64_SQRT_EPS","isTypedArray"],"mappings":";;2dAqDA,SAASA,EAAyBC,GACjC,IAAIC,EACAC,EACJ,GAAKC,EAASH,GAAM,CAEnB,IADAC,EAAM,EACAC,EAAI,EAAGA,EAAIF,EAAEI,OAAQF,IAAM,CAChC,IACEG,EAAUL,EAAGE,KACdF,EAAGE,GAAM,GACTF,EAAGE,GAAM,EAET,OAAO,EAERD,GAAOD,EAAGE,EACV,CACD,OAASI,EAASL,EAAK,IAASM,CAChC,CACD,GAAKC,EAAcR,GAAM,CAExB,IADAC,EAAM,EACAC,EAAI,EAAGA,EAAIF,EAAEI,OAAQF,IAAM,CAChC,GACCF,EAAGE,GAAM,GACTF,EAAGE,GAAM,EAET,OAAO,EAERD,GAAOD,EAAGE,EACV,CACD,OAASI,EAASL,EAAK,IAASM,CAChC,CACD,OAAO,CACR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 13a67d1..0000000 --- a/lib/index.js +++ /dev/null @@ -1,49 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Test if a value is an array of probabilities that sum to one. -* -* @module @stdlib/assert-is-unity-probability-array -* -* @example -* var isUnityProbabilityArray = require( '@stdlib/assert-is-unity-probability-array' ); -* -* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] ); -* // returns true -* -* bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) ); -* // returns true -* -* bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] ); -* // returns false -* -* bool = isUnityProbabilityArray( [ 3.14, 0.0 ] ); -* // returns false -*/ - -// 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 d0bda40..0000000 --- a/lib/main.js +++ /dev/null @@ -1,90 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -var isArray = require( '@stdlib/assert-is-array' ); -var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var absdiff = require( '@stdlib/math-base-utils-absolute-difference' ); -var FLOAT64_SQRT_EPS = require( '@stdlib/constants-float64-sqrt-eps' ); - - -// MAIN // - -/** -* Tests if a value is an array of probabilities that sum to one. -* -* @param {*} v - value to test -* @returns {boolean} boolean indicating if a value is a probability array -* -* @example -* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] ); -* // returns true -* -* @example -* var bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) ); -* // returns true -* -* @example -* var bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] ); -* // returns false -* -* @example -* var bool = isUnityProbabilityArray( [ 3.14, 0.0 ] ); -* // returns false -*/ -function isUnityProbabilityArray( v ) { - var sum; - var i; - if ( isArray( v ) ) { - sum = 0.0; - for ( i = 0; i < v.length; i++ ) { - if ( - !isNumber( v[ i ] ) || - v[ i ] > 1.0 || - v[ i ] < 0.0 - ) { - return false; - } - sum += v[ i ]; - } - return ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS ); - } - if ( isTypedArray( v ) ) { - sum = 0.0; - for ( i = 0; i < v.length; i++ ) { - if ( - v[ i ] > 1.0 || - v[ i ] < 0.0 - ) { - return false; - } - sum += v[ i ]; - } - return ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS ); - } - return false; -} - - -// EXPORTS // - -module.exports = isUnityProbabilityArray; diff --git a/package.json b/package.json index ecc5f04..bf1e9c3 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.7", "description": "Test if a value is an array of probabilities that sum to one.", "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" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,47 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-array": "^0.0.x", - "@stdlib/assert-is-number": "^0.0.x", - "@stdlib/assert-is-typed-array": "^0.0.x", - "@stdlib/constants-float64-sqrt-eps": "^0.0.x", - "@stdlib/math-base-utils-absolute-difference": "^0.0.x", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x" - }, - "devDependencies": { - "@stdlib/array-float32": "^0.0.x", - "@stdlib/array-float64": "^0.0.x", - "@stdlib/array-int16": "^0.0.x", - "@stdlib/array-int32": "^0.0.x", - "@stdlib/array-int8": "^0.0.x", - "@stdlib/array-uint16": "^0.0.x", - "@stdlib/array-uint32": "^0.0.x", - "@stdlib/array-uint8": "^0.0.x", - "@stdlib/array-uint8c": "^0.0.x", - "@stdlib/assert-is-boolean": "^0.0.x", - "@stdlib/bench": "^0.0.x", - "@stdlib/buffer-from-array": "^0.0.x", - "@stdlib/math-base-special-pow": "^0.0.x", - "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", "stdassert", @@ -105,4 +41,4 @@ "type": "patreon", "url": "https://www.patreon.com/athan" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..50458d9 --- /dev/null +++ b/stats.html @@ -0,0 +1,6177 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 7f6a066..0000000 --- a/test/test.js +++ /dev/null @@ -1,106 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Int8Array = require( '@stdlib/array-int8' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Float64Array = require( '@stdlib/array-float64' ); -var array2buffer = require( '@stdlib/buffer-from-array' ); -var isUnityProbabilityArray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof isUnityProbabilityArray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns `true` if provided an array of probabilities that sum to one', function test( t ) { - var values; - var i; - - values = [ - new Int8Array( [ 0, 0, 1 ] ), - new Uint8Array( [ 1, 0, 0 ] ), - new Uint8ClampedArray( [ 0, 1 ] ), - new Int16Array( [ 0, 0, 1, 0 ] ), - new Uint16Array( [ 1 ] ), - new Int32Array( [ 1, 0, 0 ] ), - new Uint32Array( [ 0, 1, 0 ] ), - new Float32Array( [ 0.0, 0.5, 0.5 ] ), - new Float64Array( [ 0.25, 0.25, 0.5 ] ), - [ 0.5, 0.25, 0.25 ] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.strictEqual( isUnityProbabilityArray( values[i] ), true, 'returns true when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function allows a difference in sum within floating-point epsilon', function test( t ) { - var bool = isUnityProbabilityArray( [ 0.1, 0.2, 0.1, 0.1, 0.2, 0.2, 0.1 ] ); - t.strictEqual( bool, true, 'returns true' ); - t.end(); -}); - -tape( 'the function returns `false` if not provided an array of probabilities that sum to one', function test( t ) { - var values; - var i; - - values = [ - '10', - '01', - '0.5', - '5', - 5, - NaN, - null, - void 0, - true, - [], - [ 5, null ], - [ 5, '5' ], - [ 1.0, 3.14 ], - [ -1.0, 1.0, 1.0 ], - [ 0.25, 0.33, 0.5 ], - new Float64Array( [ 0.25, 0.33, 0.5 ] ), - new Float64Array( [ 0.25, 1.33, 0.5 ] ), - new Float64Array( [ 0.25, -0.33, 0.5 ] ), - {}, - function noop() {}, - array2buffer( [ 1, 1, 0 ] ) - ]; - - for ( i = 0; i < values.length; i++ ) { - t.strictEqual( isUnityProbabilityArray( values[i] ), false, 'returns false when provided '+values[i] ); - } - t.end(); -}); From 44695bc412b1caaae15e4775a337f00ac5111ab3 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 1 Mar 2023 09:57:55 +0000 Subject: [PATCH 039/133] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 2bd7882..287b82d 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,8 @@ "@stdlib/assert-is-number": "^0.0.7", "@stdlib/assert-is-typed-array": "^0.0.6", "@stdlib/constants-float64-sqrt-eps": "^0.0.8", - "@stdlib/math-base-utils-absolute-difference": "^0.0.6" + "@stdlib/math-base-utils-absolute-difference": "^0.0.6", + "@stdlib/error-tools-fmtprodmsg": "^0.0.2" }, "devDependencies": { "@stdlib/array-float32": "^0.0.6", @@ -104,4 +105,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 2c6eecbb17fd580a144b5169e92905e1af50dced Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 1 Mar 2023 19:13:13 +0000 Subject: [PATCH 040/133] Remove files --- index.d.ts | 48 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6230 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index f77442a..0000000 --- a/index.d.ts +++ /dev/null @@ -1,48 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 2.0 - -/** -* Tests if a value is an array of probabilities that sum to one. -* -* @param v - value to test -* @returns boolean indicating if a value is a probability array -* -* @example -* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] ); -* // returns true -* -* @example -* var bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) ); -* // returns true -* -* @example -* var bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] ); -* // returns false -* -* @example -* var bool = isUnityProbabilityArray( [ 3.14, 0.0 ] ); -* // returns false -*/ -declare function isUnityProbabilityArray( v: any ): boolean; - - -// EXPORTS // - -export = isUnityProbabilityArray; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index b43d098..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-typed-array@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array@esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-number@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/math-base-utils-absolute-difference@esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/constants-float64-sqrt-eps@v0.0.8-esm/index.mjs";function n(n){var d,m;if(t(n)){for(d=0,m=0;m1||n[m]<0)return!1;d+=n[m]}return r(d,1)<=i}if(s(n)){for(d=0,m=0;m1||n[m]<0)return!1;d+=n[m]}return r(d,1)<=i}return!1}export{n as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 9e78080..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isTypedArray from '@stdlib/assert-is-typed-array';\nimport isArray from '@stdlib/assert-is-array';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport absdiff from '@stdlib/math-base-utils-absolute-difference';\nimport FLOAT64_SQRT_EPS from '@stdlib/constants-float64-sqrt-eps';\n\n\n// MAIN //\n\n/**\n* Tests if a value is an array of probabilities that sum to one.\n*\n* @param {*} v - value to test\n* @returns {boolean} boolean indicating if a value is a probability array\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] );\n* // returns true\n*\n* @example\n* var bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) );\n* // returns true\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] );\n* // returns false\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 3.14, 0.0 ] );\n* // returns false\n*/\nfunction isUnityProbabilityArray( v ) {\n\tvar sum;\n\tvar i;\n\tif ( isArray( v ) ) {\n\t\tsum = 0.0;\n\t\tfor ( i = 0; i < v.length; i++ ) {\n\t\t\tif (\n\t\t\t\t!isNumber( v[ i ] ) ||\n\t\t\t\tv[ i ] > 1.0 ||\n\t\t\t\tv[ i ] < 0.0\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tsum += v[ i ];\n\t\t}\n\t\treturn ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS );\n\t}\n\tif ( isTypedArray( v ) ) {\n\t\tsum = 0.0;\n\t\tfor ( i = 0; i < v.length; i++ ) {\n\t\t\tif (\n\t\t\t\tv[ i ] > 1.0 ||\n\t\t\t\tv[ i ] < 0.0\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tsum += v[ i ];\n\t\t}\n\t\treturn ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS );\n\t}\n\treturn false;\n}\n\n\n// EXPORTS //\n\nexport default isUnityProbabilityArray;\n"],"names":["isUnityProbabilityArray","v","sum","i","isArray","length","isNumber","absdiff","FLOAT64_SQRT_EPS","isTypedArray"],"mappings":";;2dAqDA,SAASA,EAAyBC,GACjC,IAAIC,EACAC,EACJ,GAAKC,EAASH,GAAM,CAEnB,IADAC,EAAM,EACAC,EAAI,EAAGA,EAAIF,EAAEI,OAAQF,IAAM,CAChC,IACEG,EAAUL,EAAGE,KACdF,EAAGE,GAAM,GACTF,EAAGE,GAAM,EAET,OAAO,EAERD,GAAOD,EAAGE,EACV,CACD,OAASI,EAASL,EAAK,IAASM,CAChC,CACD,GAAKC,EAAcR,GAAM,CAExB,IADAC,EAAM,EACAC,EAAI,EAAGA,EAAIF,EAAEI,OAAQF,IAAM,CAChC,GACCF,EAAGE,GAAM,GACTF,EAAGE,GAAM,EAET,OAAO,EAERD,GAAOD,EAAGE,EACV,CACD,OAASI,EAASL,EAAK,IAASM,CAChC,CACD,OAAO,CACR"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 50458d9..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 5161d1cbfa43bdd07f13d5e996433fa68e0d0adf Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 1 Mar 2023 19:14:01 +0000 Subject: [PATCH 041/133] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 62 - .github/workflows/cancel.yml | 56 - .github/workflows/close_pull_requests.yml | 44 - .github/workflows/examples.yml | 62 - .github/workflows/npm_downloads.yml | 108 - .github/workflows/productionize.yml | 798 --- .github/workflows/publish.yml | 236 - .github/workflows/test.yml | 97 - .github/workflows/test_bundles.yml | 180 - .github/workflows/test_coverage.yml | 123 - .github/workflows/test_install.yml | 83 - .gitignore | 188 - .npmignore | 227 - .npmrc | 28 - CHANGELOG.md | 5 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 41 +- benchmark/benchmark.js | 103 - branches.md | 53 - docs/repl.txt | 29 - docs/types/test.ts | 34 - examples/index.js | 48 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 49 - lib/main.js | 90 - package.json | 70 +- stats.html | 6177 +++++++++++++++++++++ test/test.js | 106 - 37 files changed, 6202 insertions(+), 3679 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 0fd4d6c..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index d59c602..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-03-01T06:24:35.133Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 75a4c32..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/assert/is-unity-probability-array) 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 a5cb54c..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/assert/is-unity-probability-array) 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 0e5537b..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: '49 1 * * 1' - - # 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 3e8e2db..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,798 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - uses: actions/checkout@v3 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Format error messages: - - name: 'Replace double quotes with single quotes in rewritten format string error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\( \"([a-zA-Z0-9]+)\"/Error\( format\( '\1'/g" {} \; - - # Format string literal error messages: - - name: 'Replace double quotes with single quotes in rewritten string literal error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\(\"([a-zA-Z0-9]+)\"\)/Error\( format\( '\1' \)/g" {} \; - - # Format code: - - name: 'Replace double quotes with single quotes in inserted `require` calls' - run: | - find . -name "*.js" -exec sed -E -i "s/require\( ?\"@stdlib\/error-tools-fmtprodmsg\" ?\);/require\( '@stdlib\/error-tools-fmtprodmsg' \);/g" {} \; - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - uses: actions/checkout@v3 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - uses: act10ns/slack@v1 - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -165,7 +158,7 @@ bool = isUnityProbabilityArray( null ); ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -229,9 +222,9 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. -[@stdlib/assert/is-probability]: https://github.com/stdlib-js/assert-is-probability +[@stdlib/assert/is-probability]: https://github.com/stdlib-js/assert-is-probability/tree/esm -[@stdlib/assert/is-probability-array]: https://github.com/stdlib-js/assert-is-probability-array +[@stdlib/assert/is-probability-array]: https://github.com/stdlib-js/assert-is-probability-array/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 1121550..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,103 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var isUnityProbabilityArray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x; - var i; - - x = []; - for ( i = 0; i < len; i++ ) { - x.push( 1.0/len ); - } - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: we are testing the worst case scenario where a function must scan the entire array before finding a failing value. - x[ len-1 ] = i * 3.14; - bool = isUnityProbabilityArray( x ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( isBoolean( bool ) ) { - b.pass( 'benchmark finished' ); - } else { - b.fail( 'should return a boolean' ); - } - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':len='+len, f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index d50fc89..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/assert/is-unity-probability-array" -%% click B href "https://github.com/stdlib-js/assert-is-unity-probability-array/tree/main" -%% click C href "https://github.com/stdlib-js/assert-is-unity-probability-array/tree/production" -%% click D href "https://github.com/stdlib-js/assert-is-unity-probability-array/tree/esm" -%% click E href "https://github.com/stdlib-js/assert-is-unity-probability-array/tree/deno" -%% click F href "https://github.com/stdlib-js/assert-is-unity-probability-array/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/assert/is-unity-probability-array -[production-url]: https://github.com/stdlib-js/assert-is-unity-probability-array/tree/production -[deno-url]: https://github.com/stdlib-js/assert-is-unity-probability-array/tree/deno -[umd-url]: https://github.com/stdlib-js/assert-is-unity-probability-array/tree/umd -[esm-url]: https://github.com/stdlib-js/assert-is-unity-probability-array/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index a2414be..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,29 +0,0 @@ - -{{alias}}( value ) - Tests if a value is an array of probabilities that sum to one. - - Parameters - ---------- - value: any - Value to test. - - Returns - ------- - bool: boolean - Boolean indicating whether value is an array of probabilities that sum - to one. - - Examples - -------- - > var bool = {{alias}}( [ 0.25, 0.5, 0.25 ] ) - true - > bool = {{alias}}( new {{alias:@stdlib/array/uint8}}( [ 0, 1 ] ) ) - true - > bool = {{alias}}( [ 0.4, 0.4, 0.4 ] ) - false - > bool = {{alias}}( [ 3.14, 0.0 ] ) - false - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 6b41658..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,34 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import isUnityProbabilityArray = require( './index' ); - - -// TESTS // - -// The function returns a boolean... -{ - isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] ); // $ExpectType boolean - isUnityProbabilityArray( [ 2, 3 ] ); // $ExpectType boolean -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - isUnityProbabilityArray(); // $ExpectError - isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ], 123 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index b0b6bbc..0000000 --- a/examples/index.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var Uint8Array = require( '@stdlib/array-uint8' ); -var isUnityProbabilityArray = require( './../lib' ); - -var arr = [ 0.0, 1.0 ]; -console.log( isUnityProbabilityArray( arr ) ); -// => true - -arr = [ 0.5, 0.25, 0.25 ]; -console.log( isUnityProbabilityArray( arr ) ); -// => true - -arr = new Uint8Array( [ 0, 0, 1, 0 ] ); -console.log( isUnityProbabilityArray( arr ) ); -// => true - -arr = [ 0.4, 0.4, 0.4 ]; -console.log( isUnityProbabilityArray( arr ) ); -// => false - -arr = [ 3.14, -1.0 ]; -console.log( isUnityProbabilityArray( arr ) ); -// => false - -console.log( isUnityProbabilityArray( [] ) ); -// => false - -console.log( isUnityProbabilityArray( null ) ); -// => false diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..b43d098 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-typed-array@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array@esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-number@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/math-base-utils-absolute-difference@esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/constants-float64-sqrt-eps@v0.0.8-esm/index.mjs";function n(n){var d,m;if(t(n)){for(d=0,m=0;m1||n[m]<0)return!1;d+=n[m]}return r(d,1)<=i}if(s(n)){for(d=0,m=0;m1||n[m]<0)return!1;d+=n[m]}return r(d,1)<=i}return!1}export{n as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..9e78080 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isTypedArray from '@stdlib/assert-is-typed-array';\nimport isArray from '@stdlib/assert-is-array';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport absdiff from '@stdlib/math-base-utils-absolute-difference';\nimport FLOAT64_SQRT_EPS from '@stdlib/constants-float64-sqrt-eps';\n\n\n// MAIN //\n\n/**\n* Tests if a value is an array of probabilities that sum to one.\n*\n* @param {*} v - value to test\n* @returns {boolean} boolean indicating if a value is a probability array\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] );\n* // returns true\n*\n* @example\n* var bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) );\n* // returns true\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] );\n* // returns false\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 3.14, 0.0 ] );\n* // returns false\n*/\nfunction isUnityProbabilityArray( v ) {\n\tvar sum;\n\tvar i;\n\tif ( isArray( v ) ) {\n\t\tsum = 0.0;\n\t\tfor ( i = 0; i < v.length; i++ ) {\n\t\t\tif (\n\t\t\t\t!isNumber( v[ i ] ) ||\n\t\t\t\tv[ i ] > 1.0 ||\n\t\t\t\tv[ i ] < 0.0\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tsum += v[ i ];\n\t\t}\n\t\treturn ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS );\n\t}\n\tif ( isTypedArray( v ) ) {\n\t\tsum = 0.0;\n\t\tfor ( i = 0; i < v.length; i++ ) {\n\t\t\tif (\n\t\t\t\tv[ i ] > 1.0 ||\n\t\t\t\tv[ i ] < 0.0\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tsum += v[ i ];\n\t\t}\n\t\treturn ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS );\n\t}\n\treturn false;\n}\n\n\n// EXPORTS //\n\nexport default isUnityProbabilityArray;\n"],"names":["isUnityProbabilityArray","v","sum","i","isArray","length","isNumber","absdiff","FLOAT64_SQRT_EPS","isTypedArray"],"mappings":";;2dAqDA,SAASA,EAAyBC,GACjC,IAAIC,EACAC,EACJ,GAAKC,EAASH,GAAM,CAEnB,IADAC,EAAM,EACAC,EAAI,EAAGA,EAAIF,EAAEI,OAAQF,IAAM,CAChC,IACEG,EAAUL,EAAGE,KACdF,EAAGE,GAAM,GACTF,EAAGE,GAAM,EAET,OAAO,EAERD,GAAOD,EAAGE,EACV,CACD,OAASI,EAASL,EAAK,IAASM,CAChC,CACD,GAAKC,EAAcR,GAAM,CAExB,IADAC,EAAM,EACAC,EAAI,EAAGA,EAAIF,EAAEI,OAAQF,IAAM,CAChC,GACCF,EAAGE,GAAM,GACTF,EAAGE,GAAM,EAET,OAAO,EAERD,GAAOD,EAAGE,EACV,CACD,OAASI,EAASL,EAAK,IAASM,CAChC,CACD,OAAO,CACR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 13a67d1..0000000 --- a/lib/index.js +++ /dev/null @@ -1,49 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Test if a value is an array of probabilities that sum to one. -* -* @module @stdlib/assert-is-unity-probability-array -* -* @example -* var isUnityProbabilityArray = require( '@stdlib/assert-is-unity-probability-array' ); -* -* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] ); -* // returns true -* -* bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) ); -* // returns true -* -* bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] ); -* // returns false -* -* bool = isUnityProbabilityArray( [ 3.14, 0.0 ] ); -* // returns false -*/ - -// 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 d0bda40..0000000 --- a/lib/main.js +++ /dev/null @@ -1,90 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -var isArray = require( '@stdlib/assert-is-array' ); -var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var absdiff = require( '@stdlib/math-base-utils-absolute-difference' ); -var FLOAT64_SQRT_EPS = require( '@stdlib/constants-float64-sqrt-eps' ); - - -// MAIN // - -/** -* Tests if a value is an array of probabilities that sum to one. -* -* @param {*} v - value to test -* @returns {boolean} boolean indicating if a value is a probability array -* -* @example -* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] ); -* // returns true -* -* @example -* var bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) ); -* // returns true -* -* @example -* var bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] ); -* // returns false -* -* @example -* var bool = isUnityProbabilityArray( [ 3.14, 0.0 ] ); -* // returns false -*/ -function isUnityProbabilityArray( v ) { - var sum; - var i; - if ( isArray( v ) ) { - sum = 0.0; - for ( i = 0; i < v.length; i++ ) { - if ( - !isNumber( v[ i ] ) || - v[ i ] > 1.0 || - v[ i ] < 0.0 - ) { - return false; - } - sum += v[ i ]; - } - return ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS ); - } - if ( isTypedArray( v ) ) { - sum = 0.0; - for ( i = 0; i < v.length; i++ ) { - if ( - v[ i ] > 1.0 || - v[ i ] < 0.0 - ) { - return false; - } - sum += v[ i ]; - } - return ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS ); - } - return false; -} - - -// EXPORTS // - -module.exports = isUnityProbabilityArray; diff --git a/package.json b/package.json index 287b82d..8fae814 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.7", "description": "Test if a value is an array of probabilities that sum to one.", "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" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,47 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-array": "^0.0.7", - "@stdlib/assert-is-number": "^0.0.7", - "@stdlib/assert-is-typed-array": "^0.0.6", - "@stdlib/constants-float64-sqrt-eps": "^0.0.8", - "@stdlib/math-base-utils-absolute-difference": "^0.0.6", - "@stdlib/error-tools-fmtprodmsg": "^0.0.2" - }, - "devDependencies": { - "@stdlib/array-float32": "^0.0.6", - "@stdlib/array-float64": "^0.0.6", - "@stdlib/array-int16": "^0.0.6", - "@stdlib/array-int32": "^0.0.6", - "@stdlib/array-int8": "^0.0.6", - "@stdlib/array-uint16": "^0.0.6", - "@stdlib/array-uint32": "^0.0.6", - "@stdlib/array-uint8": "^0.0.7", - "@stdlib/array-uint8c": "^0.0.8", - "@stdlib/assert-is-boolean": "^0.0.8", - "@stdlib/bench": "^0.0.12", - "@stdlib/buffer-from-array": "^0.0.7", - "@stdlib/math-base-special-pow": "^0.0.7", - "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", "stdassert", @@ -105,4 +41,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..0664b25 --- /dev/null +++ b/stats.html @@ -0,0 +1,6177 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 7f6a066..0000000 --- a/test/test.js +++ /dev/null @@ -1,106 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Int8Array = require( '@stdlib/array-int8' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Float64Array = require( '@stdlib/array-float64' ); -var array2buffer = require( '@stdlib/buffer-from-array' ); -var isUnityProbabilityArray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof isUnityProbabilityArray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns `true` if provided an array of probabilities that sum to one', function test( t ) { - var values; - var i; - - values = [ - new Int8Array( [ 0, 0, 1 ] ), - new Uint8Array( [ 1, 0, 0 ] ), - new Uint8ClampedArray( [ 0, 1 ] ), - new Int16Array( [ 0, 0, 1, 0 ] ), - new Uint16Array( [ 1 ] ), - new Int32Array( [ 1, 0, 0 ] ), - new Uint32Array( [ 0, 1, 0 ] ), - new Float32Array( [ 0.0, 0.5, 0.5 ] ), - new Float64Array( [ 0.25, 0.25, 0.5 ] ), - [ 0.5, 0.25, 0.25 ] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.strictEqual( isUnityProbabilityArray( values[i] ), true, 'returns true when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function allows a difference in sum within floating-point epsilon', function test( t ) { - var bool = isUnityProbabilityArray( [ 0.1, 0.2, 0.1, 0.1, 0.2, 0.2, 0.1 ] ); - t.strictEqual( bool, true, 'returns true' ); - t.end(); -}); - -tape( 'the function returns `false` if not provided an array of probabilities that sum to one', function test( t ) { - var values; - var i; - - values = [ - '10', - '01', - '0.5', - '5', - 5, - NaN, - null, - void 0, - true, - [], - [ 5, null ], - [ 5, '5' ], - [ 1.0, 3.14 ], - [ -1.0, 1.0, 1.0 ], - [ 0.25, 0.33, 0.5 ], - new Float64Array( [ 0.25, 0.33, 0.5 ] ), - new Float64Array( [ 0.25, 1.33, 0.5 ] ), - new Float64Array( [ 0.25, -0.33, 0.5 ] ), - {}, - function noop() {}, - array2buffer( [ 1, 1, 0 ] ) - ]; - - for ( i = 0; i < values.length; i++ ) { - t.strictEqual( isUnityProbabilityArray( values[i] ), false, 'returns false when provided '+values[i] ); - } - t.end(); -}); From 7a64a099a81b91a9fab145309bea3d121227dc37 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Jun 2023 09:39:29 +0000 Subject: [PATCH 042/133] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 2bd7882..287b82d 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,8 @@ "@stdlib/assert-is-number": "^0.0.7", "@stdlib/assert-is-typed-array": "^0.0.6", "@stdlib/constants-float64-sqrt-eps": "^0.0.8", - "@stdlib/math-base-utils-absolute-difference": "^0.0.6" + "@stdlib/math-base-utils-absolute-difference": "^0.0.6", + "@stdlib/error-tools-fmtprodmsg": "^0.0.2" }, "devDependencies": { "@stdlib/array-float32": "^0.0.6", @@ -104,4 +105,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 1cd025162434a7c083ec09bee5ee3f9135ca1c2c Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Jun 2023 18:03:05 +0000 Subject: [PATCH 043/133] Remove files --- index.d.ts | 48 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6230 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index f77442a..0000000 --- a/index.d.ts +++ /dev/null @@ -1,48 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 2.0 - -/** -* Tests if a value is an array of probabilities that sum to one. -* -* @param v - value to test -* @returns boolean indicating if a value is a probability array -* -* @example -* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] ); -* // returns true -* -* @example -* var bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) ); -* // returns true -* -* @example -* var bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] ); -* // returns false -* -* @example -* var bool = isUnityProbabilityArray( [ 3.14, 0.0 ] ); -* // returns false -*/ -declare function isUnityProbabilityArray( v: any ): boolean; - - -// EXPORTS // - -export = isUnityProbabilityArray; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index b43d098..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-typed-array@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array@esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-number@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/math-base-utils-absolute-difference@esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/constants-float64-sqrt-eps@v0.0.8-esm/index.mjs";function n(n){var d,m;if(t(n)){for(d=0,m=0;m1||n[m]<0)return!1;d+=n[m]}return r(d,1)<=i}if(s(n)){for(d=0,m=0;m1||n[m]<0)return!1;d+=n[m]}return r(d,1)<=i}return!1}export{n as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 9e78080..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isTypedArray from '@stdlib/assert-is-typed-array';\nimport isArray from '@stdlib/assert-is-array';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport absdiff from '@stdlib/math-base-utils-absolute-difference';\nimport FLOAT64_SQRT_EPS from '@stdlib/constants-float64-sqrt-eps';\n\n\n// MAIN //\n\n/**\n* Tests if a value is an array of probabilities that sum to one.\n*\n* @param {*} v - value to test\n* @returns {boolean} boolean indicating if a value is a probability array\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] );\n* // returns true\n*\n* @example\n* var bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) );\n* // returns true\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] );\n* // returns false\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 3.14, 0.0 ] );\n* // returns false\n*/\nfunction isUnityProbabilityArray( v ) {\n\tvar sum;\n\tvar i;\n\tif ( isArray( v ) ) {\n\t\tsum = 0.0;\n\t\tfor ( i = 0; i < v.length; i++ ) {\n\t\t\tif (\n\t\t\t\t!isNumber( v[ i ] ) ||\n\t\t\t\tv[ i ] > 1.0 ||\n\t\t\t\tv[ i ] < 0.0\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tsum += v[ i ];\n\t\t}\n\t\treturn ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS );\n\t}\n\tif ( isTypedArray( v ) ) {\n\t\tsum = 0.0;\n\t\tfor ( i = 0; i < v.length; i++ ) {\n\t\t\tif (\n\t\t\t\tv[ i ] > 1.0 ||\n\t\t\t\tv[ i ] < 0.0\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tsum += v[ i ];\n\t\t}\n\t\treturn ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS );\n\t}\n\treturn false;\n}\n\n\n// EXPORTS //\n\nexport default isUnityProbabilityArray;\n"],"names":["isUnityProbabilityArray","v","sum","i","isArray","length","isNumber","absdiff","FLOAT64_SQRT_EPS","isTypedArray"],"mappings":";;2dAqDA,SAASA,EAAyBC,GACjC,IAAIC,EACAC,EACJ,GAAKC,EAASH,GAAM,CAEnB,IADAC,EAAM,EACAC,EAAI,EAAGA,EAAIF,EAAEI,OAAQF,IAAM,CAChC,IACEG,EAAUL,EAAGE,KACdF,EAAGE,GAAM,GACTF,EAAGE,GAAM,EAET,OAAO,EAERD,GAAOD,EAAGE,EACV,CACD,OAASI,EAASL,EAAK,IAASM,CAChC,CACD,GAAKC,EAAcR,GAAM,CAExB,IADAC,EAAM,EACAC,EAAI,EAAGA,EAAIF,EAAEI,OAAQF,IAAM,CAChC,GACCF,EAAGE,GAAM,GACTF,EAAGE,GAAM,EAET,OAAO,EAERD,GAAOD,EAAGE,EACV,CACD,OAASI,EAASL,EAAK,IAASM,CAChC,CACD,OAAO,CACR"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 0664b25..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From bb5cc88ca4aa01cbed469b3259d9b344b31c5ef2 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Jun 2023 18:03:57 +0000 Subject: [PATCH 044/133] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 62 - .github/workflows/cancel.yml | 56 - .github/workflows/close_pull_requests.yml | 44 - .github/workflows/examples.yml | 62 - .github/workflows/npm_downloads.yml | 108 - .github/workflows/productionize.yml | 798 --- .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 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 41 +- benchmark/benchmark.js | 103 - branches.md | 53 - docs/repl.txt | 29 - docs/types/test.ts | 34 - examples/index.js | 48 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 49 - lib/main.js | 90 - package.json | 70 +- stats.html | 6177 +++++++++++++++++++++ test/test.js | 106 - 37 files changed, 6202 insertions(+), 3685 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 0fd4d6c..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 07513d2..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-06-01T06:21:42.806Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 75a4c32..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/assert/is-unity-probability-array) 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 a5cb54c..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/assert/is-unity-probability-array) 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 0e5537b..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: '49 1 * * 1' - - # 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 3e8e2db..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,798 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - uses: actions/checkout@v3 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Format error messages: - - name: 'Replace double quotes with single quotes in rewritten format string error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\( \"([a-zA-Z0-9]+)\"/Error\( format\( '\1'/g" {} \; - - # Format string literal error messages: - - name: 'Replace double quotes with single quotes in rewritten string literal error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\(\"([a-zA-Z0-9]+)\"\)/Error\( format\( '\1' \)/g" {} \; - - # Format code: - - name: 'Replace double quotes with single quotes in inserted `require` calls' - run: | - find . -name "*.js" -exec sed -E -i "s/require\( ?\"@stdlib\/error-tools-fmtprodmsg\" ?\);/require\( '@stdlib\/error-tools-fmtprodmsg' \);/g" {} \; - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - uses: actions/checkout@v3 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - uses: act10ns/slack@v1 - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -165,7 +158,7 @@ bool = isUnityProbabilityArray( null ); ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -229,9 +222,9 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. -[@stdlib/assert/is-probability]: https://github.com/stdlib-js/assert-is-probability +[@stdlib/assert/is-probability]: https://github.com/stdlib-js/assert-is-probability/tree/esm -[@stdlib/assert/is-probability-array]: https://github.com/stdlib-js/assert-is-probability-array +[@stdlib/assert/is-probability-array]: https://github.com/stdlib-js/assert-is-probability-array/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 1121550..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,103 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var isUnityProbabilityArray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x; - var i; - - x = []; - for ( i = 0; i < len; i++ ) { - x.push( 1.0/len ); - } - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: we are testing the worst case scenario where a function must scan the entire array before finding a failing value. - x[ len-1 ] = i * 3.14; - bool = isUnityProbabilityArray( x ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( isBoolean( bool ) ) { - b.pass( 'benchmark finished' ); - } else { - b.fail( 'should return a boolean' ); - } - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':len='+len, f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index d50fc89..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/assert/is-unity-probability-array" -%% click B href "https://github.com/stdlib-js/assert-is-unity-probability-array/tree/main" -%% click C href "https://github.com/stdlib-js/assert-is-unity-probability-array/tree/production" -%% click D href "https://github.com/stdlib-js/assert-is-unity-probability-array/tree/esm" -%% click E href "https://github.com/stdlib-js/assert-is-unity-probability-array/tree/deno" -%% click F href "https://github.com/stdlib-js/assert-is-unity-probability-array/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/assert/is-unity-probability-array -[production-url]: https://github.com/stdlib-js/assert-is-unity-probability-array/tree/production -[deno-url]: https://github.com/stdlib-js/assert-is-unity-probability-array/tree/deno -[umd-url]: https://github.com/stdlib-js/assert-is-unity-probability-array/tree/umd -[esm-url]: https://github.com/stdlib-js/assert-is-unity-probability-array/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index a2414be..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,29 +0,0 @@ - -{{alias}}( value ) - Tests if a value is an array of probabilities that sum to one. - - Parameters - ---------- - value: any - Value to test. - - Returns - ------- - bool: boolean - Boolean indicating whether value is an array of probabilities that sum - to one. - - Examples - -------- - > var bool = {{alias}}( [ 0.25, 0.5, 0.25 ] ) - true - > bool = {{alias}}( new {{alias:@stdlib/array/uint8}}( [ 0, 1 ] ) ) - true - > bool = {{alias}}( [ 0.4, 0.4, 0.4 ] ) - false - > bool = {{alias}}( [ 3.14, 0.0 ] ) - false - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 6b41658..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,34 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import isUnityProbabilityArray = require( './index' ); - - -// TESTS // - -// The function returns a boolean... -{ - isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] ); // $ExpectType boolean - isUnityProbabilityArray( [ 2, 3 ] ); // $ExpectType boolean -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - isUnityProbabilityArray(); // $ExpectError - isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ], 123 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index b0b6bbc..0000000 --- a/examples/index.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var Uint8Array = require( '@stdlib/array-uint8' ); -var isUnityProbabilityArray = require( './../lib' ); - -var arr = [ 0.0, 1.0 ]; -console.log( isUnityProbabilityArray( arr ) ); -// => true - -arr = [ 0.5, 0.25, 0.25 ]; -console.log( isUnityProbabilityArray( arr ) ); -// => true - -arr = new Uint8Array( [ 0, 0, 1, 0 ] ); -console.log( isUnityProbabilityArray( arr ) ); -// => true - -arr = [ 0.4, 0.4, 0.4 ]; -console.log( isUnityProbabilityArray( arr ) ); -// => false - -arr = [ 3.14, -1.0 ]; -console.log( isUnityProbabilityArray( arr ) ); -// => false - -console.log( isUnityProbabilityArray( [] ) ); -// => false - -console.log( isUnityProbabilityArray( null ) ); -// => false diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..b43d098 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-typed-array@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array@esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-number@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/math-base-utils-absolute-difference@esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/constants-float64-sqrt-eps@v0.0.8-esm/index.mjs";function n(n){var d,m;if(t(n)){for(d=0,m=0;m1||n[m]<0)return!1;d+=n[m]}return r(d,1)<=i}if(s(n)){for(d=0,m=0;m1||n[m]<0)return!1;d+=n[m]}return r(d,1)<=i}return!1}export{n as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..9e78080 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isTypedArray from '@stdlib/assert-is-typed-array';\nimport isArray from '@stdlib/assert-is-array';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport absdiff from '@stdlib/math-base-utils-absolute-difference';\nimport FLOAT64_SQRT_EPS from '@stdlib/constants-float64-sqrt-eps';\n\n\n// MAIN //\n\n/**\n* Tests if a value is an array of probabilities that sum to one.\n*\n* @param {*} v - value to test\n* @returns {boolean} boolean indicating if a value is a probability array\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] );\n* // returns true\n*\n* @example\n* var bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) );\n* // returns true\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] );\n* // returns false\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 3.14, 0.0 ] );\n* // returns false\n*/\nfunction isUnityProbabilityArray( v ) {\n\tvar sum;\n\tvar i;\n\tif ( isArray( v ) ) {\n\t\tsum = 0.0;\n\t\tfor ( i = 0; i < v.length; i++ ) {\n\t\t\tif (\n\t\t\t\t!isNumber( v[ i ] ) ||\n\t\t\t\tv[ i ] > 1.0 ||\n\t\t\t\tv[ i ] < 0.0\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tsum += v[ i ];\n\t\t}\n\t\treturn ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS );\n\t}\n\tif ( isTypedArray( v ) ) {\n\t\tsum = 0.0;\n\t\tfor ( i = 0; i < v.length; i++ ) {\n\t\t\tif (\n\t\t\t\tv[ i ] > 1.0 ||\n\t\t\t\tv[ i ] < 0.0\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tsum += v[ i ];\n\t\t}\n\t\treturn ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS );\n\t}\n\treturn false;\n}\n\n\n// EXPORTS //\n\nexport default isUnityProbabilityArray;\n"],"names":["isUnityProbabilityArray","v","sum","i","isArray","length","isNumber","absdiff","FLOAT64_SQRT_EPS","isTypedArray"],"mappings":";;2dAqDA,SAASA,EAAyBC,GACjC,IAAIC,EACAC,EACJ,GAAKC,EAASH,GAAM,CAEnB,IADAC,EAAM,EACAC,EAAI,EAAGA,EAAIF,EAAEI,OAAQF,IAAM,CAChC,IACEG,EAAUL,EAAGE,KACdF,EAAGE,GAAM,GACTF,EAAGE,GAAM,EAET,OAAO,EAERD,GAAOD,EAAGE,EACV,CACD,OAASI,EAASL,EAAK,IAASM,CAChC,CACD,GAAKC,EAAcR,GAAM,CAExB,IADAC,EAAM,EACAC,EAAI,EAAGA,EAAIF,EAAEI,OAAQF,IAAM,CAChC,GACCF,EAAGE,GAAM,GACTF,EAAGE,GAAM,EAET,OAAO,EAERD,GAAOD,EAAGE,EACV,CACD,OAASI,EAASL,EAAK,IAASM,CAChC,CACD,OAAO,CACR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 13a67d1..0000000 --- a/lib/index.js +++ /dev/null @@ -1,49 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Test if a value is an array of probabilities that sum to one. -* -* @module @stdlib/assert-is-unity-probability-array -* -* @example -* var isUnityProbabilityArray = require( '@stdlib/assert-is-unity-probability-array' ); -* -* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] ); -* // returns true -* -* bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) ); -* // returns true -* -* bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] ); -* // returns false -* -* bool = isUnityProbabilityArray( [ 3.14, 0.0 ] ); -* // returns false -*/ - -// 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 d0bda40..0000000 --- a/lib/main.js +++ /dev/null @@ -1,90 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -var isArray = require( '@stdlib/assert-is-array' ); -var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var absdiff = require( '@stdlib/math-base-utils-absolute-difference' ); -var FLOAT64_SQRT_EPS = require( '@stdlib/constants-float64-sqrt-eps' ); - - -// MAIN // - -/** -* Tests if a value is an array of probabilities that sum to one. -* -* @param {*} v - value to test -* @returns {boolean} boolean indicating if a value is a probability array -* -* @example -* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] ); -* // returns true -* -* @example -* var bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) ); -* // returns true -* -* @example -* var bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] ); -* // returns false -* -* @example -* var bool = isUnityProbabilityArray( [ 3.14, 0.0 ] ); -* // returns false -*/ -function isUnityProbabilityArray( v ) { - var sum; - var i; - if ( isArray( v ) ) { - sum = 0.0; - for ( i = 0; i < v.length; i++ ) { - if ( - !isNumber( v[ i ] ) || - v[ i ] > 1.0 || - v[ i ] < 0.0 - ) { - return false; - } - sum += v[ i ]; - } - return ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS ); - } - if ( isTypedArray( v ) ) { - sum = 0.0; - for ( i = 0; i < v.length; i++ ) { - if ( - v[ i ] > 1.0 || - v[ i ] < 0.0 - ) { - return false; - } - sum += v[ i ]; - } - return ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS ); - } - return false; -} - - -// EXPORTS // - -module.exports = isUnityProbabilityArray; diff --git a/package.json b/package.json index 287b82d..8fae814 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.7", "description": "Test if a value is an array of probabilities that sum to one.", "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" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,47 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-array": "^0.0.7", - "@stdlib/assert-is-number": "^0.0.7", - "@stdlib/assert-is-typed-array": "^0.0.6", - "@stdlib/constants-float64-sqrt-eps": "^0.0.8", - "@stdlib/math-base-utils-absolute-difference": "^0.0.6", - "@stdlib/error-tools-fmtprodmsg": "^0.0.2" - }, - "devDependencies": { - "@stdlib/array-float32": "^0.0.6", - "@stdlib/array-float64": "^0.0.6", - "@stdlib/array-int16": "^0.0.6", - "@stdlib/array-int32": "^0.0.6", - "@stdlib/array-int8": "^0.0.6", - "@stdlib/array-uint16": "^0.0.6", - "@stdlib/array-uint32": "^0.0.6", - "@stdlib/array-uint8": "^0.0.7", - "@stdlib/array-uint8c": "^0.0.8", - "@stdlib/assert-is-boolean": "^0.0.8", - "@stdlib/bench": "^0.0.12", - "@stdlib/buffer-from-array": "^0.0.7", - "@stdlib/math-base-special-pow": "^0.0.7", - "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", "stdassert", @@ -105,4 +41,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..f9cf5c4 --- /dev/null +++ b/stats.html @@ -0,0 +1,6177 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 7f6a066..0000000 --- a/test/test.js +++ /dev/null @@ -1,106 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Int8Array = require( '@stdlib/array-int8' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Float64Array = require( '@stdlib/array-float64' ); -var array2buffer = require( '@stdlib/buffer-from-array' ); -var isUnityProbabilityArray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof isUnityProbabilityArray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns `true` if provided an array of probabilities that sum to one', function test( t ) { - var values; - var i; - - values = [ - new Int8Array( [ 0, 0, 1 ] ), - new Uint8Array( [ 1, 0, 0 ] ), - new Uint8ClampedArray( [ 0, 1 ] ), - new Int16Array( [ 0, 0, 1, 0 ] ), - new Uint16Array( [ 1 ] ), - new Int32Array( [ 1, 0, 0 ] ), - new Uint32Array( [ 0, 1, 0 ] ), - new Float32Array( [ 0.0, 0.5, 0.5 ] ), - new Float64Array( [ 0.25, 0.25, 0.5 ] ), - [ 0.5, 0.25, 0.25 ] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.strictEqual( isUnityProbabilityArray( values[i] ), true, 'returns true when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function allows a difference in sum within floating-point epsilon', function test( t ) { - var bool = isUnityProbabilityArray( [ 0.1, 0.2, 0.1, 0.1, 0.2, 0.2, 0.1 ] ); - t.strictEqual( bool, true, 'returns true' ); - t.end(); -}); - -tape( 'the function returns `false` if not provided an array of probabilities that sum to one', function test( t ) { - var values; - var i; - - values = [ - '10', - '01', - '0.5', - '5', - 5, - NaN, - null, - void 0, - true, - [], - [ 5, null ], - [ 5, '5' ], - [ 1.0, 3.14 ], - [ -1.0, 1.0, 1.0 ], - [ 0.25, 0.33, 0.5 ], - new Float64Array( [ 0.25, 0.33, 0.5 ] ), - new Float64Array( [ 0.25, 1.33, 0.5 ] ), - new Float64Array( [ 0.25, -0.33, 0.5 ] ), - {}, - function noop() {}, - array2buffer( [ 1, 1, 0 ] ) - ]; - - for ( i = 0; i < values.length; i++ ) { - t.strictEqual( isUnityProbabilityArray( values[i] ), false, 'returns false when provided '+values[i] ); - } - t.end(); -}); From 658e78604f6c4f0a6891616f26f89ee48b9314b6 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 28 Jun 2023 04:13:39 +0000 Subject: [PATCH 045/133] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 2bd7882..287b82d 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,8 @@ "@stdlib/assert-is-number": "^0.0.7", "@stdlib/assert-is-typed-array": "^0.0.6", "@stdlib/constants-float64-sqrt-eps": "^0.0.8", - "@stdlib/math-base-utils-absolute-difference": "^0.0.6" + "@stdlib/math-base-utils-absolute-difference": "^0.0.6", + "@stdlib/error-tools-fmtprodmsg": "^0.0.2" }, "devDependencies": { "@stdlib/array-float32": "^0.0.6", @@ -104,4 +105,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From bdd525775580340f98702b0892035aa3f6429330 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 28 Jun 2023 04:28:16 +0000 Subject: [PATCH 046/133] Remove files --- index.d.ts | 48 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6230 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index f77442a..0000000 --- a/index.d.ts +++ /dev/null @@ -1,48 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 2.0 - -/** -* Tests if a value is an array of probabilities that sum to one. -* -* @param v - value to test -* @returns boolean indicating if a value is a probability array -* -* @example -* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] ); -* // returns true -* -* @example -* var bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) ); -* // returns true -* -* @example -* var bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] ); -* // returns false -* -* @example -* var bool = isUnityProbabilityArray( [ 3.14, 0.0 ] ); -* // returns false -*/ -declare function isUnityProbabilityArray( v: any ): boolean; - - -// EXPORTS // - -export = isUnityProbabilityArray; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index b43d098..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-typed-array@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array@esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-number@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/math-base-utils-absolute-difference@esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/constants-float64-sqrt-eps@v0.0.8-esm/index.mjs";function n(n){var d,m;if(t(n)){for(d=0,m=0;m1||n[m]<0)return!1;d+=n[m]}return r(d,1)<=i}if(s(n)){for(d=0,m=0;m1||n[m]<0)return!1;d+=n[m]}return r(d,1)<=i}return!1}export{n as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 9e78080..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isTypedArray from '@stdlib/assert-is-typed-array';\nimport isArray from '@stdlib/assert-is-array';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport absdiff from '@stdlib/math-base-utils-absolute-difference';\nimport FLOAT64_SQRT_EPS from '@stdlib/constants-float64-sqrt-eps';\n\n\n// MAIN //\n\n/**\n* Tests if a value is an array of probabilities that sum to one.\n*\n* @param {*} v - value to test\n* @returns {boolean} boolean indicating if a value is a probability array\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] );\n* // returns true\n*\n* @example\n* var bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) );\n* // returns true\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] );\n* // returns false\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 3.14, 0.0 ] );\n* // returns false\n*/\nfunction isUnityProbabilityArray( v ) {\n\tvar sum;\n\tvar i;\n\tif ( isArray( v ) ) {\n\t\tsum = 0.0;\n\t\tfor ( i = 0; i < v.length; i++ ) {\n\t\t\tif (\n\t\t\t\t!isNumber( v[ i ] ) ||\n\t\t\t\tv[ i ] > 1.0 ||\n\t\t\t\tv[ i ] < 0.0\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tsum += v[ i ];\n\t\t}\n\t\treturn ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS );\n\t}\n\tif ( isTypedArray( v ) ) {\n\t\tsum = 0.0;\n\t\tfor ( i = 0; i < v.length; i++ ) {\n\t\t\tif (\n\t\t\t\tv[ i ] > 1.0 ||\n\t\t\t\tv[ i ] < 0.0\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tsum += v[ i ];\n\t\t}\n\t\treturn ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS );\n\t}\n\treturn false;\n}\n\n\n// EXPORTS //\n\nexport default isUnityProbabilityArray;\n"],"names":["isUnityProbabilityArray","v","sum","i","isArray","length","isNumber","absdiff","FLOAT64_SQRT_EPS","isTypedArray"],"mappings":";;2dAqDA,SAASA,EAAyBC,GACjC,IAAIC,EACAC,EACJ,GAAKC,EAASH,GAAM,CAEnB,IADAC,EAAM,EACAC,EAAI,EAAGA,EAAIF,EAAEI,OAAQF,IAAM,CAChC,IACEG,EAAUL,EAAGE,KACdF,EAAGE,GAAM,GACTF,EAAGE,GAAM,EAET,OAAO,EAERD,GAAOD,EAAGE,EACV,CACD,OAASI,EAASL,EAAK,IAASM,CAChC,CACD,GAAKC,EAAcR,GAAM,CAExB,IADAC,EAAM,EACAC,EAAI,EAAGA,EAAIF,EAAEI,OAAQF,IAAM,CAChC,GACCF,EAAGE,GAAM,GACTF,EAAGE,GAAM,EAET,OAAO,EAERD,GAAOD,EAAGE,EACV,CACD,OAASI,EAASL,EAAK,IAASM,CAChC,CACD,OAAO,CACR"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index f9cf5c4..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 34923f775a1a6dfa3b5575bbaf7ec15013f1cff4 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 28 Jun 2023 04:29:12 +0000 Subject: [PATCH 047/133] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 62 - .github/workflows/cancel.yml | 56 - .github/workflows/close_pull_requests.yml | 44 - .github/workflows/examples.yml | 62 - .github/workflows/npm_downloads.yml | 108 - .github/workflows/productionize.yml | 798 --- .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 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 41 +- benchmark/benchmark.js | 103 - branches.md | 53 - docs/repl.txt | 29 - docs/types/test.ts | 34 - examples/index.js | 48 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 49 - lib/main.js | 90 - package.json | 70 +- stats.html | 6177 +++++++++++++++++++++ test/test.js | 106 - 36 files changed, 6202 insertions(+), 3684 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 0fd4d6c..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 75a4c32..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/assert/is-unity-probability-array) 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 a5cb54c..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/assert/is-unity-probability-array) 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 0e5537b..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: '49 1 * * 1' - - # 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 3e8e2db..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,798 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - uses: actions/checkout@v3 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Format error messages: - - name: 'Replace double quotes with single quotes in rewritten format string error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\( \"([a-zA-Z0-9]+)\"/Error\( format\( '\1'/g" {} \; - - # Format string literal error messages: - - name: 'Replace double quotes with single quotes in rewritten string literal error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\(\"([a-zA-Z0-9]+)\"\)/Error\( format\( '\1' \)/g" {} \; - - # Format code: - - name: 'Replace double quotes with single quotes in inserted `require` calls' - run: | - find . -name "*.js" -exec sed -E -i "s/require\( ?\"@stdlib\/error-tools-fmtprodmsg\" ?\);/require\( '@stdlib\/error-tools-fmtprodmsg' \);/g" {} \; - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - uses: actions/checkout@v3 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - uses: act10ns/slack@v1 - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -165,7 +158,7 @@ bool = isUnityProbabilityArray( null ); ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -229,9 +222,9 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. -[@stdlib/assert/is-probability]: https://github.com/stdlib-js/assert-is-probability +[@stdlib/assert/is-probability]: https://github.com/stdlib-js/assert-is-probability/tree/esm -[@stdlib/assert/is-probability-array]: https://github.com/stdlib-js/assert-is-probability-array +[@stdlib/assert/is-probability-array]: https://github.com/stdlib-js/assert-is-probability-array/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 1121550..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,103 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var isUnityProbabilityArray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x; - var i; - - x = []; - for ( i = 0; i < len; i++ ) { - x.push( 1.0/len ); - } - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: we are testing the worst case scenario where a function must scan the entire array before finding a failing value. - x[ len-1 ] = i * 3.14; - bool = isUnityProbabilityArray( x ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( isBoolean( bool ) ) { - b.pass( 'benchmark finished' ); - } else { - b.fail( 'should return a boolean' ); - } - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':len='+len, f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index d50fc89..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/assert/is-unity-probability-array" -%% click B href "https://github.com/stdlib-js/assert-is-unity-probability-array/tree/main" -%% click C href "https://github.com/stdlib-js/assert-is-unity-probability-array/tree/production" -%% click D href "https://github.com/stdlib-js/assert-is-unity-probability-array/tree/esm" -%% click E href "https://github.com/stdlib-js/assert-is-unity-probability-array/tree/deno" -%% click F href "https://github.com/stdlib-js/assert-is-unity-probability-array/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/assert/is-unity-probability-array -[production-url]: https://github.com/stdlib-js/assert-is-unity-probability-array/tree/production -[deno-url]: https://github.com/stdlib-js/assert-is-unity-probability-array/tree/deno -[umd-url]: https://github.com/stdlib-js/assert-is-unity-probability-array/tree/umd -[esm-url]: https://github.com/stdlib-js/assert-is-unity-probability-array/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index a2414be..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,29 +0,0 @@ - -{{alias}}( value ) - Tests if a value is an array of probabilities that sum to one. - - Parameters - ---------- - value: any - Value to test. - - Returns - ------- - bool: boolean - Boolean indicating whether value is an array of probabilities that sum - to one. - - Examples - -------- - > var bool = {{alias}}( [ 0.25, 0.5, 0.25 ] ) - true - > bool = {{alias}}( new {{alias:@stdlib/array/uint8}}( [ 0, 1 ] ) ) - true - > bool = {{alias}}( [ 0.4, 0.4, 0.4 ] ) - false - > bool = {{alias}}( [ 3.14, 0.0 ] ) - false - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 6b41658..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,34 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import isUnityProbabilityArray = require( './index' ); - - -// TESTS // - -// The function returns a boolean... -{ - isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] ); // $ExpectType boolean - isUnityProbabilityArray( [ 2, 3 ] ); // $ExpectType boolean -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - isUnityProbabilityArray(); // $ExpectError - isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ], 123 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index b0b6bbc..0000000 --- a/examples/index.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var Uint8Array = require( '@stdlib/array-uint8' ); -var isUnityProbabilityArray = require( './../lib' ); - -var arr = [ 0.0, 1.0 ]; -console.log( isUnityProbabilityArray( arr ) ); -// => true - -arr = [ 0.5, 0.25, 0.25 ]; -console.log( isUnityProbabilityArray( arr ) ); -// => true - -arr = new Uint8Array( [ 0, 0, 1, 0 ] ); -console.log( isUnityProbabilityArray( arr ) ); -// => true - -arr = [ 0.4, 0.4, 0.4 ]; -console.log( isUnityProbabilityArray( arr ) ); -// => false - -arr = [ 3.14, -1.0 ]; -console.log( isUnityProbabilityArray( arr ) ); -// => false - -console.log( isUnityProbabilityArray( [] ) ); -// => false - -console.log( isUnityProbabilityArray( null ) ); -// => false diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..b43d098 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-typed-array@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array@esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-number@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/math-base-utils-absolute-difference@esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/constants-float64-sqrt-eps@v0.0.8-esm/index.mjs";function n(n){var d,m;if(t(n)){for(d=0,m=0;m1||n[m]<0)return!1;d+=n[m]}return r(d,1)<=i}if(s(n)){for(d=0,m=0;m1||n[m]<0)return!1;d+=n[m]}return r(d,1)<=i}return!1}export{n as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..9e78080 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isTypedArray from '@stdlib/assert-is-typed-array';\nimport isArray from '@stdlib/assert-is-array';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport absdiff from '@stdlib/math-base-utils-absolute-difference';\nimport FLOAT64_SQRT_EPS from '@stdlib/constants-float64-sqrt-eps';\n\n\n// MAIN //\n\n/**\n* Tests if a value is an array of probabilities that sum to one.\n*\n* @param {*} v - value to test\n* @returns {boolean} boolean indicating if a value is a probability array\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] );\n* // returns true\n*\n* @example\n* var bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) );\n* // returns true\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] );\n* // returns false\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 3.14, 0.0 ] );\n* // returns false\n*/\nfunction isUnityProbabilityArray( v ) {\n\tvar sum;\n\tvar i;\n\tif ( isArray( v ) ) {\n\t\tsum = 0.0;\n\t\tfor ( i = 0; i < v.length; i++ ) {\n\t\t\tif (\n\t\t\t\t!isNumber( v[ i ] ) ||\n\t\t\t\tv[ i ] > 1.0 ||\n\t\t\t\tv[ i ] < 0.0\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tsum += v[ i ];\n\t\t}\n\t\treturn ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS );\n\t}\n\tif ( isTypedArray( v ) ) {\n\t\tsum = 0.0;\n\t\tfor ( i = 0; i < v.length; i++ ) {\n\t\t\tif (\n\t\t\t\tv[ i ] > 1.0 ||\n\t\t\t\tv[ i ] < 0.0\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tsum += v[ i ];\n\t\t}\n\t\treturn ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS );\n\t}\n\treturn false;\n}\n\n\n// EXPORTS //\n\nexport default isUnityProbabilityArray;\n"],"names":["isUnityProbabilityArray","v","sum","i","isArray","length","isNumber","absdiff","FLOAT64_SQRT_EPS","isTypedArray"],"mappings":";;2dAqDA,SAASA,EAAyBC,GACjC,IAAIC,EACAC,EACJ,GAAKC,EAASH,GAAM,CAEnB,IADAC,EAAM,EACAC,EAAI,EAAGA,EAAIF,EAAEI,OAAQF,IAAM,CAChC,IACEG,EAAUL,EAAGE,KACdF,EAAGE,GAAM,GACTF,EAAGE,GAAM,EAET,OAAO,EAERD,GAAOD,EAAGE,EACV,CACD,OAASI,EAASL,EAAK,IAASM,CAChC,CACD,GAAKC,EAAcR,GAAM,CAExB,IADAC,EAAM,EACAC,EAAI,EAAGA,EAAIF,EAAEI,OAAQF,IAAM,CAChC,GACCF,EAAGE,GAAM,GACTF,EAAGE,GAAM,EAET,OAAO,EAERD,GAAOD,EAAGE,EACV,CACD,OAASI,EAASL,EAAK,IAASM,CAChC,CACD,OAAO,CACR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 13a67d1..0000000 --- a/lib/index.js +++ /dev/null @@ -1,49 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Test if a value is an array of probabilities that sum to one. -* -* @module @stdlib/assert-is-unity-probability-array -* -* @example -* var isUnityProbabilityArray = require( '@stdlib/assert-is-unity-probability-array' ); -* -* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] ); -* // returns true -* -* bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) ); -* // returns true -* -* bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] ); -* // returns false -* -* bool = isUnityProbabilityArray( [ 3.14, 0.0 ] ); -* // returns false -*/ - -// 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 d0bda40..0000000 --- a/lib/main.js +++ /dev/null @@ -1,90 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -var isArray = require( '@stdlib/assert-is-array' ); -var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var absdiff = require( '@stdlib/math-base-utils-absolute-difference' ); -var FLOAT64_SQRT_EPS = require( '@stdlib/constants-float64-sqrt-eps' ); - - -// MAIN // - -/** -* Tests if a value is an array of probabilities that sum to one. -* -* @param {*} v - value to test -* @returns {boolean} boolean indicating if a value is a probability array -* -* @example -* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] ); -* // returns true -* -* @example -* var bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) ); -* // returns true -* -* @example -* var bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] ); -* // returns false -* -* @example -* var bool = isUnityProbabilityArray( [ 3.14, 0.0 ] ); -* // returns false -*/ -function isUnityProbabilityArray( v ) { - var sum; - var i; - if ( isArray( v ) ) { - sum = 0.0; - for ( i = 0; i < v.length; i++ ) { - if ( - !isNumber( v[ i ] ) || - v[ i ] > 1.0 || - v[ i ] < 0.0 - ) { - return false; - } - sum += v[ i ]; - } - return ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS ); - } - if ( isTypedArray( v ) ) { - sum = 0.0; - for ( i = 0; i < v.length; i++ ) { - if ( - v[ i ] > 1.0 || - v[ i ] < 0.0 - ) { - return false; - } - sum += v[ i ]; - } - return ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS ); - } - return false; -} - - -// EXPORTS // - -module.exports = isUnityProbabilityArray; diff --git a/package.json b/package.json index 287b82d..8fae814 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.7", "description": "Test if a value is an array of probabilities that sum to one.", "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" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,47 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-array": "^0.0.7", - "@stdlib/assert-is-number": "^0.0.7", - "@stdlib/assert-is-typed-array": "^0.0.6", - "@stdlib/constants-float64-sqrt-eps": "^0.0.8", - "@stdlib/math-base-utils-absolute-difference": "^0.0.6", - "@stdlib/error-tools-fmtprodmsg": "^0.0.2" - }, - "devDependencies": { - "@stdlib/array-float32": "^0.0.6", - "@stdlib/array-float64": "^0.0.6", - "@stdlib/array-int16": "^0.0.6", - "@stdlib/array-int32": "^0.0.6", - "@stdlib/array-int8": "^0.0.6", - "@stdlib/array-uint16": "^0.0.6", - "@stdlib/array-uint32": "^0.0.6", - "@stdlib/array-uint8": "^0.0.7", - "@stdlib/array-uint8c": "^0.0.8", - "@stdlib/assert-is-boolean": "^0.0.8", - "@stdlib/bench": "^0.0.12", - "@stdlib/buffer-from-array": "^0.0.7", - "@stdlib/math-base-special-pow": "^0.0.7", - "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", "stdassert", @@ -105,4 +41,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..02af796 --- /dev/null +++ b/stats.html @@ -0,0 +1,6177 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 7f6a066..0000000 --- a/test/test.js +++ /dev/null @@ -1,106 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Int8Array = require( '@stdlib/array-int8' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Float64Array = require( '@stdlib/array-float64' ); -var array2buffer = require( '@stdlib/buffer-from-array' ); -var isUnityProbabilityArray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof isUnityProbabilityArray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns `true` if provided an array of probabilities that sum to one', function test( t ) { - var values; - var i; - - values = [ - new Int8Array( [ 0, 0, 1 ] ), - new Uint8Array( [ 1, 0, 0 ] ), - new Uint8ClampedArray( [ 0, 1 ] ), - new Int16Array( [ 0, 0, 1, 0 ] ), - new Uint16Array( [ 1 ] ), - new Int32Array( [ 1, 0, 0 ] ), - new Uint32Array( [ 0, 1, 0 ] ), - new Float32Array( [ 0.0, 0.5, 0.5 ] ), - new Float64Array( [ 0.25, 0.25, 0.5 ] ), - [ 0.5, 0.25, 0.25 ] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.strictEqual( isUnityProbabilityArray( values[i] ), true, 'returns true when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function allows a difference in sum within floating-point epsilon', function test( t ) { - var bool = isUnityProbabilityArray( [ 0.1, 0.2, 0.1, 0.1, 0.2, 0.2, 0.1 ] ); - t.strictEqual( bool, true, 'returns true' ); - t.end(); -}); - -tape( 'the function returns `false` if not provided an array of probabilities that sum to one', function test( t ) { - var values; - var i; - - values = [ - '10', - '01', - '0.5', - '5', - 5, - NaN, - null, - void 0, - true, - [], - [ 5, null ], - [ 5, '5' ], - [ 1.0, 3.14 ], - [ -1.0, 1.0, 1.0 ], - [ 0.25, 0.33, 0.5 ], - new Float64Array( [ 0.25, 0.33, 0.5 ] ), - new Float64Array( [ 0.25, 1.33, 0.5 ] ), - new Float64Array( [ 0.25, -0.33, 0.5 ] ), - {}, - function noop() {}, - array2buffer( [ 1, 1, 0 ] ) - ]; - - for ( i = 0; i < values.length; i++ ) { - t.strictEqual( isUnityProbabilityArray( values[i] ), false, 'returns false when provided '+values[i] ); - } - t.end(); -}); From df50313fb3ccd099c42a51be19765b032f854907 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 1 Jul 2023 09:07:28 +0000 Subject: [PATCH 048/133] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 2bd7882..287b82d 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,8 @@ "@stdlib/assert-is-number": "^0.0.7", "@stdlib/assert-is-typed-array": "^0.0.6", "@stdlib/constants-float64-sqrt-eps": "^0.0.8", - "@stdlib/math-base-utils-absolute-difference": "^0.0.6" + "@stdlib/math-base-utils-absolute-difference": "^0.0.6", + "@stdlib/error-tools-fmtprodmsg": "^0.0.2" }, "devDependencies": { "@stdlib/array-float32": "^0.0.6", @@ -104,4 +105,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 04688801a3b32481fe7ff14ac0ac0ab3d42731e2 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 1 Jul 2023 18:16:12 +0000 Subject: [PATCH 049/133] Remove files --- index.d.ts | 48 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6230 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index effc3c9..0000000 --- a/index.d.ts +++ /dev/null @@ -1,48 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 2.0 - -/** -* Tests if a value is an array of probabilities that sum to one. -* -* @param v - value to test -* @returns boolean indicating if a value is a probability array -* -* @example -* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] ); -* // returns true -* -* @example -* var bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) ); -* // returns true -* -* @example -* var bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] ); -* // returns false -* -* @example -* var bool = isUnityProbabilityArray( [ 3.14, 0.0 ] ); -* // returns false -*/ -declare function isUnityProbabilityArray( v: any ): v is ArrayLike; - - -// EXPORTS // - -export = isUnityProbabilityArray; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index b43d098..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-typed-array@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array@esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-number@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/math-base-utils-absolute-difference@esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/constants-float64-sqrt-eps@v0.0.8-esm/index.mjs";function n(n){var d,m;if(t(n)){for(d=0,m=0;m1||n[m]<0)return!1;d+=n[m]}return r(d,1)<=i}if(s(n)){for(d=0,m=0;m1||n[m]<0)return!1;d+=n[m]}return r(d,1)<=i}return!1}export{n as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 9e78080..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isTypedArray from '@stdlib/assert-is-typed-array';\nimport isArray from '@stdlib/assert-is-array';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport absdiff from '@stdlib/math-base-utils-absolute-difference';\nimport FLOAT64_SQRT_EPS from '@stdlib/constants-float64-sqrt-eps';\n\n\n// MAIN //\n\n/**\n* Tests if a value is an array of probabilities that sum to one.\n*\n* @param {*} v - value to test\n* @returns {boolean} boolean indicating if a value is a probability array\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] );\n* // returns true\n*\n* @example\n* var bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) );\n* // returns true\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] );\n* // returns false\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 3.14, 0.0 ] );\n* // returns false\n*/\nfunction isUnityProbabilityArray( v ) {\n\tvar sum;\n\tvar i;\n\tif ( isArray( v ) ) {\n\t\tsum = 0.0;\n\t\tfor ( i = 0; i < v.length; i++ ) {\n\t\t\tif (\n\t\t\t\t!isNumber( v[ i ] ) ||\n\t\t\t\tv[ i ] > 1.0 ||\n\t\t\t\tv[ i ] < 0.0\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tsum += v[ i ];\n\t\t}\n\t\treturn ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS );\n\t}\n\tif ( isTypedArray( v ) ) {\n\t\tsum = 0.0;\n\t\tfor ( i = 0; i < v.length; i++ ) {\n\t\t\tif (\n\t\t\t\tv[ i ] > 1.0 ||\n\t\t\t\tv[ i ] < 0.0\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tsum += v[ i ];\n\t\t}\n\t\treturn ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS );\n\t}\n\treturn false;\n}\n\n\n// EXPORTS //\n\nexport default isUnityProbabilityArray;\n"],"names":["isUnityProbabilityArray","v","sum","i","isArray","length","isNumber","absdiff","FLOAT64_SQRT_EPS","isTypedArray"],"mappings":";;2dAqDA,SAASA,EAAyBC,GACjC,IAAIC,EACAC,EACJ,GAAKC,EAASH,GAAM,CAEnB,IADAC,EAAM,EACAC,EAAI,EAAGA,EAAIF,EAAEI,OAAQF,IAAM,CAChC,IACEG,EAAUL,EAAGE,KACdF,EAAGE,GAAM,GACTF,EAAGE,GAAM,EAET,OAAO,EAERD,GAAOD,EAAGE,EACV,CACD,OAASI,EAASL,EAAK,IAASM,CAChC,CACD,GAAKC,EAAcR,GAAM,CAExB,IADAC,EAAM,EACAC,EAAI,EAAGA,EAAIF,EAAEI,OAAQF,IAAM,CAChC,GACCF,EAAGE,GAAM,GACTF,EAAGE,GAAM,EAET,OAAO,EAERD,GAAOD,EAAGE,EACV,CACD,OAASI,EAASL,EAAK,IAASM,CAChC,CACD,OAAO,CACR"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 02af796..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 92f4138e89f06f1cd87c8eae4e8630e71ba7d442 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 1 Jul 2023 18:17:01 +0000 Subject: [PATCH 050/133] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 62 - .github/workflows/cancel.yml | 56 - .github/workflows/close_pull_requests.yml | 44 - .github/workflows/examples.yml | 62 - .github/workflows/npm_downloads.yml | 108 - .github/workflows/productionize.yml | 798 --- .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 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 41 +- benchmark/benchmark.js | 103 - branches.md | 53 - docs/repl.txt | 29 - docs/types/test.ts | 34 - examples/index.js | 48 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 49 - lib/main.js | 90 - package.json | 70 +- stats.html | 6177 +++++++++++++++++++++ test/test.js | 106 - 37 files changed, 6202 insertions(+), 3685 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 0fd4d6c..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 8f01509..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-07-01T06:13:10.896Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 75a4c32..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/assert/is-unity-probability-array) 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 a5cb54c..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/assert/is-unity-probability-array) 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 0e5537b..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: '49 1 * * 1' - - # 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 3e8e2db..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,798 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - uses: actions/checkout@v3 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Format error messages: - - name: 'Replace double quotes with single quotes in rewritten format string error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\( \"([a-zA-Z0-9]+)\"/Error\( format\( '\1'/g" {} \; - - # Format string literal error messages: - - name: 'Replace double quotes with single quotes in rewritten string literal error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\(\"([a-zA-Z0-9]+)\"\)/Error\( format\( '\1' \)/g" {} \; - - # Format code: - - name: 'Replace double quotes with single quotes in inserted `require` calls' - run: | - find . -name "*.js" -exec sed -E -i "s/require\( ?\"@stdlib\/error-tools-fmtprodmsg\" ?\);/require\( '@stdlib\/error-tools-fmtprodmsg' \);/g" {} \; - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - uses: actions/checkout@v3 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - uses: act10ns/slack@v1 - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -165,7 +158,7 @@ bool = isUnityProbabilityArray( null ); ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -229,9 +222,9 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. -[@stdlib/assert/is-probability]: https://github.com/stdlib-js/assert-is-probability +[@stdlib/assert/is-probability]: https://github.com/stdlib-js/assert-is-probability/tree/esm -[@stdlib/assert/is-probability-array]: https://github.com/stdlib-js/assert-is-probability-array +[@stdlib/assert/is-probability-array]: https://github.com/stdlib-js/assert-is-probability-array/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 1121550..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,103 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var isUnityProbabilityArray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x; - var i; - - x = []; - for ( i = 0; i < len; i++ ) { - x.push( 1.0/len ); - } - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: we are testing the worst case scenario where a function must scan the entire array before finding a failing value. - x[ len-1 ] = i * 3.14; - bool = isUnityProbabilityArray( x ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( isBoolean( bool ) ) { - b.pass( 'benchmark finished' ); - } else { - b.fail( 'should return a boolean' ); - } - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':len='+len, f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index d50fc89..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/assert/is-unity-probability-array" -%% click B href "https://github.com/stdlib-js/assert-is-unity-probability-array/tree/main" -%% click C href "https://github.com/stdlib-js/assert-is-unity-probability-array/tree/production" -%% click D href "https://github.com/stdlib-js/assert-is-unity-probability-array/tree/esm" -%% click E href "https://github.com/stdlib-js/assert-is-unity-probability-array/tree/deno" -%% click F href "https://github.com/stdlib-js/assert-is-unity-probability-array/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/assert/is-unity-probability-array -[production-url]: https://github.com/stdlib-js/assert-is-unity-probability-array/tree/production -[deno-url]: https://github.com/stdlib-js/assert-is-unity-probability-array/tree/deno -[umd-url]: https://github.com/stdlib-js/assert-is-unity-probability-array/tree/umd -[esm-url]: https://github.com/stdlib-js/assert-is-unity-probability-array/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index a2414be..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,29 +0,0 @@ - -{{alias}}( value ) - Tests if a value is an array of probabilities that sum to one. - - Parameters - ---------- - value: any - Value to test. - - Returns - ------- - bool: boolean - Boolean indicating whether value is an array of probabilities that sum - to one. - - Examples - -------- - > var bool = {{alias}}( [ 0.25, 0.5, 0.25 ] ) - true - > bool = {{alias}}( new {{alias:@stdlib/array/uint8}}( [ 0, 1 ] ) ) - true - > bool = {{alias}}( [ 0.4, 0.4, 0.4 ] ) - false - > bool = {{alias}}( [ 3.14, 0.0 ] ) - false - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 6b41658..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,34 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import isUnityProbabilityArray = require( './index' ); - - -// TESTS // - -// The function returns a boolean... -{ - isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] ); // $ExpectType boolean - isUnityProbabilityArray( [ 2, 3 ] ); // $ExpectType boolean -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - isUnityProbabilityArray(); // $ExpectError - isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ], 123 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index b0b6bbc..0000000 --- a/examples/index.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var Uint8Array = require( '@stdlib/array-uint8' ); -var isUnityProbabilityArray = require( './../lib' ); - -var arr = [ 0.0, 1.0 ]; -console.log( isUnityProbabilityArray( arr ) ); -// => true - -arr = [ 0.5, 0.25, 0.25 ]; -console.log( isUnityProbabilityArray( arr ) ); -// => true - -arr = new Uint8Array( [ 0, 0, 1, 0 ] ); -console.log( isUnityProbabilityArray( arr ) ); -// => true - -arr = [ 0.4, 0.4, 0.4 ]; -console.log( isUnityProbabilityArray( arr ) ); -// => false - -arr = [ 3.14, -1.0 ]; -console.log( isUnityProbabilityArray( arr ) ); -// => false - -console.log( isUnityProbabilityArray( [] ) ); -// => false - -console.log( isUnityProbabilityArray( null ) ); -// => false diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..b43d098 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-typed-array@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array@esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-number@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/math-base-utils-absolute-difference@esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/constants-float64-sqrt-eps@v0.0.8-esm/index.mjs";function n(n){var d,m;if(t(n)){for(d=0,m=0;m1||n[m]<0)return!1;d+=n[m]}return r(d,1)<=i}if(s(n)){for(d=0,m=0;m1||n[m]<0)return!1;d+=n[m]}return r(d,1)<=i}return!1}export{n as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..9e78080 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isTypedArray from '@stdlib/assert-is-typed-array';\nimport isArray from '@stdlib/assert-is-array';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport absdiff from '@stdlib/math-base-utils-absolute-difference';\nimport FLOAT64_SQRT_EPS from '@stdlib/constants-float64-sqrt-eps';\n\n\n// MAIN //\n\n/**\n* Tests if a value is an array of probabilities that sum to one.\n*\n* @param {*} v - value to test\n* @returns {boolean} boolean indicating if a value is a probability array\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] );\n* // returns true\n*\n* @example\n* var bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) );\n* // returns true\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] );\n* // returns false\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 3.14, 0.0 ] );\n* // returns false\n*/\nfunction isUnityProbabilityArray( v ) {\n\tvar sum;\n\tvar i;\n\tif ( isArray( v ) ) {\n\t\tsum = 0.0;\n\t\tfor ( i = 0; i < v.length; i++ ) {\n\t\t\tif (\n\t\t\t\t!isNumber( v[ i ] ) ||\n\t\t\t\tv[ i ] > 1.0 ||\n\t\t\t\tv[ i ] < 0.0\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tsum += v[ i ];\n\t\t}\n\t\treturn ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS );\n\t}\n\tif ( isTypedArray( v ) ) {\n\t\tsum = 0.0;\n\t\tfor ( i = 0; i < v.length; i++ ) {\n\t\t\tif (\n\t\t\t\tv[ i ] > 1.0 ||\n\t\t\t\tv[ i ] < 0.0\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tsum += v[ i ];\n\t\t}\n\t\treturn ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS );\n\t}\n\treturn false;\n}\n\n\n// EXPORTS //\n\nexport default isUnityProbabilityArray;\n"],"names":["isUnityProbabilityArray","v","sum","i","isArray","length","isNumber","absdiff","FLOAT64_SQRT_EPS","isTypedArray"],"mappings":";;2dAqDA,SAASA,EAAyBC,GACjC,IAAIC,EACAC,EACJ,GAAKC,EAASH,GAAM,CAEnB,IADAC,EAAM,EACAC,EAAI,EAAGA,EAAIF,EAAEI,OAAQF,IAAM,CAChC,IACEG,EAAUL,EAAGE,KACdF,EAAGE,GAAM,GACTF,EAAGE,GAAM,EAET,OAAO,EAERD,GAAOD,EAAGE,EACV,CACD,OAASI,EAASL,EAAK,IAASM,CAChC,CACD,GAAKC,EAAcR,GAAM,CAExB,IADAC,EAAM,EACAC,EAAI,EAAGA,EAAIF,EAAEI,OAAQF,IAAM,CAChC,GACCF,EAAGE,GAAM,GACTF,EAAGE,GAAM,EAET,OAAO,EAERD,GAAOD,EAAGE,EACV,CACD,OAASI,EAASL,EAAK,IAASM,CAChC,CACD,OAAO,CACR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 13a67d1..0000000 --- a/lib/index.js +++ /dev/null @@ -1,49 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Test if a value is an array of probabilities that sum to one. -* -* @module @stdlib/assert-is-unity-probability-array -* -* @example -* var isUnityProbabilityArray = require( '@stdlib/assert-is-unity-probability-array' ); -* -* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] ); -* // returns true -* -* bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) ); -* // returns true -* -* bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] ); -* // returns false -* -* bool = isUnityProbabilityArray( [ 3.14, 0.0 ] ); -* // returns false -*/ - -// 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 d0bda40..0000000 --- a/lib/main.js +++ /dev/null @@ -1,90 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -var isArray = require( '@stdlib/assert-is-array' ); -var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var absdiff = require( '@stdlib/math-base-utils-absolute-difference' ); -var FLOAT64_SQRT_EPS = require( '@stdlib/constants-float64-sqrt-eps' ); - - -// MAIN // - -/** -* Tests if a value is an array of probabilities that sum to one. -* -* @param {*} v - value to test -* @returns {boolean} boolean indicating if a value is a probability array -* -* @example -* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] ); -* // returns true -* -* @example -* var bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) ); -* // returns true -* -* @example -* var bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] ); -* // returns false -* -* @example -* var bool = isUnityProbabilityArray( [ 3.14, 0.0 ] ); -* // returns false -*/ -function isUnityProbabilityArray( v ) { - var sum; - var i; - if ( isArray( v ) ) { - sum = 0.0; - for ( i = 0; i < v.length; i++ ) { - if ( - !isNumber( v[ i ] ) || - v[ i ] > 1.0 || - v[ i ] < 0.0 - ) { - return false; - } - sum += v[ i ]; - } - return ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS ); - } - if ( isTypedArray( v ) ) { - sum = 0.0; - for ( i = 0; i < v.length; i++ ) { - if ( - v[ i ] > 1.0 || - v[ i ] < 0.0 - ) { - return false; - } - sum += v[ i ]; - } - return ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS ); - } - return false; -} - - -// EXPORTS // - -module.exports = isUnityProbabilityArray; diff --git a/package.json b/package.json index 287b82d..8fae814 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.7", "description": "Test if a value is an array of probabilities that sum to one.", "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" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,47 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-array": "^0.0.7", - "@stdlib/assert-is-number": "^0.0.7", - "@stdlib/assert-is-typed-array": "^0.0.6", - "@stdlib/constants-float64-sqrt-eps": "^0.0.8", - "@stdlib/math-base-utils-absolute-difference": "^0.0.6", - "@stdlib/error-tools-fmtprodmsg": "^0.0.2" - }, - "devDependencies": { - "@stdlib/array-float32": "^0.0.6", - "@stdlib/array-float64": "^0.0.6", - "@stdlib/array-int16": "^0.0.6", - "@stdlib/array-int32": "^0.0.6", - "@stdlib/array-int8": "^0.0.6", - "@stdlib/array-uint16": "^0.0.6", - "@stdlib/array-uint32": "^0.0.6", - "@stdlib/array-uint8": "^0.0.7", - "@stdlib/array-uint8c": "^0.0.8", - "@stdlib/assert-is-boolean": "^0.0.8", - "@stdlib/bench": "^0.0.12", - "@stdlib/buffer-from-array": "^0.0.7", - "@stdlib/math-base-special-pow": "^0.0.7", - "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", "stdassert", @@ -105,4 +41,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..a204fa3 --- /dev/null +++ b/stats.html @@ -0,0 +1,6177 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 7f6a066..0000000 --- a/test/test.js +++ /dev/null @@ -1,106 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Int8Array = require( '@stdlib/array-int8' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Float64Array = require( '@stdlib/array-float64' ); -var array2buffer = require( '@stdlib/buffer-from-array' ); -var isUnityProbabilityArray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof isUnityProbabilityArray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns `true` if provided an array of probabilities that sum to one', function test( t ) { - var values; - var i; - - values = [ - new Int8Array( [ 0, 0, 1 ] ), - new Uint8Array( [ 1, 0, 0 ] ), - new Uint8ClampedArray( [ 0, 1 ] ), - new Int16Array( [ 0, 0, 1, 0 ] ), - new Uint16Array( [ 1 ] ), - new Int32Array( [ 1, 0, 0 ] ), - new Uint32Array( [ 0, 1, 0 ] ), - new Float32Array( [ 0.0, 0.5, 0.5 ] ), - new Float64Array( [ 0.25, 0.25, 0.5 ] ), - [ 0.5, 0.25, 0.25 ] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.strictEqual( isUnityProbabilityArray( values[i] ), true, 'returns true when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function allows a difference in sum within floating-point epsilon', function test( t ) { - var bool = isUnityProbabilityArray( [ 0.1, 0.2, 0.1, 0.1, 0.2, 0.2, 0.1 ] ); - t.strictEqual( bool, true, 'returns true' ); - t.end(); -}); - -tape( 'the function returns `false` if not provided an array of probabilities that sum to one', function test( t ) { - var values; - var i; - - values = [ - '10', - '01', - '0.5', - '5', - 5, - NaN, - null, - void 0, - true, - [], - [ 5, null ], - [ 5, '5' ], - [ 1.0, 3.14 ], - [ -1.0, 1.0, 1.0 ], - [ 0.25, 0.33, 0.5 ], - new Float64Array( [ 0.25, 0.33, 0.5 ] ), - new Float64Array( [ 0.25, 1.33, 0.5 ] ), - new Float64Array( [ 0.25, -0.33, 0.5 ] ), - {}, - function noop() {}, - array2buffer( [ 1, 1, 0 ] ) - ]; - - for ( i = 0; i < values.length; i++ ) { - t.strictEqual( isUnityProbabilityArray( values[i] ), false, 'returns false when provided '+values[i] ); - } - t.end(); -}); From f2e66d3efd0ce7f4278d10a246f21abb6ac31945 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 24 Jul 2023 16:44:03 +0000 Subject: [PATCH 051/133] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 2bd7882..287b82d 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,8 @@ "@stdlib/assert-is-number": "^0.0.7", "@stdlib/assert-is-typed-array": "^0.0.6", "@stdlib/constants-float64-sqrt-eps": "^0.0.8", - "@stdlib/math-base-utils-absolute-difference": "^0.0.6" + "@stdlib/math-base-utils-absolute-difference": "^0.0.6", + "@stdlib/error-tools-fmtprodmsg": "^0.0.2" }, "devDependencies": { "@stdlib/array-float32": "^0.0.6", @@ -104,4 +105,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From dd8831f809e3cdceb9818d42a4d293717d97e146 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 24 Jul 2023 17:32:17 +0000 Subject: [PATCH 052/133] Remove files --- index.d.ts | 48 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6230 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index effc3c9..0000000 --- a/index.d.ts +++ /dev/null @@ -1,48 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 2.0 - -/** -* Tests if a value is an array of probabilities that sum to one. -* -* @param v - value to test -* @returns boolean indicating if a value is a probability array -* -* @example -* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] ); -* // returns true -* -* @example -* var bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) ); -* // returns true -* -* @example -* var bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] ); -* // returns false -* -* @example -* var bool = isUnityProbabilityArray( [ 3.14, 0.0 ] ); -* // returns false -*/ -declare function isUnityProbabilityArray( v: any ): v is ArrayLike; - - -// EXPORTS // - -export = isUnityProbabilityArray; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index b43d098..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-typed-array@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array@esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-number@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/math-base-utils-absolute-difference@esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/constants-float64-sqrt-eps@v0.0.8-esm/index.mjs";function n(n){var d,m;if(t(n)){for(d=0,m=0;m1||n[m]<0)return!1;d+=n[m]}return r(d,1)<=i}if(s(n)){for(d=0,m=0;m1||n[m]<0)return!1;d+=n[m]}return r(d,1)<=i}return!1}export{n as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 9e78080..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isTypedArray from '@stdlib/assert-is-typed-array';\nimport isArray from '@stdlib/assert-is-array';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport absdiff from '@stdlib/math-base-utils-absolute-difference';\nimport FLOAT64_SQRT_EPS from '@stdlib/constants-float64-sqrt-eps';\n\n\n// MAIN //\n\n/**\n* Tests if a value is an array of probabilities that sum to one.\n*\n* @param {*} v - value to test\n* @returns {boolean} boolean indicating if a value is a probability array\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] );\n* // returns true\n*\n* @example\n* var bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) );\n* // returns true\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] );\n* // returns false\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 3.14, 0.0 ] );\n* // returns false\n*/\nfunction isUnityProbabilityArray( v ) {\n\tvar sum;\n\tvar i;\n\tif ( isArray( v ) ) {\n\t\tsum = 0.0;\n\t\tfor ( i = 0; i < v.length; i++ ) {\n\t\t\tif (\n\t\t\t\t!isNumber( v[ i ] ) ||\n\t\t\t\tv[ i ] > 1.0 ||\n\t\t\t\tv[ i ] < 0.0\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tsum += v[ i ];\n\t\t}\n\t\treturn ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS );\n\t}\n\tif ( isTypedArray( v ) ) {\n\t\tsum = 0.0;\n\t\tfor ( i = 0; i < v.length; i++ ) {\n\t\t\tif (\n\t\t\t\tv[ i ] > 1.0 ||\n\t\t\t\tv[ i ] < 0.0\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tsum += v[ i ];\n\t\t}\n\t\treturn ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS );\n\t}\n\treturn false;\n}\n\n\n// EXPORTS //\n\nexport default isUnityProbabilityArray;\n"],"names":["isUnityProbabilityArray","v","sum","i","isArray","length","isNumber","absdiff","FLOAT64_SQRT_EPS","isTypedArray"],"mappings":";;2dAqDA,SAASA,EAAyBC,GACjC,IAAIC,EACAC,EACJ,GAAKC,EAASH,GAAM,CAEnB,IADAC,EAAM,EACAC,EAAI,EAAGA,EAAIF,EAAEI,OAAQF,IAAM,CAChC,IACEG,EAAUL,EAAGE,KACdF,EAAGE,GAAM,GACTF,EAAGE,GAAM,EAET,OAAO,EAERD,GAAOD,EAAGE,EACV,CACD,OAASI,EAASL,EAAK,IAASM,CAChC,CACD,GAAKC,EAAcR,GAAM,CAExB,IADAC,EAAM,EACAC,EAAI,EAAGA,EAAIF,EAAEI,OAAQF,IAAM,CAChC,GACCF,EAAGE,GAAM,GACTF,EAAGE,GAAM,EAET,OAAO,EAERD,GAAOD,EAAGE,EACV,CACD,OAASI,EAASL,EAAK,IAASM,CAChC,CACD,OAAO,CACR"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index a204fa3..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 5d7a872ef2b41da90d2eedbf0a5e2252c792f8da Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 24 Jul 2023 17:33:08 +0000 Subject: [PATCH 053/133] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 62 - .github/workflows/cancel.yml | 56 - .github/workflows/close_pull_requests.yml | 44 - .github/workflows/examples.yml | 62 - .github/workflows/npm_downloads.yml | 108 - .github/workflows/productionize.yml | 798 --- .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 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 41 +- benchmark/benchmark.js | 103 - branches.md | 53 - docs/repl.txt | 29 - docs/types/test.ts | 34 - examples/index.js | 48 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 49 - lib/main.js | 90 - package.json | 70 +- stats.html | 6177 +++++++++++++++++++++ test/test.js | 106 - 36 files changed, 6202 insertions(+), 3684 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 0fd4d6c..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 75a4c32..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/assert/is-unity-probability-array) 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 a5cb54c..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/assert/is-unity-probability-array) 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 0e5537b..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: '49 1 * * 1' - - # 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 3e8e2db..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,798 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - uses: actions/checkout@v3 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Format error messages: - - name: 'Replace double quotes with single quotes in rewritten format string error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\( \"([a-zA-Z0-9]+)\"/Error\( format\( '\1'/g" {} \; - - # Format string literal error messages: - - name: 'Replace double quotes with single quotes in rewritten string literal error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\(\"([a-zA-Z0-9]+)\"\)/Error\( format\( '\1' \)/g" {} \; - - # Format code: - - name: 'Replace double quotes with single quotes in inserted `require` calls' - run: | - find . -name "*.js" -exec sed -E -i "s/require\( ?\"@stdlib\/error-tools-fmtprodmsg\" ?\);/require\( '@stdlib\/error-tools-fmtprodmsg' \);/g" {} \; - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - uses: actions/checkout@v3 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - uses: act10ns/slack@v1 - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -165,7 +158,7 @@ bool = isUnityProbabilityArray( null ); ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -229,9 +222,9 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. -[@stdlib/assert/is-probability]: https://github.com/stdlib-js/assert-is-probability +[@stdlib/assert/is-probability]: https://github.com/stdlib-js/assert-is-probability/tree/esm -[@stdlib/assert/is-probability-array]: https://github.com/stdlib-js/assert-is-probability-array +[@stdlib/assert/is-probability-array]: https://github.com/stdlib-js/assert-is-probability-array/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 1121550..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,103 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var isUnityProbabilityArray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x; - var i; - - x = []; - for ( i = 0; i < len; i++ ) { - x.push( 1.0/len ); - } - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: we are testing the worst case scenario where a function must scan the entire array before finding a failing value. - x[ len-1 ] = i * 3.14; - bool = isUnityProbabilityArray( x ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( isBoolean( bool ) ) { - b.pass( 'benchmark finished' ); - } else { - b.fail( 'should return a boolean' ); - } - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':len='+len, f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index d50fc89..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/assert/is-unity-probability-array" -%% click B href "https://github.com/stdlib-js/assert-is-unity-probability-array/tree/main" -%% click C href "https://github.com/stdlib-js/assert-is-unity-probability-array/tree/production" -%% click D href "https://github.com/stdlib-js/assert-is-unity-probability-array/tree/esm" -%% click E href "https://github.com/stdlib-js/assert-is-unity-probability-array/tree/deno" -%% click F href "https://github.com/stdlib-js/assert-is-unity-probability-array/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/assert/is-unity-probability-array -[production-url]: https://github.com/stdlib-js/assert-is-unity-probability-array/tree/production -[deno-url]: https://github.com/stdlib-js/assert-is-unity-probability-array/tree/deno -[umd-url]: https://github.com/stdlib-js/assert-is-unity-probability-array/tree/umd -[esm-url]: https://github.com/stdlib-js/assert-is-unity-probability-array/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index a2414be..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,29 +0,0 @@ - -{{alias}}( value ) - Tests if a value is an array of probabilities that sum to one. - - Parameters - ---------- - value: any - Value to test. - - Returns - ------- - bool: boolean - Boolean indicating whether value is an array of probabilities that sum - to one. - - Examples - -------- - > var bool = {{alias}}( [ 0.25, 0.5, 0.25 ] ) - true - > bool = {{alias}}( new {{alias:@stdlib/array/uint8}}( [ 0, 1 ] ) ) - true - > bool = {{alias}}( [ 0.4, 0.4, 0.4 ] ) - false - > bool = {{alias}}( [ 3.14, 0.0 ] ) - false - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 6b41658..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,34 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import isUnityProbabilityArray = require( './index' ); - - -// TESTS // - -// The function returns a boolean... -{ - isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] ); // $ExpectType boolean - isUnityProbabilityArray( [ 2, 3 ] ); // $ExpectType boolean -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - isUnityProbabilityArray(); // $ExpectError - isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ], 123 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index b0b6bbc..0000000 --- a/examples/index.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var Uint8Array = require( '@stdlib/array-uint8' ); -var isUnityProbabilityArray = require( './../lib' ); - -var arr = [ 0.0, 1.0 ]; -console.log( isUnityProbabilityArray( arr ) ); -// => true - -arr = [ 0.5, 0.25, 0.25 ]; -console.log( isUnityProbabilityArray( arr ) ); -// => true - -arr = new Uint8Array( [ 0, 0, 1, 0 ] ); -console.log( isUnityProbabilityArray( arr ) ); -// => true - -arr = [ 0.4, 0.4, 0.4 ]; -console.log( isUnityProbabilityArray( arr ) ); -// => false - -arr = [ 3.14, -1.0 ]; -console.log( isUnityProbabilityArray( arr ) ); -// => false - -console.log( isUnityProbabilityArray( [] ) ); -// => false - -console.log( isUnityProbabilityArray( null ) ); -// => false diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..b43d098 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-typed-array@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array@esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-number@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/math-base-utils-absolute-difference@esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/constants-float64-sqrt-eps@v0.0.8-esm/index.mjs";function n(n){var d,m;if(t(n)){for(d=0,m=0;m1||n[m]<0)return!1;d+=n[m]}return r(d,1)<=i}if(s(n)){for(d=0,m=0;m1||n[m]<0)return!1;d+=n[m]}return r(d,1)<=i}return!1}export{n as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..9e78080 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isTypedArray from '@stdlib/assert-is-typed-array';\nimport isArray from '@stdlib/assert-is-array';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport absdiff from '@stdlib/math-base-utils-absolute-difference';\nimport FLOAT64_SQRT_EPS from '@stdlib/constants-float64-sqrt-eps';\n\n\n// MAIN //\n\n/**\n* Tests if a value is an array of probabilities that sum to one.\n*\n* @param {*} v - value to test\n* @returns {boolean} boolean indicating if a value is a probability array\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] );\n* // returns true\n*\n* @example\n* var bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) );\n* // returns true\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] );\n* // returns false\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 3.14, 0.0 ] );\n* // returns false\n*/\nfunction isUnityProbabilityArray( v ) {\n\tvar sum;\n\tvar i;\n\tif ( isArray( v ) ) {\n\t\tsum = 0.0;\n\t\tfor ( i = 0; i < v.length; i++ ) {\n\t\t\tif (\n\t\t\t\t!isNumber( v[ i ] ) ||\n\t\t\t\tv[ i ] > 1.0 ||\n\t\t\t\tv[ i ] < 0.0\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tsum += v[ i ];\n\t\t}\n\t\treturn ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS );\n\t}\n\tif ( isTypedArray( v ) ) {\n\t\tsum = 0.0;\n\t\tfor ( i = 0; i < v.length; i++ ) {\n\t\t\tif (\n\t\t\t\tv[ i ] > 1.0 ||\n\t\t\t\tv[ i ] < 0.0\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tsum += v[ i ];\n\t\t}\n\t\treturn ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS );\n\t}\n\treturn false;\n}\n\n\n// EXPORTS //\n\nexport default isUnityProbabilityArray;\n"],"names":["isUnityProbabilityArray","v","sum","i","isArray","length","isNumber","absdiff","FLOAT64_SQRT_EPS","isTypedArray"],"mappings":";;2dAqDA,SAASA,EAAyBC,GACjC,IAAIC,EACAC,EACJ,GAAKC,EAASH,GAAM,CAEnB,IADAC,EAAM,EACAC,EAAI,EAAGA,EAAIF,EAAEI,OAAQF,IAAM,CAChC,IACEG,EAAUL,EAAGE,KACdF,EAAGE,GAAM,GACTF,EAAGE,GAAM,EAET,OAAO,EAERD,GAAOD,EAAGE,EACV,CACD,OAASI,EAASL,EAAK,IAASM,CAChC,CACD,GAAKC,EAAcR,GAAM,CAExB,IADAC,EAAM,EACAC,EAAI,EAAGA,EAAIF,EAAEI,OAAQF,IAAM,CAChC,GACCF,EAAGE,GAAM,GACTF,EAAGE,GAAM,EAET,OAAO,EAERD,GAAOD,EAAGE,EACV,CACD,OAASI,EAASL,EAAK,IAASM,CAChC,CACD,OAAO,CACR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 13a67d1..0000000 --- a/lib/index.js +++ /dev/null @@ -1,49 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Test if a value is an array of probabilities that sum to one. -* -* @module @stdlib/assert-is-unity-probability-array -* -* @example -* var isUnityProbabilityArray = require( '@stdlib/assert-is-unity-probability-array' ); -* -* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] ); -* // returns true -* -* bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) ); -* // returns true -* -* bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] ); -* // returns false -* -* bool = isUnityProbabilityArray( [ 3.14, 0.0 ] ); -* // returns false -*/ - -// 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 d0bda40..0000000 --- a/lib/main.js +++ /dev/null @@ -1,90 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -var isArray = require( '@stdlib/assert-is-array' ); -var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var absdiff = require( '@stdlib/math-base-utils-absolute-difference' ); -var FLOAT64_SQRT_EPS = require( '@stdlib/constants-float64-sqrt-eps' ); - - -// MAIN // - -/** -* Tests if a value is an array of probabilities that sum to one. -* -* @param {*} v - value to test -* @returns {boolean} boolean indicating if a value is a probability array -* -* @example -* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] ); -* // returns true -* -* @example -* var bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) ); -* // returns true -* -* @example -* var bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] ); -* // returns false -* -* @example -* var bool = isUnityProbabilityArray( [ 3.14, 0.0 ] ); -* // returns false -*/ -function isUnityProbabilityArray( v ) { - var sum; - var i; - if ( isArray( v ) ) { - sum = 0.0; - for ( i = 0; i < v.length; i++ ) { - if ( - !isNumber( v[ i ] ) || - v[ i ] > 1.0 || - v[ i ] < 0.0 - ) { - return false; - } - sum += v[ i ]; - } - return ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS ); - } - if ( isTypedArray( v ) ) { - sum = 0.0; - for ( i = 0; i < v.length; i++ ) { - if ( - v[ i ] > 1.0 || - v[ i ] < 0.0 - ) { - return false; - } - sum += v[ i ]; - } - return ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS ); - } - return false; -} - - -// EXPORTS // - -module.exports = isUnityProbabilityArray; diff --git a/package.json b/package.json index 287b82d..8fae814 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.7", "description": "Test if a value is an array of probabilities that sum to one.", "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" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,47 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-array": "^0.0.7", - "@stdlib/assert-is-number": "^0.0.7", - "@stdlib/assert-is-typed-array": "^0.0.6", - "@stdlib/constants-float64-sqrt-eps": "^0.0.8", - "@stdlib/math-base-utils-absolute-difference": "^0.0.6", - "@stdlib/error-tools-fmtprodmsg": "^0.0.2" - }, - "devDependencies": { - "@stdlib/array-float32": "^0.0.6", - "@stdlib/array-float64": "^0.0.6", - "@stdlib/array-int16": "^0.0.6", - "@stdlib/array-int32": "^0.0.6", - "@stdlib/array-int8": "^0.0.6", - "@stdlib/array-uint16": "^0.0.6", - "@stdlib/array-uint32": "^0.0.6", - "@stdlib/array-uint8": "^0.0.7", - "@stdlib/array-uint8c": "^0.0.8", - "@stdlib/assert-is-boolean": "^0.0.8", - "@stdlib/bench": "^0.0.12", - "@stdlib/buffer-from-array": "^0.0.7", - "@stdlib/math-base-special-pow": "^0.0.7", - "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", "stdassert", @@ -105,4 +41,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..b2c35f6 --- /dev/null +++ b/stats.html @@ -0,0 +1,6177 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/test.js b/test/test.js deleted file mode 100644 index a0424fb..0000000 --- a/test/test.js +++ /dev/null @@ -1,106 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Int8Array = require( '@stdlib/array-int8' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Float64Array = require( '@stdlib/array-float64' ); -var array2buffer = require( '@stdlib/buffer-from-array' ); -var isUnityProbabilityArray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof isUnityProbabilityArray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns `true` if provided an array of probabilities that sum to one', function test( t ) { - var values; - var i; - - values = [ - new Int8Array( [ 0, 0, 1 ] ), - new Uint8Array( [ 1, 0, 0 ] ), - new Uint8ClampedArray( [ 0, 1 ] ), - new Int16Array( [ 0, 0, 1, 0 ] ), - new Uint16Array( [ 1 ] ), - new Int32Array( [ 1, 0, 0 ] ), - new Uint32Array( [ 0, 1, 0 ] ), - new Float32Array( [ 0.0, 0.5, 0.5 ] ), - new Float64Array( [ 0.25, 0.25, 0.5 ] ), - [ 0.5, 0.25, 0.25 ] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.strictEqual( isUnityProbabilityArray( values[i] ), true, 'returns true when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function allows a difference in sum within floating-point epsilon', function test( t ) { - var bool = isUnityProbabilityArray( [ 0.1, 0.2, 0.1, 0.1, 0.2, 0.2, 0.1 ] ); - t.strictEqual( bool, true, 'returns true' ); - t.end(); -}); - -tape( 'the function returns `false` if not provided an array of probabilities that sum to one', function test( t ) { - var values; - var i; - - values = [ - '10', - '01', - '0.5', - '5', - 5, - NaN, - null, - void 0, - true, - [], - [ 5, null ], - [ 5, '5' ], - [ 1.0, 3.14 ], - [ -1.0, 1.0, 1.0 ], - [ 0.25, 0.33, 0.5 ], - new Float64Array( [ 0.25, 0.33, 0.5 ] ), - new Float64Array( [ 0.25, 1.33, 0.5 ] ), - new Float64Array( [ 0.25, -0.33, 0.5 ] ), - {}, - function noop() {}, - array2buffer( [ 1, 1, 0 ] ) - ]; - - for ( i = 0; i < values.length; i++ ) { - t.strictEqual( isUnityProbabilityArray( values[i] ), false, 'returns false when provided '+values[i] ); - } - t.end(); -}); From 33e9f5ddcec6540e882eb360949c6da98e78baad Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 24 Sep 2023 06:01:26 +0000 Subject: [PATCH 054/133] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 06edb18..588d124 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,8 @@ "@stdlib/assert-is-number": "^0.1.0", "@stdlib/assert-is-typed-array": "^0.1.0", "@stdlib/constants-float64-sqrt-eps": "^0.1.0", - "@stdlib/math-base-utils-absolute-difference": "^0.2.0" + "@stdlib/math-base-utils-absolute-difference": "^0.2.0", + "@stdlib/error-tools-fmtprodmsg": "^0.1.0" }, "devDependencies": { "@stdlib/array-float32": "^0.1.0", @@ -104,4 +105,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From ca43a7a1a5259a35d8a661f7beba9ca13319d2d5 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 24 Sep 2023 08:21:26 +0000 Subject: [PATCH 055/133] Remove files --- index.d.ts | 48 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6230 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index effc3c9..0000000 --- a/index.d.ts +++ /dev/null @@ -1,48 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 2.0 - -/** -* Tests if a value is an array of probabilities that sum to one. -* -* @param v - value to test -* @returns boolean indicating if a value is a probability array -* -* @example -* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] ); -* // returns true -* -* @example -* var bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) ); -* // returns true -* -* @example -* var bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] ); -* // returns false -* -* @example -* var bool = isUnityProbabilityArray( [ 3.14, 0.0 ] ); -* // returns false -*/ -declare function isUnityProbabilityArray( v: any ): v is ArrayLike; - - -// EXPORTS // - -export = isUnityProbabilityArray; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index b43d098..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-typed-array@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array@esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-number@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/math-base-utils-absolute-difference@esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/constants-float64-sqrt-eps@v0.0.8-esm/index.mjs";function n(n){var d,m;if(t(n)){for(d=0,m=0;m1||n[m]<0)return!1;d+=n[m]}return r(d,1)<=i}if(s(n)){for(d=0,m=0;m1||n[m]<0)return!1;d+=n[m]}return r(d,1)<=i}return!1}export{n as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 9e78080..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isTypedArray from '@stdlib/assert-is-typed-array';\nimport isArray from '@stdlib/assert-is-array';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport absdiff from '@stdlib/math-base-utils-absolute-difference';\nimport FLOAT64_SQRT_EPS from '@stdlib/constants-float64-sqrt-eps';\n\n\n// MAIN //\n\n/**\n* Tests if a value is an array of probabilities that sum to one.\n*\n* @param {*} v - value to test\n* @returns {boolean} boolean indicating if a value is a probability array\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] );\n* // returns true\n*\n* @example\n* var bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) );\n* // returns true\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] );\n* // returns false\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 3.14, 0.0 ] );\n* // returns false\n*/\nfunction isUnityProbabilityArray( v ) {\n\tvar sum;\n\tvar i;\n\tif ( isArray( v ) ) {\n\t\tsum = 0.0;\n\t\tfor ( i = 0; i < v.length; i++ ) {\n\t\t\tif (\n\t\t\t\t!isNumber( v[ i ] ) ||\n\t\t\t\tv[ i ] > 1.0 ||\n\t\t\t\tv[ i ] < 0.0\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tsum += v[ i ];\n\t\t}\n\t\treturn ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS );\n\t}\n\tif ( isTypedArray( v ) ) {\n\t\tsum = 0.0;\n\t\tfor ( i = 0; i < v.length; i++ ) {\n\t\t\tif (\n\t\t\t\tv[ i ] > 1.0 ||\n\t\t\t\tv[ i ] < 0.0\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tsum += v[ i ];\n\t\t}\n\t\treturn ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS );\n\t}\n\treturn false;\n}\n\n\n// EXPORTS //\n\nexport default isUnityProbabilityArray;\n"],"names":["isUnityProbabilityArray","v","sum","i","isArray","length","isNumber","absdiff","FLOAT64_SQRT_EPS","isTypedArray"],"mappings":";;2dAqDA,SAASA,EAAyBC,GACjC,IAAIC,EACAC,EACJ,GAAKC,EAASH,GAAM,CAEnB,IADAC,EAAM,EACAC,EAAI,EAAGA,EAAIF,EAAEI,OAAQF,IAAM,CAChC,IACEG,EAAUL,EAAGE,KACdF,EAAGE,GAAM,GACTF,EAAGE,GAAM,EAET,OAAO,EAERD,GAAOD,EAAGE,EACV,CACD,OAASI,EAASL,EAAK,IAASM,CAChC,CACD,GAAKC,EAAcR,GAAM,CAExB,IADAC,EAAM,EACAC,EAAI,EAAGA,EAAIF,EAAEI,OAAQF,IAAM,CAChC,GACCF,EAAGE,GAAM,GACTF,EAAGE,GAAM,EAET,OAAO,EAERD,GAAOD,EAAGE,EACV,CACD,OAASI,EAASL,EAAK,IAASM,CAChC,CACD,OAAO,CACR"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index b2c35f6..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From d330145124b5ab17c25d97b2974b59f123fc8597 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 24 Sep 2023 08:22:12 +0000 Subject: [PATCH 056/133] 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 | 41 +- benchmark/benchmark.js | 103 - branches.md | 53 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 29 - docs/types/test.ts | 34 - examples/index.js | 48 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 49 - lib/main.js | 90 - package.json | 70 +- stats.html | 6177 +++++++++++++++++++++ test/test.js | 106 - 40 files changed, 6202 insertions(+), 3719 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 delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/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 75a4c32..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/assert/is-unity-probability-array) 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 a5cb54c..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/assert/is-unity-probability-array) 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 0e5537b..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: '49 1 * * 1' - - # 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 + + ```
@@ -176,7 +169,7 @@ bool = isUnityProbabilityArray( null ); ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -240,9 +233,9 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. -[@stdlib/assert/is-probability]: https://github.com/stdlib-js/assert-is-probability +[@stdlib/assert/is-probability]: https://github.com/stdlib-js/assert-is-probability/tree/esm -[@stdlib/assert/is-probability-array]: https://github.com/stdlib-js/assert-is-probability-array +[@stdlib/assert/is-probability-array]: https://github.com/stdlib-js/assert-is-probability-array/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 1121550..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,103 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var isUnityProbabilityArray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x; - var i; - - x = []; - for ( i = 0; i < len; i++ ) { - x.push( 1.0/len ); - } - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: we are testing the worst case scenario where a function must scan the entire array before finding a failing value. - x[ len-1 ] = i * 3.14; - bool = isUnityProbabilityArray( x ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( isBoolean( bool ) ) { - b.pass( 'benchmark finished' ); - } else { - b.fail( 'should return a boolean' ); - } - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':len='+len, f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index d50fc89..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/assert/is-unity-probability-array" -%% click B href "https://github.com/stdlib-js/assert-is-unity-probability-array/tree/main" -%% click C href "https://github.com/stdlib-js/assert-is-unity-probability-array/tree/production" -%% click D href "https://github.com/stdlib-js/assert-is-unity-probability-array/tree/esm" -%% click E href "https://github.com/stdlib-js/assert-is-unity-probability-array/tree/deno" -%% click F href "https://github.com/stdlib-js/assert-is-unity-probability-array/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/assert/is-unity-probability-array -[production-url]: https://github.com/stdlib-js/assert-is-unity-probability-array/tree/production -[deno-url]: https://github.com/stdlib-js/assert-is-unity-probability-array/tree/deno -[umd-url]: https://github.com/stdlib-js/assert-is-unity-probability-array/tree/umd -[esm-url]: https://github.com/stdlib-js/assert-is-unity-probability-array/tree/esm \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index c77d01e..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import isUnityProbabilityArray from '../docs/types/index'; -export = isUnityProbabilityArray; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 70d7801..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var f=function(r,i){return function(){return i||r((i={exports:{}}).exports,i),i.exports}};var u=f(function(m,s){ -var n=require('@stdlib/assert-is-typed-array/dist'),l=require('@stdlib/assert-is-array/dist'),o=require('@stdlib/assert-is-number/dist').isPrimitive,a=require('@stdlib/math-base-utils-absolute-difference/dist'),t=require('@stdlib/constants-float64-sqrt-eps/dist');function q(r){var i,e;if(l(r)){for(i=0,e=0;e1||r[e]<0)return!1;i+=r[e]}return a(i,1)<=t}if(n(r)){for(i=0,e=0;e1||r[e]<0)return!1;i+=r[e]}return a(i,1)<=t}return!1}s.exports=q -});var y=u();module.exports=y; -/** @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 387d5ad..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) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isTypedArray = require( '@stdlib/assert-is-typed-array' );\nvar isArray = require( '@stdlib/assert-is-array' );\nvar isNumber = require( '@stdlib/assert-is-number' ).isPrimitive;\nvar absdiff = require( '@stdlib/math-base-utils-absolute-difference' );\nvar FLOAT64_SQRT_EPS = require( '@stdlib/constants-float64-sqrt-eps' );\n\n\n// MAIN //\n\n/**\n* Tests if a value is an array of probabilities that sum to one.\n*\n* @param {*} v - value to test\n* @returns {boolean} boolean indicating if a value is a probability array\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] );\n* // returns true\n*\n* @example\n* var bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) );\n* // returns true\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] );\n* // returns false\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 3.14, 0.0 ] );\n* // returns false\n*/\nfunction isUnityProbabilityArray( v ) {\n\tvar sum;\n\tvar i;\n\tif ( isArray( v ) ) {\n\t\tsum = 0.0;\n\t\tfor ( i = 0; i < v.length; i++ ) {\n\t\t\tif (\n\t\t\t\t!isNumber( v[ i ] ) ||\n\t\t\t\tv[ i ] > 1.0 ||\n\t\t\t\tv[ i ] < 0.0\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tsum += v[ i ];\n\t\t}\n\t\treturn ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS );\n\t}\n\tif ( isTypedArray( v ) ) {\n\t\tsum = 0.0;\n\t\tfor ( i = 0; i < v.length; i++ ) {\n\t\t\tif (\n\t\t\t\tv[ i ] > 1.0 ||\n\t\t\t\tv[ i ] < 0.0\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tsum += v[ i ];\n\t\t}\n\t\treturn ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS );\n\t}\n\treturn false;\n}\n\n\n// EXPORTS //\n\nmodule.exports = isUnityProbabilityArray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Test if a value is an array of probabilities that sum to one.\n*\n* @module @stdlib/assert-is-unity-probability-array\n*\n* @example\n* var isUnityProbabilityArray = require( '@stdlib/assert-is-unity-probability-array' );\n*\n* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] );\n* // returns true\n*\n* bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) );\n* // returns true\n*\n* bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] );\n* // returns false\n*\n* bool = isUnityProbabilityArray( [ 3.14, 0.0 ] );\n* // returns false\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,EAAe,QAAS,+BAAgC,EACxDC,EAAU,QAAS,yBAA0B,EAC7CC,EAAW,QAAS,0BAA2B,EAAE,YACjDC,EAAU,QAAS,6CAA8C,EACjEC,EAAmB,QAAS,oCAAqC,EA2BrE,SAASC,EAAyBC,EAAI,CACrC,IAAIC,EACAC,EACJ,GAAKP,EAASK,CAAE,EAAI,CAEnB,IADAC,EAAM,EACAC,EAAI,EAAGA,EAAIF,EAAE,OAAQE,IAAM,CAChC,GACC,CAACN,EAAUI,EAAGE,CAAE,CAAE,GAClBF,EAAGE,CAAE,EAAI,GACTF,EAAGE,CAAE,EAAI,EAET,MAAO,GAERD,GAAOD,EAAGE,CAAE,CACb,CACA,OAASL,EAASI,EAAK,CAAI,GAAKH,CACjC,CACA,GAAKJ,EAAcM,CAAE,EAAI,CAExB,IADAC,EAAM,EACAC,EAAI,EAAGA,EAAIF,EAAE,OAAQE,IAAM,CAChC,GACCF,EAAGE,CAAE,EAAI,GACTF,EAAGE,CAAE,EAAI,EAET,MAAO,GAERD,GAAOD,EAAGE,CAAE,CACb,CACA,OAASL,EAASI,EAAK,CAAI,GAAKH,CACjC,CACA,MAAO,EACR,CAKAL,EAAO,QAAUM,IC9CjB,IAAII,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isTypedArray", "isArray", "isNumber", "absdiff", "FLOAT64_SQRT_EPS", "isUnityProbabilityArray", "v", "sum", "i", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index a2414be..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,29 +0,0 @@ - -{{alias}}( value ) - Tests if a value is an array of probabilities that sum to one. - - Parameters - ---------- - value: any - Value to test. - - Returns - ------- - bool: boolean - Boolean indicating whether value is an array of probabilities that sum - to one. - - Examples - -------- - > var bool = {{alias}}( [ 0.25, 0.5, 0.25 ] ) - true - > bool = {{alias}}( new {{alias:@stdlib/array/uint8}}( [ 0, 1 ] ) ) - true - > bool = {{alias}}( [ 0.4, 0.4, 0.4 ] ) - false - > bool = {{alias}}( [ 3.14, 0.0 ] ) - false - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 6b41658..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,34 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import isUnityProbabilityArray = require( './index' ); - - -// TESTS // - -// The function returns a boolean... -{ - isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] ); // $ExpectType boolean - isUnityProbabilityArray( [ 2, 3 ] ); // $ExpectType boolean -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - isUnityProbabilityArray(); // $ExpectError - isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ], 123 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index b0b6bbc..0000000 --- a/examples/index.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var Uint8Array = require( '@stdlib/array-uint8' ); -var isUnityProbabilityArray = require( './../lib' ); - -var arr = [ 0.0, 1.0 ]; -console.log( isUnityProbabilityArray( arr ) ); -// => true - -arr = [ 0.5, 0.25, 0.25 ]; -console.log( isUnityProbabilityArray( arr ) ); -// => true - -arr = new Uint8Array( [ 0, 0, 1, 0 ] ); -console.log( isUnityProbabilityArray( arr ) ); -// => true - -arr = [ 0.4, 0.4, 0.4 ]; -console.log( isUnityProbabilityArray( arr ) ); -// => false - -arr = [ 3.14, -1.0 ]; -console.log( isUnityProbabilityArray( arr ) ); -// => false - -console.log( isUnityProbabilityArray( [] ) ); -// => false - -console.log( isUnityProbabilityArray( null ) ); -// => false diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..4faf0c0 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-typed-array@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array@v0.1.0-esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-number@v0.1.0-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/math-base-utils-absolute-difference@v0.2.0-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/constants-float64-sqrt-eps@v0.1.0-esm/index.mjs";function n(n){var d,m;if(t(n)){for(d=0,m=0;m1||n[m]<0)return!1;d+=n[m]}return r(d,1)<=i}if(s(n)){for(d=0,m=0;m1||n[m]<0)return!1;d+=n[m]}return r(d,1)<=i}return!1}export{n as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..1dcd1a9 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isTypedArray from '@stdlib/assert-is-typed-array';\nimport isArray from '@stdlib/assert-is-array';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport absdiff from '@stdlib/math-base-utils-absolute-difference';\nimport FLOAT64_SQRT_EPS from '@stdlib/constants-float64-sqrt-eps';\n\n\n// MAIN //\n\n/**\n* Tests if a value is an array of probabilities that sum to one.\n*\n* @param {*} v - value to test\n* @returns {boolean} boolean indicating if a value is a probability array\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] );\n* // returns true\n*\n* @example\n* var bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) );\n* // returns true\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] );\n* // returns false\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 3.14, 0.0 ] );\n* // returns false\n*/\nfunction isUnityProbabilityArray( v ) {\n\tvar sum;\n\tvar i;\n\tif ( isArray( v ) ) {\n\t\tsum = 0.0;\n\t\tfor ( i = 0; i < v.length; i++ ) {\n\t\t\tif (\n\t\t\t\t!isNumber( v[ i ] ) ||\n\t\t\t\tv[ i ] > 1.0 ||\n\t\t\t\tv[ i ] < 0.0\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tsum += v[ i ];\n\t\t}\n\t\treturn ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS );\n\t}\n\tif ( isTypedArray( v ) ) {\n\t\tsum = 0.0;\n\t\tfor ( i = 0; i < v.length; i++ ) {\n\t\t\tif (\n\t\t\t\tv[ i ] > 1.0 ||\n\t\t\t\tv[ i ] < 0.0\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tsum += v[ i ];\n\t\t}\n\t\treturn ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS );\n\t}\n\treturn false;\n}\n\n\n// EXPORTS //\n\nexport default isUnityProbabilityArray;\n"],"names":["isUnityProbabilityArray","v","sum","i","isArray","length","isNumber","absdiff","FLOAT64_SQRT_EPS","isTypedArray"],"mappings":";;gfAqDA,SAASA,EAAyBC,GACjC,IAAIC,EACAC,EACJ,GAAKC,EAASH,GAAM,CAEnB,IADAC,EAAM,EACAC,EAAI,EAAGA,EAAIF,EAAEI,OAAQF,IAAM,CAChC,IACEG,EAAUL,EAAGE,KACdF,EAAGE,GAAM,GACTF,EAAGE,GAAM,EAET,OAAO,EAERD,GAAOD,EAAGE,EACV,CACD,OAASI,EAASL,EAAK,IAASM,CAChC,CACD,GAAKC,EAAcR,GAAM,CAExB,IADAC,EAAM,EACAC,EAAI,EAAGA,EAAIF,EAAEI,OAAQF,IAAM,CAChC,GACCF,EAAGE,GAAM,GACTF,EAAGE,GAAM,EAET,OAAO,EAERD,GAAOD,EAAGE,EACV,CACD,OAASI,EAASL,EAAK,IAASM,CAChC,CACD,OAAO,CACR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 13a67d1..0000000 --- a/lib/index.js +++ /dev/null @@ -1,49 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Test if a value is an array of probabilities that sum to one. -* -* @module @stdlib/assert-is-unity-probability-array -* -* @example -* var isUnityProbabilityArray = require( '@stdlib/assert-is-unity-probability-array' ); -* -* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] ); -* // returns true -* -* bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) ); -* // returns true -* -* bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] ); -* // returns false -* -* bool = isUnityProbabilityArray( [ 3.14, 0.0 ] ); -* // returns false -*/ - -// 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 d0bda40..0000000 --- a/lib/main.js +++ /dev/null @@ -1,90 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -var isArray = require( '@stdlib/assert-is-array' ); -var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var absdiff = require( '@stdlib/math-base-utils-absolute-difference' ); -var FLOAT64_SQRT_EPS = require( '@stdlib/constants-float64-sqrt-eps' ); - - -// MAIN // - -/** -* Tests if a value is an array of probabilities that sum to one. -* -* @param {*} v - value to test -* @returns {boolean} boolean indicating if a value is a probability array -* -* @example -* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] ); -* // returns true -* -* @example -* var bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) ); -* // returns true -* -* @example -* var bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] ); -* // returns false -* -* @example -* var bool = isUnityProbabilityArray( [ 3.14, 0.0 ] ); -* // returns false -*/ -function isUnityProbabilityArray( v ) { - var sum; - var i; - if ( isArray( v ) ) { - sum = 0.0; - for ( i = 0; i < v.length; i++ ) { - if ( - !isNumber( v[ i ] ) || - v[ i ] > 1.0 || - v[ i ] < 0.0 - ) { - return false; - } - sum += v[ i ]; - } - return ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS ); - } - if ( isTypedArray( v ) ) { - sum = 0.0; - for ( i = 0; i < v.length; i++ ) { - if ( - v[ i ] > 1.0 || - v[ i ] < 0.0 - ) { - return false; - } - sum += v[ i ]; - } - return ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS ); - } - return false; -} - - -// EXPORTS // - -module.exports = isUnityProbabilityArray; diff --git a/package.json b/package.json index 588d124..660ccd4 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.0", "description": "Test if a value is an array of probabilities that sum to one.", "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" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,47 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-array": "^0.1.0", - "@stdlib/assert-is-number": "^0.1.0", - "@stdlib/assert-is-typed-array": "^0.1.0", - "@stdlib/constants-float64-sqrt-eps": "^0.1.0", - "@stdlib/math-base-utils-absolute-difference": "^0.2.0", - "@stdlib/error-tools-fmtprodmsg": "^0.1.0" - }, - "devDependencies": { - "@stdlib/array-float32": "^0.1.0", - "@stdlib/array-float64": "^0.1.0", - "@stdlib/array-int16": "^0.1.0", - "@stdlib/array-int32": "^0.1.0", - "@stdlib/array-int8": "^0.1.0", - "@stdlib/array-uint16": "^0.1.0", - "@stdlib/array-uint32": "^0.1.0", - "@stdlib/array-uint8": "^0.1.0", - "@stdlib/array-uint8c": "^0.1.0", - "@stdlib/assert-is-boolean": "^0.1.0", - "@stdlib/bench": "^0.1.0", - "@stdlib/buffer-from-array": "^0.1.0", - "@stdlib/math-base-special-pow": "^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", "stdassert", @@ -105,4 +41,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..3db0fe1 --- /dev/null +++ b/stats.html @@ -0,0 +1,6177 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/test.js b/test/test.js deleted file mode 100644 index a0424fb..0000000 --- a/test/test.js +++ /dev/null @@ -1,106 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Int8Array = require( '@stdlib/array-int8' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Float64Array = require( '@stdlib/array-float64' ); -var array2buffer = require( '@stdlib/buffer-from-array' ); -var isUnityProbabilityArray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof isUnityProbabilityArray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns `true` if provided an array of probabilities that sum to one', function test( t ) { - var values; - var i; - - values = [ - new Int8Array( [ 0, 0, 1 ] ), - new Uint8Array( [ 1, 0, 0 ] ), - new Uint8ClampedArray( [ 0, 1 ] ), - new Int16Array( [ 0, 0, 1, 0 ] ), - new Uint16Array( [ 1 ] ), - new Int32Array( [ 1, 0, 0 ] ), - new Uint32Array( [ 0, 1, 0 ] ), - new Float32Array( [ 0.0, 0.5, 0.5 ] ), - new Float64Array( [ 0.25, 0.25, 0.5 ] ), - [ 0.5, 0.25, 0.25 ] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.strictEqual( isUnityProbabilityArray( values[i] ), true, 'returns true when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function allows a difference in sum within floating-point epsilon', function test( t ) { - var bool = isUnityProbabilityArray( [ 0.1, 0.2, 0.1, 0.1, 0.2, 0.2, 0.1 ] ); - t.strictEqual( bool, true, 'returns true' ); - t.end(); -}); - -tape( 'the function returns `false` if not provided an array of probabilities that sum to one', function test( t ) { - var values; - var i; - - values = [ - '10', - '01', - '0.5', - '5', - 5, - NaN, - null, - void 0, - true, - [], - [ 5, null ], - [ 5, '5' ], - [ 1.0, 3.14 ], - [ -1.0, 1.0, 1.0 ], - [ 0.25, 0.33, 0.5 ], - new Float64Array( [ 0.25, 0.33, 0.5 ] ), - new Float64Array( [ 0.25, 1.33, 0.5 ] ), - new Float64Array( [ 0.25, -0.33, 0.5 ] ), - {}, - function noop() {}, - array2buffer( [ 1, 1, 0 ] ) - ]; - - for ( i = 0; i < values.length; i++ ) { - t.strictEqual( isUnityProbabilityArray( values[i] ), false, 'returns false when provided '+values[i] ); - } - t.end(); -}); From 8e88da3705e90abd0ef9de065cf657b015a4e4e4 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 24 Sep 2023 09:36:57 +0000 Subject: [PATCH 057/133] Update README.md for ESM bundle v0.1.0 --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 7176f19..a3749cb 100644 --- a/README.md +++ b/README.md @@ -42,7 +42,7 @@ limitations under the License. ## Usage ```javascript -import isUnityProbabilityArray from 'https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-unity-probability-array@esm/index.mjs'; +import isUnityProbabilityArray from 'https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-unity-probability-array@v0.1.0-esm/index.mjs'; ``` #### isUnityProbabilityArray( value ) @@ -108,7 +108,7 @@ bool = isUnityProbabilityArray( [ 3.14, 0.0 ] ); - - - - From 317b2c261182d39aa166f11a6e29457258905260 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 2 Oct 2023 21:50:30 +0000 Subject: [PATCH 061/133] 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 | 41 +- benchmark/benchmark.js | 103 - branches.md | 53 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 29 - docs/types/test.ts | 34 - examples/index.js | 48 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 49 - lib/main.js | 90 - package.json | 70 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 106 - test/test.js | 106 - 42 files changed, 6202 insertions(+), 3884 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 delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/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 22abd64..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-10-01T04:15:02.251Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 75a4c32..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/assert/is-unity-probability-array) 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 5119885..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/assert/is-unity-probability-array) 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 41d1b0b..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: '49 1 * * 1' - - # 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 + + ```
@@ -176,7 +169,7 @@ bool = isUnityProbabilityArray( null ); ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -240,9 +233,9 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. -[@stdlib/assert/is-probability]: https://github.com/stdlib-js/assert-is-probability +[@stdlib/assert/is-probability]: https://github.com/stdlib-js/assert-is-probability/tree/esm -[@stdlib/assert/is-probability-array]: https://github.com/stdlib-js/assert-is-probability-array +[@stdlib/assert/is-probability-array]: https://github.com/stdlib-js/assert-is-probability-array/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 1121550..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,103 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var isUnityProbabilityArray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x; - var i; - - x = []; - for ( i = 0; i < len; i++ ) { - x.push( 1.0/len ); - } - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: we are testing the worst case scenario where a function must scan the entire array before finding a failing value. - x[ len-1 ] = i * 3.14; - bool = isUnityProbabilityArray( x ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( isBoolean( bool ) ) { - b.pass( 'benchmark finished' ); - } else { - b.fail( 'should return a boolean' ); - } - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':len='+len, f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index d50fc89..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/assert/is-unity-probability-array" -%% click B href "https://github.com/stdlib-js/assert-is-unity-probability-array/tree/main" -%% click C href "https://github.com/stdlib-js/assert-is-unity-probability-array/tree/production" -%% click D href "https://github.com/stdlib-js/assert-is-unity-probability-array/tree/esm" -%% click E href "https://github.com/stdlib-js/assert-is-unity-probability-array/tree/deno" -%% click F href "https://github.com/stdlib-js/assert-is-unity-probability-array/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/assert/is-unity-probability-array -[production-url]: https://github.com/stdlib-js/assert-is-unity-probability-array/tree/production -[deno-url]: https://github.com/stdlib-js/assert-is-unity-probability-array/tree/deno -[umd-url]: https://github.com/stdlib-js/assert-is-unity-probability-array/tree/umd -[esm-url]: https://github.com/stdlib-js/assert-is-unity-probability-array/tree/esm \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index c77d01e..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import isUnityProbabilityArray from '../docs/types/index'; -export = isUnityProbabilityArray; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 70d7801..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var f=function(r,i){return function(){return i||r((i={exports:{}}).exports,i),i.exports}};var u=f(function(m,s){ -var n=require('@stdlib/assert-is-typed-array/dist'),l=require('@stdlib/assert-is-array/dist'),o=require('@stdlib/assert-is-number/dist').isPrimitive,a=require('@stdlib/math-base-utils-absolute-difference/dist'),t=require('@stdlib/constants-float64-sqrt-eps/dist');function q(r){var i,e;if(l(r)){for(i=0,e=0;e1||r[e]<0)return!1;i+=r[e]}return a(i,1)<=t}if(n(r)){for(i=0,e=0;e1||r[e]<0)return!1;i+=r[e]}return a(i,1)<=t}return!1}s.exports=q -});var y=u();module.exports=y; -/** @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 387d5ad..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) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isTypedArray = require( '@stdlib/assert-is-typed-array' );\nvar isArray = require( '@stdlib/assert-is-array' );\nvar isNumber = require( '@stdlib/assert-is-number' ).isPrimitive;\nvar absdiff = require( '@stdlib/math-base-utils-absolute-difference' );\nvar FLOAT64_SQRT_EPS = require( '@stdlib/constants-float64-sqrt-eps' );\n\n\n// MAIN //\n\n/**\n* Tests if a value is an array of probabilities that sum to one.\n*\n* @param {*} v - value to test\n* @returns {boolean} boolean indicating if a value is a probability array\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] );\n* // returns true\n*\n* @example\n* var bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) );\n* // returns true\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] );\n* // returns false\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 3.14, 0.0 ] );\n* // returns false\n*/\nfunction isUnityProbabilityArray( v ) {\n\tvar sum;\n\tvar i;\n\tif ( isArray( v ) ) {\n\t\tsum = 0.0;\n\t\tfor ( i = 0; i < v.length; i++ ) {\n\t\t\tif (\n\t\t\t\t!isNumber( v[ i ] ) ||\n\t\t\t\tv[ i ] > 1.0 ||\n\t\t\t\tv[ i ] < 0.0\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tsum += v[ i ];\n\t\t}\n\t\treturn ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS );\n\t}\n\tif ( isTypedArray( v ) ) {\n\t\tsum = 0.0;\n\t\tfor ( i = 0; i < v.length; i++ ) {\n\t\t\tif (\n\t\t\t\tv[ i ] > 1.0 ||\n\t\t\t\tv[ i ] < 0.0\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tsum += v[ i ];\n\t\t}\n\t\treturn ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS );\n\t}\n\treturn false;\n}\n\n\n// EXPORTS //\n\nmodule.exports = isUnityProbabilityArray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Test if a value is an array of probabilities that sum to one.\n*\n* @module @stdlib/assert-is-unity-probability-array\n*\n* @example\n* var isUnityProbabilityArray = require( '@stdlib/assert-is-unity-probability-array' );\n*\n* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] );\n* // returns true\n*\n* bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) );\n* // returns true\n*\n* bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] );\n* // returns false\n*\n* bool = isUnityProbabilityArray( [ 3.14, 0.0 ] );\n* // returns false\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,EAAe,QAAS,+BAAgC,EACxDC,EAAU,QAAS,yBAA0B,EAC7CC,EAAW,QAAS,0BAA2B,EAAE,YACjDC,EAAU,QAAS,6CAA8C,EACjEC,EAAmB,QAAS,oCAAqC,EA2BrE,SAASC,EAAyBC,EAAI,CACrC,IAAIC,EACAC,EACJ,GAAKP,EAASK,CAAE,EAAI,CAEnB,IADAC,EAAM,EACAC,EAAI,EAAGA,EAAIF,EAAE,OAAQE,IAAM,CAChC,GACC,CAACN,EAAUI,EAAGE,CAAE,CAAE,GAClBF,EAAGE,CAAE,EAAI,GACTF,EAAGE,CAAE,EAAI,EAET,MAAO,GAERD,GAAOD,EAAGE,CAAE,CACb,CACA,OAASL,EAASI,EAAK,CAAI,GAAKH,CACjC,CACA,GAAKJ,EAAcM,CAAE,EAAI,CAExB,IADAC,EAAM,EACAC,EAAI,EAAGA,EAAIF,EAAE,OAAQE,IAAM,CAChC,GACCF,EAAGE,CAAE,EAAI,GACTF,EAAGE,CAAE,EAAI,EAET,MAAO,GAERD,GAAOD,EAAGE,CAAE,CACb,CACA,OAASL,EAASI,EAAK,CAAI,GAAKH,CACjC,CACA,MAAO,EACR,CAKAL,EAAO,QAAUM,IC9CjB,IAAII,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isTypedArray", "isArray", "isNumber", "absdiff", "FLOAT64_SQRT_EPS", "isUnityProbabilityArray", "v", "sum", "i", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index a2414be..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,29 +0,0 @@ - -{{alias}}( value ) - Tests if a value is an array of probabilities that sum to one. - - Parameters - ---------- - value: any - Value to test. - - Returns - ------- - bool: boolean - Boolean indicating whether value is an array of probabilities that sum - to one. - - Examples - -------- - > var bool = {{alias}}( [ 0.25, 0.5, 0.25 ] ) - true - > bool = {{alias}}( new {{alias:@stdlib/array/uint8}}( [ 0, 1 ] ) ) - true - > bool = {{alias}}( [ 0.4, 0.4, 0.4 ] ) - false - > bool = {{alias}}( [ 3.14, 0.0 ] ) - false - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 6b41658..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,34 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import isUnityProbabilityArray = require( './index' ); - - -// TESTS // - -// The function returns a boolean... -{ - isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] ); // $ExpectType boolean - isUnityProbabilityArray( [ 2, 3 ] ); // $ExpectType boolean -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - isUnityProbabilityArray(); // $ExpectError - isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ], 123 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index b0b6bbc..0000000 --- a/examples/index.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var Uint8Array = require( '@stdlib/array-uint8' ); -var isUnityProbabilityArray = require( './../lib' ); - -var arr = [ 0.0, 1.0 ]; -console.log( isUnityProbabilityArray( arr ) ); -// => true - -arr = [ 0.5, 0.25, 0.25 ]; -console.log( isUnityProbabilityArray( arr ) ); -// => true - -arr = new Uint8Array( [ 0, 0, 1, 0 ] ); -console.log( isUnityProbabilityArray( arr ) ); -// => true - -arr = [ 0.4, 0.4, 0.4 ]; -console.log( isUnityProbabilityArray( arr ) ); -// => false - -arr = [ 3.14, -1.0 ]; -console.log( isUnityProbabilityArray( arr ) ); -// => false - -console.log( isUnityProbabilityArray( [] ) ); -// => false - -console.log( isUnityProbabilityArray( null ) ); -// => false diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..a2759d8 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-typed-array@v0.1.0-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array@v0.1.0-esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-number@v0.1.0-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/math-base-utils-absolute-difference@v0.2.0-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/constants-float64-sqrt-eps@v0.1.0-esm/index.mjs";function n(n){var d,m;if(t(n)){for(d=0,m=0;m1||n[m]<0)return!1;d+=n[m]}return r(d,1)<=i}if(s(n)){for(d=0,m=0;m1||n[m]<0)return!1;d+=n[m]}return r(d,1)<=i}return!1}export{n as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..08904b0 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isTypedArray from '@stdlib/assert-is-typed-array';\nimport isArray from '@stdlib/assert-is-array';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport absdiff from '@stdlib/math-base-utils-absolute-difference';\nimport FLOAT64_SQRT_EPS from '@stdlib/constants-float64-sqrt-eps';\n\n\n// MAIN //\n\n/**\n* Tests if a value is an array of probabilities that sum to one.\n*\n* @param {*} v - value to test\n* @returns {boolean} boolean indicating if a value is a probability array\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] );\n* // returns true\n*\n* @example\n* var bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) );\n* // returns true\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] );\n* // returns false\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 3.14, 0.0 ] );\n* // returns false\n*/\nfunction isUnityProbabilityArray( v ) {\n\tvar sum;\n\tvar i;\n\tif ( isArray( v ) ) {\n\t\tsum = 0.0;\n\t\tfor ( i = 0; i < v.length; i++ ) {\n\t\t\tif (\n\t\t\t\t!isNumber( v[ i ] ) ||\n\t\t\t\tv[ i ] > 1.0 ||\n\t\t\t\tv[ i ] < 0.0\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tsum += v[ i ];\n\t\t}\n\t\treturn ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS );\n\t}\n\tif ( isTypedArray( v ) ) {\n\t\tsum = 0.0;\n\t\tfor ( i = 0; i < v.length; i++ ) {\n\t\t\tif (\n\t\t\t\tv[ i ] > 1.0 ||\n\t\t\t\tv[ i ] < 0.0\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tsum += v[ i ];\n\t\t}\n\t\treturn ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS );\n\t}\n\treturn false;\n}\n\n\n// EXPORTS //\n\nexport default isUnityProbabilityArray;\n"],"names":["isUnityProbabilityArray","v","sum","i","isArray","length","isNumber","absdiff","FLOAT64_SQRT_EPS","isTypedArray"],"mappings":";;ufAqDA,SAASA,EAAyBC,GACjC,IAAIC,EACAC,EACJ,GAAKC,EAASH,GAAM,CAEnB,IADAC,EAAM,EACAC,EAAI,EAAGA,EAAIF,EAAEI,OAAQF,IAAM,CAChC,IACEG,EAAUL,EAAGE,KACdF,EAAGE,GAAM,GACTF,EAAGE,GAAM,EAET,OAAO,EAERD,GAAOD,EAAGE,EACV,CACD,OAASI,EAASL,EAAK,IAASM,CAChC,CACD,GAAKC,EAAcR,GAAM,CAExB,IADAC,EAAM,EACAC,EAAI,EAAGA,EAAIF,EAAEI,OAAQF,IAAM,CAChC,GACCF,EAAGE,GAAM,GACTF,EAAGE,GAAM,EAET,OAAO,EAERD,GAAOD,EAAGE,EACV,CACD,OAASI,EAASL,EAAK,IAASM,CAChC,CACD,OAAO,CACR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 13a67d1..0000000 --- a/lib/index.js +++ /dev/null @@ -1,49 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Test if a value is an array of probabilities that sum to one. -* -* @module @stdlib/assert-is-unity-probability-array -* -* @example -* var isUnityProbabilityArray = require( '@stdlib/assert-is-unity-probability-array' ); -* -* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] ); -* // returns true -* -* bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) ); -* // returns true -* -* bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] ); -* // returns false -* -* bool = isUnityProbabilityArray( [ 3.14, 0.0 ] ); -* // returns false -*/ - -// 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 d0bda40..0000000 --- a/lib/main.js +++ /dev/null @@ -1,90 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -var isArray = require( '@stdlib/assert-is-array' ); -var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var absdiff = require( '@stdlib/math-base-utils-absolute-difference' ); -var FLOAT64_SQRT_EPS = require( '@stdlib/constants-float64-sqrt-eps' ); - - -// MAIN // - -/** -* Tests if a value is an array of probabilities that sum to one. -* -* @param {*} v - value to test -* @returns {boolean} boolean indicating if a value is a probability array -* -* @example -* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] ); -* // returns true -* -* @example -* var bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) ); -* // returns true -* -* @example -* var bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] ); -* // returns false -* -* @example -* var bool = isUnityProbabilityArray( [ 3.14, 0.0 ] ); -* // returns false -*/ -function isUnityProbabilityArray( v ) { - var sum; - var i; - if ( isArray( v ) ) { - sum = 0.0; - for ( i = 0; i < v.length; i++ ) { - if ( - !isNumber( v[ i ] ) || - v[ i ] > 1.0 || - v[ i ] < 0.0 - ) { - return false; - } - sum += v[ i ]; - } - return ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS ); - } - if ( isTypedArray( v ) ) { - sum = 0.0; - for ( i = 0; i < v.length; i++ ) { - if ( - v[ i ] > 1.0 || - v[ i ] < 0.0 - ) { - return false; - } - sum += v[ i ]; - } - return ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS ); - } - return false; -} - - -// EXPORTS // - -module.exports = isUnityProbabilityArray; diff --git a/package.json b/package.json index 588d124..660ccd4 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.0", "description": "Test if a value is an array of probabilities that sum to one.", "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" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,47 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-array": "^0.1.0", - "@stdlib/assert-is-number": "^0.1.0", - "@stdlib/assert-is-typed-array": "^0.1.0", - "@stdlib/constants-float64-sqrt-eps": "^0.1.0", - "@stdlib/math-base-utils-absolute-difference": "^0.2.0", - "@stdlib/error-tools-fmtprodmsg": "^0.1.0" - }, - "devDependencies": { - "@stdlib/array-float32": "^0.1.0", - "@stdlib/array-float64": "^0.1.0", - "@stdlib/array-int16": "^0.1.0", - "@stdlib/array-int32": "^0.1.0", - "@stdlib/array-int8": "^0.1.0", - "@stdlib/array-uint16": "^0.1.0", - "@stdlib/array-uint32": "^0.1.0", - "@stdlib/array-uint8": "^0.1.0", - "@stdlib/array-uint8c": "^0.1.0", - "@stdlib/assert-is-boolean": "^0.1.0", - "@stdlib/bench": "^0.1.0", - "@stdlib/buffer-from-array": "^0.1.0", - "@stdlib/math-base-special-pow": "^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", "stdassert", @@ -105,4 +41,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..c8e375e --- /dev/null +++ b/stats.html @@ -0,0 +1,6177 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index 122d26d..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,106 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Int8Array = require( '@stdlib/array-int8' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Float64Array = require( '@stdlib/array-float64' ); -var array2buffer = require( '@stdlib/buffer-from-array' ); -var isUnityProbabilityArray = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof isUnityProbabilityArray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns `true` if provided an array of probabilities that sum to one', function test( t ) { - var values; - var i; - - values = [ - new Int8Array( [ 0, 0, 1 ] ), - new Uint8Array( [ 1, 0, 0 ] ), - new Uint8ClampedArray( [ 0, 1 ] ), - new Int16Array( [ 0, 0, 1, 0 ] ), - new Uint16Array( [ 1 ] ), - new Int32Array( [ 1, 0, 0 ] ), - new Uint32Array( [ 0, 1, 0 ] ), - new Float32Array( [ 0.0, 0.5, 0.5 ] ), - new Float64Array( [ 0.25, 0.25, 0.5 ] ), - [ 0.5, 0.25, 0.25 ] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.strictEqual( isUnityProbabilityArray( values[i] ), true, 'returns true when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function allows a difference in sum within floating-point epsilon', function test( t ) { - var bool = isUnityProbabilityArray( [ 0.1, 0.2, 0.1, 0.1, 0.2, 0.2, 0.1 ] ); - t.strictEqual( bool, true, 'returns true' ); - t.end(); -}); - -tape( 'the function returns `false` if not provided an array of probabilities that sum to one', function test( t ) { - var values; - var i; - - values = [ - '10', - '01', - '0.5', - '5', - 5, - NaN, - null, - void 0, - true, - [], - [ 5, null ], - [ 5, '5' ], - [ 1.0, 3.14 ], - [ -1.0, 1.0, 1.0 ], - [ 0.25, 0.33, 0.5 ], - new Float64Array( [ 0.25, 0.33, 0.5 ] ), - new Float64Array( [ 0.25, 1.33, 0.5 ] ), - new Float64Array( [ 0.25, -0.33, 0.5 ] ), - {}, - function noop() {}, - array2buffer( [ 1, 1, 0 ] ) - ]; - - for ( i = 0; i < values.length; i++ ) { - t.strictEqual( isUnityProbabilityArray( values[i] ), false, 'returns false when provided '+values[i] ); - } - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index a0424fb..0000000 --- a/test/test.js +++ /dev/null @@ -1,106 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Int8Array = require( '@stdlib/array-int8' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Float64Array = require( '@stdlib/array-float64' ); -var array2buffer = require( '@stdlib/buffer-from-array' ); -var isUnityProbabilityArray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof isUnityProbabilityArray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns `true` if provided an array of probabilities that sum to one', function test( t ) { - var values; - var i; - - values = [ - new Int8Array( [ 0, 0, 1 ] ), - new Uint8Array( [ 1, 0, 0 ] ), - new Uint8ClampedArray( [ 0, 1 ] ), - new Int16Array( [ 0, 0, 1, 0 ] ), - new Uint16Array( [ 1 ] ), - new Int32Array( [ 1, 0, 0 ] ), - new Uint32Array( [ 0, 1, 0 ] ), - new Float32Array( [ 0.0, 0.5, 0.5 ] ), - new Float64Array( [ 0.25, 0.25, 0.5 ] ), - [ 0.5, 0.25, 0.25 ] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.strictEqual( isUnityProbabilityArray( values[i] ), true, 'returns true when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function allows a difference in sum within floating-point epsilon', function test( t ) { - var bool = isUnityProbabilityArray( [ 0.1, 0.2, 0.1, 0.1, 0.2, 0.2, 0.1 ] ); - t.strictEqual( bool, true, 'returns true' ); - t.end(); -}); - -tape( 'the function returns `false` if not provided an array of probabilities that sum to one', function test( t ) { - var values; - var i; - - values = [ - '10', - '01', - '0.5', - '5', - 5, - NaN, - null, - void 0, - true, - [], - [ 5, null ], - [ 5, '5' ], - [ 1.0, 3.14 ], - [ -1.0, 1.0, 1.0 ], - [ 0.25, 0.33, 0.5 ], - new Float64Array( [ 0.25, 0.33, 0.5 ] ), - new Float64Array( [ 0.25, 1.33, 0.5 ] ), - new Float64Array( [ 0.25, -0.33, 0.5 ] ), - {}, - function noop() {}, - array2buffer( [ 1, 1, 0 ] ) - ]; - - for ( i = 0; i < values.length; i++ ) { - t.strictEqual( isUnityProbabilityArray( values[i] ), false, 'returns false when provided '+values[i] ); - } - t.end(); -}); From eeba4018b5699c50c4979d56c8cd39a78a8900a3 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 5 Oct 2023 17:24:38 +0000 Subject: [PATCH 062/133] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 9661d6f..bfff21b 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,8 @@ "@stdlib/assert-is-number": "^0.1.1", "@stdlib/assert-is-typed-array": "^0.1.0", "@stdlib/constants-float64-sqrt-eps": "^0.1.1", - "@stdlib/math-base-utils-absolute-difference": "^0.2.0" + "@stdlib/math-base-utils-absolute-difference": "^0.2.0", + "@stdlib/error-tools-fmtprodmsg": "^0.1.1" }, "devDependencies": { "@stdlib/array-float32": "^0.1.0", @@ -104,4 +105,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 009cad0a6ad9e077108f8cbceaca94bf576bebcc Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 6 Oct 2023 23:13:32 +0000 Subject: [PATCH 063/133] Remove files --- index.d.ts | 48 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6230 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index 63a123d..0000000 --- a/index.d.ts +++ /dev/null @@ -1,48 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/** -* Tests if a value is an array of probabilities that sum to one. -* -* @param v - value to test -* @returns boolean indicating if a value is a probability array -* -* @example -* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] ); -* // returns true -* -* @example -* var bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) ); -* // returns true -* -* @example -* var bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] ); -* // returns false -* -* @example -* var bool = isUnityProbabilityArray( [ 3.14, 0.0 ] ); -* // returns false -*/ -declare function isUnityProbabilityArray( v: any ): v is ArrayLike; - - -// EXPORTS // - -export = isUnityProbabilityArray; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index a2759d8..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-typed-array@v0.1.0-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array@v0.1.0-esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-number@v0.1.0-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/math-base-utils-absolute-difference@v0.2.0-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/constants-float64-sqrt-eps@v0.1.0-esm/index.mjs";function n(n){var d,m;if(t(n)){for(d=0,m=0;m1||n[m]<0)return!1;d+=n[m]}return r(d,1)<=i}if(s(n)){for(d=0,m=0;m1||n[m]<0)return!1;d+=n[m]}return r(d,1)<=i}return!1}export{n as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 08904b0..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isTypedArray from '@stdlib/assert-is-typed-array';\nimport isArray from '@stdlib/assert-is-array';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport absdiff from '@stdlib/math-base-utils-absolute-difference';\nimport FLOAT64_SQRT_EPS from '@stdlib/constants-float64-sqrt-eps';\n\n\n// MAIN //\n\n/**\n* Tests if a value is an array of probabilities that sum to one.\n*\n* @param {*} v - value to test\n* @returns {boolean} boolean indicating if a value is a probability array\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] );\n* // returns true\n*\n* @example\n* var bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) );\n* // returns true\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] );\n* // returns false\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 3.14, 0.0 ] );\n* // returns false\n*/\nfunction isUnityProbabilityArray( v ) {\n\tvar sum;\n\tvar i;\n\tif ( isArray( v ) ) {\n\t\tsum = 0.0;\n\t\tfor ( i = 0; i < v.length; i++ ) {\n\t\t\tif (\n\t\t\t\t!isNumber( v[ i ] ) ||\n\t\t\t\tv[ i ] > 1.0 ||\n\t\t\t\tv[ i ] < 0.0\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tsum += v[ i ];\n\t\t}\n\t\treturn ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS );\n\t}\n\tif ( isTypedArray( v ) ) {\n\t\tsum = 0.0;\n\t\tfor ( i = 0; i < v.length; i++ ) {\n\t\t\tif (\n\t\t\t\tv[ i ] > 1.0 ||\n\t\t\t\tv[ i ] < 0.0\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tsum += v[ i ];\n\t\t}\n\t\treturn ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS );\n\t}\n\treturn false;\n}\n\n\n// EXPORTS //\n\nexport default isUnityProbabilityArray;\n"],"names":["isUnityProbabilityArray","v","sum","i","isArray","length","isNumber","absdiff","FLOAT64_SQRT_EPS","isTypedArray"],"mappings":";;ufAqDA,SAASA,EAAyBC,GACjC,IAAIC,EACAC,EACJ,GAAKC,EAASH,GAAM,CAEnB,IADAC,EAAM,EACAC,EAAI,EAAGA,EAAIF,EAAEI,OAAQF,IAAM,CAChC,IACEG,EAAUL,EAAGE,KACdF,EAAGE,GAAM,GACTF,EAAGE,GAAM,EAET,OAAO,EAERD,GAAOD,EAAGE,EACV,CACD,OAASI,EAASL,EAAK,IAASM,CAChC,CACD,GAAKC,EAAcR,GAAM,CAExB,IADAC,EAAM,EACAC,EAAI,EAAGA,EAAIF,EAAEI,OAAQF,IAAM,CAChC,GACCF,EAAGE,GAAM,GACTF,EAAGE,GAAM,EAET,OAAO,EAERD,GAAOD,EAAGE,EACV,CACD,OAASI,EAASL,EAAK,IAASM,CAChC,CACD,OAAO,CACR"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index c8e375e..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 2177268feba846fb1a1d197a2b7938bd1b777ca2 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 6 Oct 2023 23:14:19 +0000 Subject: [PATCH 064/133] 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 | 41 +- benchmark/benchmark.js | 103 - branches.md | 53 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 29 - docs/types/test.ts | 34 - examples/index.js | 48 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 49 - lib/main.js | 90 - package.json | 70 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 106 - test/test.js | 106 - 41 files changed, 6202 insertions(+), 3883 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 delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/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 75a4c32..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/assert/is-unity-probability-array) 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 5119885..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/assert/is-unity-probability-array) 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 41d1b0b..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: '49 1 * * 1' - - # 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 + + ```
@@ -176,7 +169,7 @@ bool = isUnityProbabilityArray( null ); ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -240,9 +233,9 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. -[@stdlib/assert/is-probability]: https://github.com/stdlib-js/assert-is-probability +[@stdlib/assert/is-probability]: https://github.com/stdlib-js/assert-is-probability/tree/esm -[@stdlib/assert/is-probability-array]: https://github.com/stdlib-js/assert-is-probability-array +[@stdlib/assert/is-probability-array]: https://github.com/stdlib-js/assert-is-probability-array/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 1121550..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,103 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var isUnityProbabilityArray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x; - var i; - - x = []; - for ( i = 0; i < len; i++ ) { - x.push( 1.0/len ); - } - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: we are testing the worst case scenario where a function must scan the entire array before finding a failing value. - x[ len-1 ] = i * 3.14; - bool = isUnityProbabilityArray( x ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( isBoolean( bool ) ) { - b.pass( 'benchmark finished' ); - } else { - b.fail( 'should return a boolean' ); - } - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':len='+len, f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index d50fc89..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/assert/is-unity-probability-array" -%% click B href "https://github.com/stdlib-js/assert-is-unity-probability-array/tree/main" -%% click C href "https://github.com/stdlib-js/assert-is-unity-probability-array/tree/production" -%% click D href "https://github.com/stdlib-js/assert-is-unity-probability-array/tree/esm" -%% click E href "https://github.com/stdlib-js/assert-is-unity-probability-array/tree/deno" -%% click F href "https://github.com/stdlib-js/assert-is-unity-probability-array/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/assert/is-unity-probability-array -[production-url]: https://github.com/stdlib-js/assert-is-unity-probability-array/tree/production -[deno-url]: https://github.com/stdlib-js/assert-is-unity-probability-array/tree/deno -[umd-url]: https://github.com/stdlib-js/assert-is-unity-probability-array/tree/umd -[esm-url]: https://github.com/stdlib-js/assert-is-unity-probability-array/tree/esm \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index c77d01e..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import isUnityProbabilityArray from '../docs/types/index'; -export = isUnityProbabilityArray; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 70d7801..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var f=function(r,i){return function(){return i||r((i={exports:{}}).exports,i),i.exports}};var u=f(function(m,s){ -var n=require('@stdlib/assert-is-typed-array/dist'),l=require('@stdlib/assert-is-array/dist'),o=require('@stdlib/assert-is-number/dist').isPrimitive,a=require('@stdlib/math-base-utils-absolute-difference/dist'),t=require('@stdlib/constants-float64-sqrt-eps/dist');function q(r){var i,e;if(l(r)){for(i=0,e=0;e1||r[e]<0)return!1;i+=r[e]}return a(i,1)<=t}if(n(r)){for(i=0,e=0;e1||r[e]<0)return!1;i+=r[e]}return a(i,1)<=t}return!1}s.exports=q -});var y=u();module.exports=y; -/** @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 387d5ad..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) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isTypedArray = require( '@stdlib/assert-is-typed-array' );\nvar isArray = require( '@stdlib/assert-is-array' );\nvar isNumber = require( '@stdlib/assert-is-number' ).isPrimitive;\nvar absdiff = require( '@stdlib/math-base-utils-absolute-difference' );\nvar FLOAT64_SQRT_EPS = require( '@stdlib/constants-float64-sqrt-eps' );\n\n\n// MAIN //\n\n/**\n* Tests if a value is an array of probabilities that sum to one.\n*\n* @param {*} v - value to test\n* @returns {boolean} boolean indicating if a value is a probability array\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] );\n* // returns true\n*\n* @example\n* var bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) );\n* // returns true\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] );\n* // returns false\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 3.14, 0.0 ] );\n* // returns false\n*/\nfunction isUnityProbabilityArray( v ) {\n\tvar sum;\n\tvar i;\n\tif ( isArray( v ) ) {\n\t\tsum = 0.0;\n\t\tfor ( i = 0; i < v.length; i++ ) {\n\t\t\tif (\n\t\t\t\t!isNumber( v[ i ] ) ||\n\t\t\t\tv[ i ] > 1.0 ||\n\t\t\t\tv[ i ] < 0.0\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tsum += v[ i ];\n\t\t}\n\t\treturn ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS );\n\t}\n\tif ( isTypedArray( v ) ) {\n\t\tsum = 0.0;\n\t\tfor ( i = 0; i < v.length; i++ ) {\n\t\t\tif (\n\t\t\t\tv[ i ] > 1.0 ||\n\t\t\t\tv[ i ] < 0.0\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tsum += v[ i ];\n\t\t}\n\t\treturn ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS );\n\t}\n\treturn false;\n}\n\n\n// EXPORTS //\n\nmodule.exports = isUnityProbabilityArray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Test if a value is an array of probabilities that sum to one.\n*\n* @module @stdlib/assert-is-unity-probability-array\n*\n* @example\n* var isUnityProbabilityArray = require( '@stdlib/assert-is-unity-probability-array' );\n*\n* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] );\n* // returns true\n*\n* bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) );\n* // returns true\n*\n* bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] );\n* // returns false\n*\n* bool = isUnityProbabilityArray( [ 3.14, 0.0 ] );\n* // returns false\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,EAAe,QAAS,+BAAgC,EACxDC,EAAU,QAAS,yBAA0B,EAC7CC,EAAW,QAAS,0BAA2B,EAAE,YACjDC,EAAU,QAAS,6CAA8C,EACjEC,EAAmB,QAAS,oCAAqC,EA2BrE,SAASC,EAAyBC,EAAI,CACrC,IAAIC,EACAC,EACJ,GAAKP,EAASK,CAAE,EAAI,CAEnB,IADAC,EAAM,EACAC,EAAI,EAAGA,EAAIF,EAAE,OAAQE,IAAM,CAChC,GACC,CAACN,EAAUI,EAAGE,CAAE,CAAE,GAClBF,EAAGE,CAAE,EAAI,GACTF,EAAGE,CAAE,EAAI,EAET,MAAO,GAERD,GAAOD,EAAGE,CAAE,CACb,CACA,OAASL,EAASI,EAAK,CAAI,GAAKH,CACjC,CACA,GAAKJ,EAAcM,CAAE,EAAI,CAExB,IADAC,EAAM,EACAC,EAAI,EAAGA,EAAIF,EAAE,OAAQE,IAAM,CAChC,GACCF,EAAGE,CAAE,EAAI,GACTF,EAAGE,CAAE,EAAI,EAET,MAAO,GAERD,GAAOD,EAAGE,CAAE,CACb,CACA,OAASL,EAASI,EAAK,CAAI,GAAKH,CACjC,CACA,MAAO,EACR,CAKAL,EAAO,QAAUM,IC9CjB,IAAII,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isTypedArray", "isArray", "isNumber", "absdiff", "FLOAT64_SQRT_EPS", "isUnityProbabilityArray", "v", "sum", "i", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index a2414be..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,29 +0,0 @@ - -{{alias}}( value ) - Tests if a value is an array of probabilities that sum to one. - - Parameters - ---------- - value: any - Value to test. - - Returns - ------- - bool: boolean - Boolean indicating whether value is an array of probabilities that sum - to one. - - Examples - -------- - > var bool = {{alias}}( [ 0.25, 0.5, 0.25 ] ) - true - > bool = {{alias}}( new {{alias:@stdlib/array/uint8}}( [ 0, 1 ] ) ) - true - > bool = {{alias}}( [ 0.4, 0.4, 0.4 ] ) - false - > bool = {{alias}}( [ 3.14, 0.0 ] ) - false - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 6b41658..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,34 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import isUnityProbabilityArray = require( './index' ); - - -// TESTS // - -// The function returns a boolean... -{ - isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] ); // $ExpectType boolean - isUnityProbabilityArray( [ 2, 3 ] ); // $ExpectType boolean -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - isUnityProbabilityArray(); // $ExpectError - isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ], 123 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index b0b6bbc..0000000 --- a/examples/index.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var Uint8Array = require( '@stdlib/array-uint8' ); -var isUnityProbabilityArray = require( './../lib' ); - -var arr = [ 0.0, 1.0 ]; -console.log( isUnityProbabilityArray( arr ) ); -// => true - -arr = [ 0.5, 0.25, 0.25 ]; -console.log( isUnityProbabilityArray( arr ) ); -// => true - -arr = new Uint8Array( [ 0, 0, 1, 0 ] ); -console.log( isUnityProbabilityArray( arr ) ); -// => true - -arr = [ 0.4, 0.4, 0.4 ]; -console.log( isUnityProbabilityArray( arr ) ); -// => false - -arr = [ 3.14, -1.0 ]; -console.log( isUnityProbabilityArray( arr ) ); -// => false - -console.log( isUnityProbabilityArray( [] ) ); -// => false - -console.log( isUnityProbabilityArray( null ) ); -// => false diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..bc83655 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-typed-array@v0.1.0-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array@v0.1.1-esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-number@v0.1.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/math-base-utils-absolute-difference@v0.2.0-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/constants-float64-sqrt-eps@v0.1.1-esm/index.mjs";function n(n){var d,m;if(t(n)){for(d=0,m=0;m1||n[m]<0)return!1;d+=n[m]}return r(d,1)<=i}if(s(n)){for(d=0,m=0;m1||n[m]<0)return!1;d+=n[m]}return r(d,1)<=i}return!1}export{n as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..08904b0 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isTypedArray from '@stdlib/assert-is-typed-array';\nimport isArray from '@stdlib/assert-is-array';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport absdiff from '@stdlib/math-base-utils-absolute-difference';\nimport FLOAT64_SQRT_EPS from '@stdlib/constants-float64-sqrt-eps';\n\n\n// MAIN //\n\n/**\n* Tests if a value is an array of probabilities that sum to one.\n*\n* @param {*} v - value to test\n* @returns {boolean} boolean indicating if a value is a probability array\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] );\n* // returns true\n*\n* @example\n* var bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) );\n* // returns true\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] );\n* // returns false\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 3.14, 0.0 ] );\n* // returns false\n*/\nfunction isUnityProbabilityArray( v ) {\n\tvar sum;\n\tvar i;\n\tif ( isArray( v ) ) {\n\t\tsum = 0.0;\n\t\tfor ( i = 0; i < v.length; i++ ) {\n\t\t\tif (\n\t\t\t\t!isNumber( v[ i ] ) ||\n\t\t\t\tv[ i ] > 1.0 ||\n\t\t\t\tv[ i ] < 0.0\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tsum += v[ i ];\n\t\t}\n\t\treturn ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS );\n\t}\n\tif ( isTypedArray( v ) ) {\n\t\tsum = 0.0;\n\t\tfor ( i = 0; i < v.length; i++ ) {\n\t\t\tif (\n\t\t\t\tv[ i ] > 1.0 ||\n\t\t\t\tv[ i ] < 0.0\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tsum += v[ i ];\n\t\t}\n\t\treturn ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS );\n\t}\n\treturn false;\n}\n\n\n// EXPORTS //\n\nexport default isUnityProbabilityArray;\n"],"names":["isUnityProbabilityArray","v","sum","i","isArray","length","isNumber","absdiff","FLOAT64_SQRT_EPS","isTypedArray"],"mappings":";;ufAqDA,SAASA,EAAyBC,GACjC,IAAIC,EACAC,EACJ,GAAKC,EAASH,GAAM,CAEnB,IADAC,EAAM,EACAC,EAAI,EAAGA,EAAIF,EAAEI,OAAQF,IAAM,CAChC,IACEG,EAAUL,EAAGE,KACdF,EAAGE,GAAM,GACTF,EAAGE,GAAM,EAET,OAAO,EAERD,GAAOD,EAAGE,EACV,CACD,OAASI,EAASL,EAAK,IAASM,CAChC,CACD,GAAKC,EAAcR,GAAM,CAExB,IADAC,EAAM,EACAC,EAAI,EAAGA,EAAIF,EAAEI,OAAQF,IAAM,CAChC,GACCF,EAAGE,GAAM,GACTF,EAAGE,GAAM,EAET,OAAO,EAERD,GAAOD,EAAGE,EACV,CACD,OAASI,EAASL,EAAK,IAASM,CAChC,CACD,OAAO,CACR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 13a67d1..0000000 --- a/lib/index.js +++ /dev/null @@ -1,49 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Test if a value is an array of probabilities that sum to one. -* -* @module @stdlib/assert-is-unity-probability-array -* -* @example -* var isUnityProbabilityArray = require( '@stdlib/assert-is-unity-probability-array' ); -* -* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] ); -* // returns true -* -* bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) ); -* // returns true -* -* bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] ); -* // returns false -* -* bool = isUnityProbabilityArray( [ 3.14, 0.0 ] ); -* // returns false -*/ - -// 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 d0bda40..0000000 --- a/lib/main.js +++ /dev/null @@ -1,90 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -var isArray = require( '@stdlib/assert-is-array' ); -var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var absdiff = require( '@stdlib/math-base-utils-absolute-difference' ); -var FLOAT64_SQRT_EPS = require( '@stdlib/constants-float64-sqrt-eps' ); - - -// MAIN // - -/** -* Tests if a value is an array of probabilities that sum to one. -* -* @param {*} v - value to test -* @returns {boolean} boolean indicating if a value is a probability array -* -* @example -* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] ); -* // returns true -* -* @example -* var bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) ); -* // returns true -* -* @example -* var bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] ); -* // returns false -* -* @example -* var bool = isUnityProbabilityArray( [ 3.14, 0.0 ] ); -* // returns false -*/ -function isUnityProbabilityArray( v ) { - var sum; - var i; - if ( isArray( v ) ) { - sum = 0.0; - for ( i = 0; i < v.length; i++ ) { - if ( - !isNumber( v[ i ] ) || - v[ i ] > 1.0 || - v[ i ] < 0.0 - ) { - return false; - } - sum += v[ i ]; - } - return ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS ); - } - if ( isTypedArray( v ) ) { - sum = 0.0; - for ( i = 0; i < v.length; i++ ) { - if ( - v[ i ] > 1.0 || - v[ i ] < 0.0 - ) { - return false; - } - sum += v[ i ]; - } - return ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS ); - } - return false; -} - - -// EXPORTS // - -module.exports = isUnityProbabilityArray; diff --git a/package.json b/package.json index bfff21b..660ccd4 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.0", "description": "Test if a value is an array of probabilities that sum to one.", "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" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,47 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-array": "^0.1.1", - "@stdlib/assert-is-number": "^0.1.1", - "@stdlib/assert-is-typed-array": "^0.1.0", - "@stdlib/constants-float64-sqrt-eps": "^0.1.1", - "@stdlib/math-base-utils-absolute-difference": "^0.2.0", - "@stdlib/error-tools-fmtprodmsg": "^0.1.1" - }, - "devDependencies": { - "@stdlib/array-float32": "^0.1.0", - "@stdlib/array-float64": "^0.1.0", - "@stdlib/array-int16": "^0.1.0", - "@stdlib/array-int32": "^0.1.0", - "@stdlib/array-int8": "^0.1.0", - "@stdlib/array-uint16": "^0.1.0", - "@stdlib/array-uint32": "^0.1.0", - "@stdlib/array-uint8": "^0.1.0", - "@stdlib/array-uint8c": "^0.1.0", - "@stdlib/assert-is-boolean": "^0.1.1", - "@stdlib/bench": "^0.1.0", - "@stdlib/buffer-from-array": "^0.1.0", - "@stdlib/math-base-special-pow": "^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", "stdassert", @@ -105,4 +41,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..929512e --- /dev/null +++ b/stats.html @@ -0,0 +1,6177 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index 122d26d..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,106 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Int8Array = require( '@stdlib/array-int8' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Float64Array = require( '@stdlib/array-float64' ); -var array2buffer = require( '@stdlib/buffer-from-array' ); -var isUnityProbabilityArray = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof isUnityProbabilityArray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns `true` if provided an array of probabilities that sum to one', function test( t ) { - var values; - var i; - - values = [ - new Int8Array( [ 0, 0, 1 ] ), - new Uint8Array( [ 1, 0, 0 ] ), - new Uint8ClampedArray( [ 0, 1 ] ), - new Int16Array( [ 0, 0, 1, 0 ] ), - new Uint16Array( [ 1 ] ), - new Int32Array( [ 1, 0, 0 ] ), - new Uint32Array( [ 0, 1, 0 ] ), - new Float32Array( [ 0.0, 0.5, 0.5 ] ), - new Float64Array( [ 0.25, 0.25, 0.5 ] ), - [ 0.5, 0.25, 0.25 ] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.strictEqual( isUnityProbabilityArray( values[i] ), true, 'returns true when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function allows a difference in sum within floating-point epsilon', function test( t ) { - var bool = isUnityProbabilityArray( [ 0.1, 0.2, 0.1, 0.1, 0.2, 0.2, 0.1 ] ); - t.strictEqual( bool, true, 'returns true' ); - t.end(); -}); - -tape( 'the function returns `false` if not provided an array of probabilities that sum to one', function test( t ) { - var values; - var i; - - values = [ - '10', - '01', - '0.5', - '5', - 5, - NaN, - null, - void 0, - true, - [], - [ 5, null ], - [ 5, '5' ], - [ 1.0, 3.14 ], - [ -1.0, 1.0, 1.0 ], - [ 0.25, 0.33, 0.5 ], - new Float64Array( [ 0.25, 0.33, 0.5 ] ), - new Float64Array( [ 0.25, 1.33, 0.5 ] ), - new Float64Array( [ 0.25, -0.33, 0.5 ] ), - {}, - function noop() {}, - array2buffer( [ 1, 1, 0 ] ) - ]; - - for ( i = 0; i < values.length; i++ ) { - t.strictEqual( isUnityProbabilityArray( values[i] ), false, 'returns false when provided '+values[i] ); - } - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index a0424fb..0000000 --- a/test/test.js +++ /dev/null @@ -1,106 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Int8Array = require( '@stdlib/array-int8' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Float64Array = require( '@stdlib/array-float64' ); -var array2buffer = require( '@stdlib/buffer-from-array' ); -var isUnityProbabilityArray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof isUnityProbabilityArray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns `true` if provided an array of probabilities that sum to one', function test( t ) { - var values; - var i; - - values = [ - new Int8Array( [ 0, 0, 1 ] ), - new Uint8Array( [ 1, 0, 0 ] ), - new Uint8ClampedArray( [ 0, 1 ] ), - new Int16Array( [ 0, 0, 1, 0 ] ), - new Uint16Array( [ 1 ] ), - new Int32Array( [ 1, 0, 0 ] ), - new Uint32Array( [ 0, 1, 0 ] ), - new Float32Array( [ 0.0, 0.5, 0.5 ] ), - new Float64Array( [ 0.25, 0.25, 0.5 ] ), - [ 0.5, 0.25, 0.25 ] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.strictEqual( isUnityProbabilityArray( values[i] ), true, 'returns true when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function allows a difference in sum within floating-point epsilon', function test( t ) { - var bool = isUnityProbabilityArray( [ 0.1, 0.2, 0.1, 0.1, 0.2, 0.2, 0.1 ] ); - t.strictEqual( bool, true, 'returns true' ); - t.end(); -}); - -tape( 'the function returns `false` if not provided an array of probabilities that sum to one', function test( t ) { - var values; - var i; - - values = [ - '10', - '01', - '0.5', - '5', - 5, - NaN, - null, - void 0, - true, - [], - [ 5, null ], - [ 5, '5' ], - [ 1.0, 3.14 ], - [ -1.0, 1.0, 1.0 ], - [ 0.25, 0.33, 0.5 ], - new Float64Array( [ 0.25, 0.33, 0.5 ] ), - new Float64Array( [ 0.25, 1.33, 0.5 ] ), - new Float64Array( [ 0.25, -0.33, 0.5 ] ), - {}, - function noop() {}, - array2buffer( [ 1, 1, 0 ] ) - ]; - - for ( i = 0; i < values.length; i++ ) { - t.strictEqual( isUnityProbabilityArray( values[i] ), false, 'returns false when provided '+values[i] ); - } - t.end(); -}); From 93d308d386c36e562cb684939d7a8d681ac67e33 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 1 Nov 2023 14:52:54 +0000 Subject: [PATCH 065/133] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 64f807c..4ff0c80 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,8 @@ "@stdlib/assert-is-number": "^0.1.1", "@stdlib/assert-is-typed-array": "^0.1.0", "@stdlib/constants-float64-sqrt-eps": "^0.1.1", - "@stdlib/math-base-utils-absolute-difference": "^0.2.0" + "@stdlib/math-base-utils-absolute-difference": "^0.2.0", + "@stdlib/error-tools-fmtprodmsg": "^0.1.1" }, "devDependencies": { "@stdlib/array-float32": "^0.1.1", @@ -104,4 +105,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 64c0d2db950e295c53933a24e5cb40bf654098be Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 2 Nov 2023 22:07:06 +0000 Subject: [PATCH 066/133] Remove files --- index.d.ts | 48 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6230 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index 63a123d..0000000 --- a/index.d.ts +++ /dev/null @@ -1,48 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/** -* Tests if a value is an array of probabilities that sum to one. -* -* @param v - value to test -* @returns boolean indicating if a value is a probability array -* -* @example -* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] ); -* // returns true -* -* @example -* var bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) ); -* // returns true -* -* @example -* var bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] ); -* // returns false -* -* @example -* var bool = isUnityProbabilityArray( [ 3.14, 0.0 ] ); -* // returns false -*/ -declare function isUnityProbabilityArray( v: any ): v is ArrayLike; - - -// EXPORTS // - -export = isUnityProbabilityArray; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index bc83655..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-typed-array@v0.1.0-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array@v0.1.1-esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-number@v0.1.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/math-base-utils-absolute-difference@v0.2.0-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/constants-float64-sqrt-eps@v0.1.1-esm/index.mjs";function n(n){var d,m;if(t(n)){for(d=0,m=0;m1||n[m]<0)return!1;d+=n[m]}return r(d,1)<=i}if(s(n)){for(d=0,m=0;m1||n[m]<0)return!1;d+=n[m]}return r(d,1)<=i}return!1}export{n as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 08904b0..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isTypedArray from '@stdlib/assert-is-typed-array';\nimport isArray from '@stdlib/assert-is-array';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport absdiff from '@stdlib/math-base-utils-absolute-difference';\nimport FLOAT64_SQRT_EPS from '@stdlib/constants-float64-sqrt-eps';\n\n\n// MAIN //\n\n/**\n* Tests if a value is an array of probabilities that sum to one.\n*\n* @param {*} v - value to test\n* @returns {boolean} boolean indicating if a value is a probability array\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] );\n* // returns true\n*\n* @example\n* var bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) );\n* // returns true\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] );\n* // returns false\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 3.14, 0.0 ] );\n* // returns false\n*/\nfunction isUnityProbabilityArray( v ) {\n\tvar sum;\n\tvar i;\n\tif ( isArray( v ) ) {\n\t\tsum = 0.0;\n\t\tfor ( i = 0; i < v.length; i++ ) {\n\t\t\tif (\n\t\t\t\t!isNumber( v[ i ] ) ||\n\t\t\t\tv[ i ] > 1.0 ||\n\t\t\t\tv[ i ] < 0.0\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tsum += v[ i ];\n\t\t}\n\t\treturn ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS );\n\t}\n\tif ( isTypedArray( v ) ) {\n\t\tsum = 0.0;\n\t\tfor ( i = 0; i < v.length; i++ ) {\n\t\t\tif (\n\t\t\t\tv[ i ] > 1.0 ||\n\t\t\t\tv[ i ] < 0.0\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tsum += v[ i ];\n\t\t}\n\t\treturn ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS );\n\t}\n\treturn false;\n}\n\n\n// EXPORTS //\n\nexport default isUnityProbabilityArray;\n"],"names":["isUnityProbabilityArray","v","sum","i","isArray","length","isNumber","absdiff","FLOAT64_SQRT_EPS","isTypedArray"],"mappings":";;ufAqDA,SAASA,EAAyBC,GACjC,IAAIC,EACAC,EACJ,GAAKC,EAASH,GAAM,CAEnB,IADAC,EAAM,EACAC,EAAI,EAAGA,EAAIF,EAAEI,OAAQF,IAAM,CAChC,IACEG,EAAUL,EAAGE,KACdF,EAAGE,GAAM,GACTF,EAAGE,GAAM,EAET,OAAO,EAERD,GAAOD,EAAGE,EACV,CACD,OAASI,EAASL,EAAK,IAASM,CAChC,CACD,GAAKC,EAAcR,GAAM,CAExB,IADAC,EAAM,EACAC,EAAI,EAAGA,EAAIF,EAAEI,OAAQF,IAAM,CAChC,GACCF,EAAGE,GAAM,GACTF,EAAGE,GAAM,EAET,OAAO,EAERD,GAAOD,EAAGE,EACV,CACD,OAASI,EAASL,EAAK,IAASM,CAChC,CACD,OAAO,CACR"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 929512e..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 51dac09e9d466e4ed9636823d70c790adb279986 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 2 Nov 2023 22:07:58 +0000 Subject: [PATCH 067/133] 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 | 41 +- benchmark/benchmark.js | 103 - branches.md | 53 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 29 - docs/types/test.ts | 34 - examples/index.js | 48 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 49 - lib/main.js | 90 - package.json | 70 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 106 - 42 files changed, 6202 insertions(+), 3819 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 delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/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 bf44645..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-11-01T04:29:43.407Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 75a4c32..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/assert/is-unity-probability-array) 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 5119885..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/assert/is-unity-probability-array) 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 41d1b0b..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: '49 1 * * 1' - - # 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 + + ```
@@ -176,7 +169,7 @@ bool = isUnityProbabilityArray( null ); ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -240,9 +233,9 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. -[@stdlib/assert/is-probability]: https://github.com/stdlib-js/assert-is-probability +[@stdlib/assert/is-probability]: https://github.com/stdlib-js/assert-is-probability/tree/esm -[@stdlib/assert/is-probability-array]: https://github.com/stdlib-js/assert-is-probability-array +[@stdlib/assert/is-probability-array]: https://github.com/stdlib-js/assert-is-probability-array/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 1121550..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,103 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var isUnityProbabilityArray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x; - var i; - - x = []; - for ( i = 0; i < len; i++ ) { - x.push( 1.0/len ); - } - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: we are testing the worst case scenario where a function must scan the entire array before finding a failing value. - x[ len-1 ] = i * 3.14; - bool = isUnityProbabilityArray( x ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( isBoolean( bool ) ) { - b.pass( 'benchmark finished' ); - } else { - b.fail( 'should return a boolean' ); - } - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':len='+len, f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index d50fc89..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/assert/is-unity-probability-array" -%% click B href "https://github.com/stdlib-js/assert-is-unity-probability-array/tree/main" -%% click C href "https://github.com/stdlib-js/assert-is-unity-probability-array/tree/production" -%% click D href "https://github.com/stdlib-js/assert-is-unity-probability-array/tree/esm" -%% click E href "https://github.com/stdlib-js/assert-is-unity-probability-array/tree/deno" -%% click F href "https://github.com/stdlib-js/assert-is-unity-probability-array/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/assert/is-unity-probability-array -[production-url]: https://github.com/stdlib-js/assert-is-unity-probability-array/tree/production -[deno-url]: https://github.com/stdlib-js/assert-is-unity-probability-array/tree/deno -[umd-url]: https://github.com/stdlib-js/assert-is-unity-probability-array/tree/umd -[esm-url]: https://github.com/stdlib-js/assert-is-unity-probability-array/tree/esm \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index c77d01e..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import isUnityProbabilityArray from '../docs/types/index'; -export = isUnityProbabilityArray; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 70d7801..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var f=function(r,i){return function(){return i||r((i={exports:{}}).exports,i),i.exports}};var u=f(function(m,s){ -var n=require('@stdlib/assert-is-typed-array/dist'),l=require('@stdlib/assert-is-array/dist'),o=require('@stdlib/assert-is-number/dist').isPrimitive,a=require('@stdlib/math-base-utils-absolute-difference/dist'),t=require('@stdlib/constants-float64-sqrt-eps/dist');function q(r){var i,e;if(l(r)){for(i=0,e=0;e1||r[e]<0)return!1;i+=r[e]}return a(i,1)<=t}if(n(r)){for(i=0,e=0;e1||r[e]<0)return!1;i+=r[e]}return a(i,1)<=t}return!1}s.exports=q -});var y=u();module.exports=y; -/** @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 387d5ad..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) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isTypedArray = require( '@stdlib/assert-is-typed-array' );\nvar isArray = require( '@stdlib/assert-is-array' );\nvar isNumber = require( '@stdlib/assert-is-number' ).isPrimitive;\nvar absdiff = require( '@stdlib/math-base-utils-absolute-difference' );\nvar FLOAT64_SQRT_EPS = require( '@stdlib/constants-float64-sqrt-eps' );\n\n\n// MAIN //\n\n/**\n* Tests if a value is an array of probabilities that sum to one.\n*\n* @param {*} v - value to test\n* @returns {boolean} boolean indicating if a value is a probability array\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] );\n* // returns true\n*\n* @example\n* var bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) );\n* // returns true\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] );\n* // returns false\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 3.14, 0.0 ] );\n* // returns false\n*/\nfunction isUnityProbabilityArray( v ) {\n\tvar sum;\n\tvar i;\n\tif ( isArray( v ) ) {\n\t\tsum = 0.0;\n\t\tfor ( i = 0; i < v.length; i++ ) {\n\t\t\tif (\n\t\t\t\t!isNumber( v[ i ] ) ||\n\t\t\t\tv[ i ] > 1.0 ||\n\t\t\t\tv[ i ] < 0.0\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tsum += v[ i ];\n\t\t}\n\t\treturn ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS );\n\t}\n\tif ( isTypedArray( v ) ) {\n\t\tsum = 0.0;\n\t\tfor ( i = 0; i < v.length; i++ ) {\n\t\t\tif (\n\t\t\t\tv[ i ] > 1.0 ||\n\t\t\t\tv[ i ] < 0.0\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tsum += v[ i ];\n\t\t}\n\t\treturn ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS );\n\t}\n\treturn false;\n}\n\n\n// EXPORTS //\n\nmodule.exports = isUnityProbabilityArray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Test if a value is an array of probabilities that sum to one.\n*\n* @module @stdlib/assert-is-unity-probability-array\n*\n* @example\n* var isUnityProbabilityArray = require( '@stdlib/assert-is-unity-probability-array' );\n*\n* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] );\n* // returns true\n*\n* bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) );\n* // returns true\n*\n* bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] );\n* // returns false\n*\n* bool = isUnityProbabilityArray( [ 3.14, 0.0 ] );\n* // returns false\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,EAAe,QAAS,+BAAgC,EACxDC,EAAU,QAAS,yBAA0B,EAC7CC,EAAW,QAAS,0BAA2B,EAAE,YACjDC,EAAU,QAAS,6CAA8C,EACjEC,EAAmB,QAAS,oCAAqC,EA2BrE,SAASC,EAAyBC,EAAI,CACrC,IAAIC,EACAC,EACJ,GAAKP,EAASK,CAAE,EAAI,CAEnB,IADAC,EAAM,EACAC,EAAI,EAAGA,EAAIF,EAAE,OAAQE,IAAM,CAChC,GACC,CAACN,EAAUI,EAAGE,CAAE,CAAE,GAClBF,EAAGE,CAAE,EAAI,GACTF,EAAGE,CAAE,EAAI,EAET,MAAO,GAERD,GAAOD,EAAGE,CAAE,CACb,CACA,OAASL,EAASI,EAAK,CAAI,GAAKH,CACjC,CACA,GAAKJ,EAAcM,CAAE,EAAI,CAExB,IADAC,EAAM,EACAC,EAAI,EAAGA,EAAIF,EAAE,OAAQE,IAAM,CAChC,GACCF,EAAGE,CAAE,EAAI,GACTF,EAAGE,CAAE,EAAI,EAET,MAAO,GAERD,GAAOD,EAAGE,CAAE,CACb,CACA,OAASL,EAASI,EAAK,CAAI,GAAKH,CACjC,CACA,MAAO,EACR,CAKAL,EAAO,QAAUM,IC9CjB,IAAII,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isTypedArray", "isArray", "isNumber", "absdiff", "FLOAT64_SQRT_EPS", "isUnityProbabilityArray", "v", "sum", "i", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index a2414be..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,29 +0,0 @@ - -{{alias}}( value ) - Tests if a value is an array of probabilities that sum to one. - - Parameters - ---------- - value: any - Value to test. - - Returns - ------- - bool: boolean - Boolean indicating whether value is an array of probabilities that sum - to one. - - Examples - -------- - > var bool = {{alias}}( [ 0.25, 0.5, 0.25 ] ) - true - > bool = {{alias}}( new {{alias:@stdlib/array/uint8}}( [ 0, 1 ] ) ) - true - > bool = {{alias}}( [ 0.4, 0.4, 0.4 ] ) - false - > bool = {{alias}}( [ 3.14, 0.0 ] ) - false - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 6b41658..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,34 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import isUnityProbabilityArray = require( './index' ); - - -// TESTS // - -// The function returns a boolean... -{ - isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] ); // $ExpectType boolean - isUnityProbabilityArray( [ 2, 3 ] ); // $ExpectType boolean -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - isUnityProbabilityArray(); // $ExpectError - isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ], 123 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index b0b6bbc..0000000 --- a/examples/index.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var Uint8Array = require( '@stdlib/array-uint8' ); -var isUnityProbabilityArray = require( './../lib' ); - -var arr = [ 0.0, 1.0 ]; -console.log( isUnityProbabilityArray( arr ) ); -// => true - -arr = [ 0.5, 0.25, 0.25 ]; -console.log( isUnityProbabilityArray( arr ) ); -// => true - -arr = new Uint8Array( [ 0, 0, 1, 0 ] ); -console.log( isUnityProbabilityArray( arr ) ); -// => true - -arr = [ 0.4, 0.4, 0.4 ]; -console.log( isUnityProbabilityArray( arr ) ); -// => false - -arr = [ 3.14, -1.0 ]; -console.log( isUnityProbabilityArray( arr ) ); -// => false - -console.log( isUnityProbabilityArray( [] ) ); -// => false - -console.log( isUnityProbabilityArray( null ) ); -// => false diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..bc83655 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-typed-array@v0.1.0-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array@v0.1.1-esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-number@v0.1.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/math-base-utils-absolute-difference@v0.2.0-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/constants-float64-sqrt-eps@v0.1.1-esm/index.mjs";function n(n){var d,m;if(t(n)){for(d=0,m=0;m1||n[m]<0)return!1;d+=n[m]}return r(d,1)<=i}if(s(n)){for(d=0,m=0;m1||n[m]<0)return!1;d+=n[m]}return r(d,1)<=i}return!1}export{n as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..08904b0 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isTypedArray from '@stdlib/assert-is-typed-array';\nimport isArray from '@stdlib/assert-is-array';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport absdiff from '@stdlib/math-base-utils-absolute-difference';\nimport FLOAT64_SQRT_EPS from '@stdlib/constants-float64-sqrt-eps';\n\n\n// MAIN //\n\n/**\n* Tests if a value is an array of probabilities that sum to one.\n*\n* @param {*} v - value to test\n* @returns {boolean} boolean indicating if a value is a probability array\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] );\n* // returns true\n*\n* @example\n* var bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) );\n* // returns true\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] );\n* // returns false\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 3.14, 0.0 ] );\n* // returns false\n*/\nfunction isUnityProbabilityArray( v ) {\n\tvar sum;\n\tvar i;\n\tif ( isArray( v ) ) {\n\t\tsum = 0.0;\n\t\tfor ( i = 0; i < v.length; i++ ) {\n\t\t\tif (\n\t\t\t\t!isNumber( v[ i ] ) ||\n\t\t\t\tv[ i ] > 1.0 ||\n\t\t\t\tv[ i ] < 0.0\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tsum += v[ i ];\n\t\t}\n\t\treturn ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS );\n\t}\n\tif ( isTypedArray( v ) ) {\n\t\tsum = 0.0;\n\t\tfor ( i = 0; i < v.length; i++ ) {\n\t\t\tif (\n\t\t\t\tv[ i ] > 1.0 ||\n\t\t\t\tv[ i ] < 0.0\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tsum += v[ i ];\n\t\t}\n\t\treturn ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS );\n\t}\n\treturn false;\n}\n\n\n// EXPORTS //\n\nexport default isUnityProbabilityArray;\n"],"names":["isUnityProbabilityArray","v","sum","i","isArray","length","isNumber","absdiff","FLOAT64_SQRT_EPS","isTypedArray"],"mappings":";;ufAqDA,SAASA,EAAyBC,GACjC,IAAIC,EACAC,EACJ,GAAKC,EAASH,GAAM,CAEnB,IADAC,EAAM,EACAC,EAAI,EAAGA,EAAIF,EAAEI,OAAQF,IAAM,CAChC,IACEG,EAAUL,EAAGE,KACdF,EAAGE,GAAM,GACTF,EAAGE,GAAM,EAET,OAAO,EAERD,GAAOD,EAAGE,EACV,CACD,OAASI,EAASL,EAAK,IAASM,CAChC,CACD,GAAKC,EAAcR,GAAM,CAExB,IADAC,EAAM,EACAC,EAAI,EAAGA,EAAIF,EAAEI,OAAQF,IAAM,CAChC,GACCF,EAAGE,GAAM,GACTF,EAAGE,GAAM,EAET,OAAO,EAERD,GAAOD,EAAGE,EACV,CACD,OAASI,EAASL,EAAK,IAASM,CAChC,CACD,OAAO,CACR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 13a67d1..0000000 --- a/lib/index.js +++ /dev/null @@ -1,49 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Test if a value is an array of probabilities that sum to one. -* -* @module @stdlib/assert-is-unity-probability-array -* -* @example -* var isUnityProbabilityArray = require( '@stdlib/assert-is-unity-probability-array' ); -* -* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] ); -* // returns true -* -* bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) ); -* // returns true -* -* bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] ); -* // returns false -* -* bool = isUnityProbabilityArray( [ 3.14, 0.0 ] ); -* // returns false -*/ - -// 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 d0bda40..0000000 --- a/lib/main.js +++ /dev/null @@ -1,90 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -var isArray = require( '@stdlib/assert-is-array' ); -var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var absdiff = require( '@stdlib/math-base-utils-absolute-difference' ); -var FLOAT64_SQRT_EPS = require( '@stdlib/constants-float64-sqrt-eps' ); - - -// MAIN // - -/** -* Tests if a value is an array of probabilities that sum to one. -* -* @param {*} v - value to test -* @returns {boolean} boolean indicating if a value is a probability array -* -* @example -* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] ); -* // returns true -* -* @example -* var bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) ); -* // returns true -* -* @example -* var bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] ); -* // returns false -* -* @example -* var bool = isUnityProbabilityArray( [ 3.14, 0.0 ] ); -* // returns false -*/ -function isUnityProbabilityArray( v ) { - var sum; - var i; - if ( isArray( v ) ) { - sum = 0.0; - for ( i = 0; i < v.length; i++ ) { - if ( - !isNumber( v[ i ] ) || - v[ i ] > 1.0 || - v[ i ] < 0.0 - ) { - return false; - } - sum += v[ i ]; - } - return ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS ); - } - if ( isTypedArray( v ) ) { - sum = 0.0; - for ( i = 0; i < v.length; i++ ) { - if ( - v[ i ] > 1.0 || - v[ i ] < 0.0 - ) { - return false; - } - sum += v[ i ]; - } - return ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS ); - } - return false; -} - - -// EXPORTS // - -module.exports = isUnityProbabilityArray; diff --git a/package.json b/package.json index 4ff0c80..660ccd4 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.0", "description": "Test if a value is an array of probabilities that sum to one.", "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" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,47 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-array": "^0.1.1", - "@stdlib/assert-is-number": "^0.1.1", - "@stdlib/assert-is-typed-array": "^0.1.0", - "@stdlib/constants-float64-sqrt-eps": "^0.1.1", - "@stdlib/math-base-utils-absolute-difference": "^0.2.0", - "@stdlib/error-tools-fmtprodmsg": "^0.1.1" - }, - "devDependencies": { - "@stdlib/array-float32": "^0.1.1", - "@stdlib/array-float64": "^0.1.1", - "@stdlib/array-int16": "^0.1.1", - "@stdlib/array-int32": "^0.1.1", - "@stdlib/array-int8": "^0.1.1", - "@stdlib/array-uint16": "^0.1.1", - "@stdlib/array-uint32": "^0.1.1", - "@stdlib/array-uint8": "^0.1.1", - "@stdlib/array-uint8c": "^0.1.1", - "@stdlib/assert-is-boolean": "^0.1.1", - "@stdlib/bench": "^0.1.0", - "@stdlib/buffer-from-array": "^0.1.0", - "@stdlib/math-base-special-pow": "^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", "stdassert", @@ -105,4 +41,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..0134b5d --- /dev/null +++ b/stats.html @@ -0,0 +1,6177 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index a0424fb..0000000 --- a/test/test.js +++ /dev/null @@ -1,106 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Int8Array = require( '@stdlib/array-int8' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Float64Array = require( '@stdlib/array-float64' ); -var array2buffer = require( '@stdlib/buffer-from-array' ); -var isUnityProbabilityArray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof isUnityProbabilityArray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns `true` if provided an array of probabilities that sum to one', function test( t ) { - var values; - var i; - - values = [ - new Int8Array( [ 0, 0, 1 ] ), - new Uint8Array( [ 1, 0, 0 ] ), - new Uint8ClampedArray( [ 0, 1 ] ), - new Int16Array( [ 0, 0, 1, 0 ] ), - new Uint16Array( [ 1 ] ), - new Int32Array( [ 1, 0, 0 ] ), - new Uint32Array( [ 0, 1, 0 ] ), - new Float32Array( [ 0.0, 0.5, 0.5 ] ), - new Float64Array( [ 0.25, 0.25, 0.5 ] ), - [ 0.5, 0.25, 0.25 ] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.strictEqual( isUnityProbabilityArray( values[i] ), true, 'returns true when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function allows a difference in sum within floating-point epsilon', function test( t ) { - var bool = isUnityProbabilityArray( [ 0.1, 0.2, 0.1, 0.1, 0.2, 0.2, 0.1 ] ); - t.strictEqual( bool, true, 'returns true' ); - t.end(); -}); - -tape( 'the function returns `false` if not provided an array of probabilities that sum to one', function test( t ) { - var values; - var i; - - values = [ - '10', - '01', - '0.5', - '5', - 5, - NaN, - null, - void 0, - true, - [], - [ 5, null ], - [ 5, '5' ], - [ 1.0, 3.14 ], - [ -1.0, 1.0, 1.0 ], - [ 0.25, 0.33, 0.5 ], - new Float64Array( [ 0.25, 0.33, 0.5 ] ), - new Float64Array( [ 0.25, 1.33, 0.5 ] ), - new Float64Array( [ 0.25, -0.33, 0.5 ] ), - {}, - function noop() {}, - array2buffer( [ 1, 1, 0 ] ) - ]; - - for ( i = 0; i < values.length; i++ ) { - t.strictEqual( isUnityProbabilityArray( values[i] ), false, 'returns false when provided '+values[i] ); - } - t.end(); -}); From c20fd465d0304d330f4d4ee76e21ca22b5cdcd02 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Dec 2023 11:20:45 +0000 Subject: [PATCH 068/133] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index cc2cf20..32e9474 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,8 @@ "@stdlib/assert-is-number": "^0.1.1", "@stdlib/assert-is-typed-array": "^0.1.0", "@stdlib/constants-float64-sqrt-eps": "^0.1.1", - "@stdlib/math-base-utils-absolute-difference": "^0.2.0" + "@stdlib/math-base-utils-absolute-difference": "^0.2.0", + "@stdlib/error-tools-fmtprodmsg": "^0.1.1" }, "devDependencies": { "@stdlib/array-float32": "^0.1.1", @@ -104,4 +105,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From f04e65aa641f446b112d08732e825246a12176da Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 2 Dec 2023 08:24:21 +0000 Subject: [PATCH 069/133] Remove files --- index.d.ts | 48 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6230 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index 63a123d..0000000 --- a/index.d.ts +++ /dev/null @@ -1,48 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/** -* Tests if a value is an array of probabilities that sum to one. -* -* @param v - value to test -* @returns boolean indicating if a value is a probability array -* -* @example -* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] ); -* // returns true -* -* @example -* var bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) ); -* // returns true -* -* @example -* var bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] ); -* // returns false -* -* @example -* var bool = isUnityProbabilityArray( [ 3.14, 0.0 ] ); -* // returns false -*/ -declare function isUnityProbabilityArray( v: any ): v is ArrayLike; - - -// EXPORTS // - -export = isUnityProbabilityArray; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index bc83655..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-typed-array@v0.1.0-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array@v0.1.1-esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-number@v0.1.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/math-base-utils-absolute-difference@v0.2.0-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/constants-float64-sqrt-eps@v0.1.1-esm/index.mjs";function n(n){var d,m;if(t(n)){for(d=0,m=0;m1||n[m]<0)return!1;d+=n[m]}return r(d,1)<=i}if(s(n)){for(d=0,m=0;m1||n[m]<0)return!1;d+=n[m]}return r(d,1)<=i}return!1}export{n as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 08904b0..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isTypedArray from '@stdlib/assert-is-typed-array';\nimport isArray from '@stdlib/assert-is-array';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport absdiff from '@stdlib/math-base-utils-absolute-difference';\nimport FLOAT64_SQRT_EPS from '@stdlib/constants-float64-sqrt-eps';\n\n\n// MAIN //\n\n/**\n* Tests if a value is an array of probabilities that sum to one.\n*\n* @param {*} v - value to test\n* @returns {boolean} boolean indicating if a value is a probability array\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] );\n* // returns true\n*\n* @example\n* var bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) );\n* // returns true\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] );\n* // returns false\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 3.14, 0.0 ] );\n* // returns false\n*/\nfunction isUnityProbabilityArray( v ) {\n\tvar sum;\n\tvar i;\n\tif ( isArray( v ) ) {\n\t\tsum = 0.0;\n\t\tfor ( i = 0; i < v.length; i++ ) {\n\t\t\tif (\n\t\t\t\t!isNumber( v[ i ] ) ||\n\t\t\t\tv[ i ] > 1.0 ||\n\t\t\t\tv[ i ] < 0.0\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tsum += v[ i ];\n\t\t}\n\t\treturn ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS );\n\t}\n\tif ( isTypedArray( v ) ) {\n\t\tsum = 0.0;\n\t\tfor ( i = 0; i < v.length; i++ ) {\n\t\t\tif (\n\t\t\t\tv[ i ] > 1.0 ||\n\t\t\t\tv[ i ] < 0.0\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tsum += v[ i ];\n\t\t}\n\t\treturn ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS );\n\t}\n\treturn false;\n}\n\n\n// EXPORTS //\n\nexport default isUnityProbabilityArray;\n"],"names":["isUnityProbabilityArray","v","sum","i","isArray","length","isNumber","absdiff","FLOAT64_SQRT_EPS","isTypedArray"],"mappings":";;ufAqDA,SAASA,EAAyBC,GACjC,IAAIC,EACAC,EACJ,GAAKC,EAASH,GAAM,CAEnB,IADAC,EAAM,EACAC,EAAI,EAAGA,EAAIF,EAAEI,OAAQF,IAAM,CAChC,IACEG,EAAUL,EAAGE,KACdF,EAAGE,GAAM,GACTF,EAAGE,GAAM,EAET,OAAO,EAERD,GAAOD,EAAGE,EACV,CACD,OAASI,EAASL,EAAK,IAASM,CAChC,CACD,GAAKC,EAAcR,GAAM,CAExB,IADAC,EAAM,EACAC,EAAI,EAAGA,EAAIF,EAAEI,OAAQF,IAAM,CAChC,GACCF,EAAGE,GAAM,GACTF,EAAGE,GAAM,EAET,OAAO,EAERD,GAAOD,EAAGE,EACV,CACD,OAASI,EAASL,EAAK,IAASM,CAChC,CACD,OAAO,CACR"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 0134b5d..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 1d17eea27b488bee83f73024b18bf430c76dcee3 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 2 Dec 2023 08:25:01 +0000 Subject: [PATCH 070/133] 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 | 41 +- benchmark/benchmark.js | 103 - branches.md | 53 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 29 - docs/types/test.ts | 34 - examples/index.js | 48 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 49 - lib/main.js | 90 - package.json | 70 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 106 - 42 files changed, 6202 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 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/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 dd676eb..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-12-01T04:40:16.220Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 75a4c32..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/assert/is-unity-probability-array) 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 5119885..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/assert/is-unity-probability-array) 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 41d1b0b..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: '49 1 * * 1' - - # 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 + + ```
@@ -176,7 +169,7 @@ bool = isUnityProbabilityArray( null ); ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -240,9 +233,9 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. -[@stdlib/assert/is-probability]: https://github.com/stdlib-js/assert-is-probability +[@stdlib/assert/is-probability]: https://github.com/stdlib-js/assert-is-probability/tree/esm -[@stdlib/assert/is-probability-array]: https://github.com/stdlib-js/assert-is-probability-array +[@stdlib/assert/is-probability-array]: https://github.com/stdlib-js/assert-is-probability-array/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 1121550..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,103 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var isUnityProbabilityArray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x; - var i; - - x = []; - for ( i = 0; i < len; i++ ) { - x.push( 1.0/len ); - } - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: we are testing the worst case scenario where a function must scan the entire array before finding a failing value. - x[ len-1 ] = i * 3.14; - bool = isUnityProbabilityArray( x ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( isBoolean( bool ) ) { - b.pass( 'benchmark finished' ); - } else { - b.fail( 'should return a boolean' ); - } - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':len='+len, f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index d50fc89..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/assert/is-unity-probability-array" -%% click B href "https://github.com/stdlib-js/assert-is-unity-probability-array/tree/main" -%% click C href "https://github.com/stdlib-js/assert-is-unity-probability-array/tree/production" -%% click D href "https://github.com/stdlib-js/assert-is-unity-probability-array/tree/esm" -%% click E href "https://github.com/stdlib-js/assert-is-unity-probability-array/tree/deno" -%% click F href "https://github.com/stdlib-js/assert-is-unity-probability-array/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/assert/is-unity-probability-array -[production-url]: https://github.com/stdlib-js/assert-is-unity-probability-array/tree/production -[deno-url]: https://github.com/stdlib-js/assert-is-unity-probability-array/tree/deno -[umd-url]: https://github.com/stdlib-js/assert-is-unity-probability-array/tree/umd -[esm-url]: https://github.com/stdlib-js/assert-is-unity-probability-array/tree/esm \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index c77d01e..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import isUnityProbabilityArray from '../docs/types/index'; -export = isUnityProbabilityArray; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 70d7801..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var f=function(r,i){return function(){return i||r((i={exports:{}}).exports,i),i.exports}};var u=f(function(m,s){ -var n=require('@stdlib/assert-is-typed-array/dist'),l=require('@stdlib/assert-is-array/dist'),o=require('@stdlib/assert-is-number/dist').isPrimitive,a=require('@stdlib/math-base-utils-absolute-difference/dist'),t=require('@stdlib/constants-float64-sqrt-eps/dist');function q(r){var i,e;if(l(r)){for(i=0,e=0;e1||r[e]<0)return!1;i+=r[e]}return a(i,1)<=t}if(n(r)){for(i=0,e=0;e1||r[e]<0)return!1;i+=r[e]}return a(i,1)<=t}return!1}s.exports=q -});var y=u();module.exports=y; -/** @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 387d5ad..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) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isTypedArray = require( '@stdlib/assert-is-typed-array' );\nvar isArray = require( '@stdlib/assert-is-array' );\nvar isNumber = require( '@stdlib/assert-is-number' ).isPrimitive;\nvar absdiff = require( '@stdlib/math-base-utils-absolute-difference' );\nvar FLOAT64_SQRT_EPS = require( '@stdlib/constants-float64-sqrt-eps' );\n\n\n// MAIN //\n\n/**\n* Tests if a value is an array of probabilities that sum to one.\n*\n* @param {*} v - value to test\n* @returns {boolean} boolean indicating if a value is a probability array\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] );\n* // returns true\n*\n* @example\n* var bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) );\n* // returns true\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] );\n* // returns false\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 3.14, 0.0 ] );\n* // returns false\n*/\nfunction isUnityProbabilityArray( v ) {\n\tvar sum;\n\tvar i;\n\tif ( isArray( v ) ) {\n\t\tsum = 0.0;\n\t\tfor ( i = 0; i < v.length; i++ ) {\n\t\t\tif (\n\t\t\t\t!isNumber( v[ i ] ) ||\n\t\t\t\tv[ i ] > 1.0 ||\n\t\t\t\tv[ i ] < 0.0\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tsum += v[ i ];\n\t\t}\n\t\treturn ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS );\n\t}\n\tif ( isTypedArray( v ) ) {\n\t\tsum = 0.0;\n\t\tfor ( i = 0; i < v.length; i++ ) {\n\t\t\tif (\n\t\t\t\tv[ i ] > 1.0 ||\n\t\t\t\tv[ i ] < 0.0\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tsum += v[ i ];\n\t\t}\n\t\treturn ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS );\n\t}\n\treturn false;\n}\n\n\n// EXPORTS //\n\nmodule.exports = isUnityProbabilityArray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Test if a value is an array of probabilities that sum to one.\n*\n* @module @stdlib/assert-is-unity-probability-array\n*\n* @example\n* var isUnityProbabilityArray = require( '@stdlib/assert-is-unity-probability-array' );\n*\n* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] );\n* // returns true\n*\n* bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) );\n* // returns true\n*\n* bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] );\n* // returns false\n*\n* bool = isUnityProbabilityArray( [ 3.14, 0.0 ] );\n* // returns false\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,EAAe,QAAS,+BAAgC,EACxDC,EAAU,QAAS,yBAA0B,EAC7CC,EAAW,QAAS,0BAA2B,EAAE,YACjDC,EAAU,QAAS,6CAA8C,EACjEC,EAAmB,QAAS,oCAAqC,EA2BrE,SAASC,EAAyBC,EAAI,CACrC,IAAIC,EACAC,EACJ,GAAKP,EAASK,CAAE,EAAI,CAEnB,IADAC,EAAM,EACAC,EAAI,EAAGA,EAAIF,EAAE,OAAQE,IAAM,CAChC,GACC,CAACN,EAAUI,EAAGE,CAAE,CAAE,GAClBF,EAAGE,CAAE,EAAI,GACTF,EAAGE,CAAE,EAAI,EAET,MAAO,GAERD,GAAOD,EAAGE,CAAE,CACb,CACA,OAASL,EAASI,EAAK,CAAI,GAAKH,CACjC,CACA,GAAKJ,EAAcM,CAAE,EAAI,CAExB,IADAC,EAAM,EACAC,EAAI,EAAGA,EAAIF,EAAE,OAAQE,IAAM,CAChC,GACCF,EAAGE,CAAE,EAAI,GACTF,EAAGE,CAAE,EAAI,EAET,MAAO,GAERD,GAAOD,EAAGE,CAAE,CACb,CACA,OAASL,EAASI,EAAK,CAAI,GAAKH,CACjC,CACA,MAAO,EACR,CAKAL,EAAO,QAAUM,IC9CjB,IAAII,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isTypedArray", "isArray", "isNumber", "absdiff", "FLOAT64_SQRT_EPS", "isUnityProbabilityArray", "v", "sum", "i", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index a2414be..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,29 +0,0 @@ - -{{alias}}( value ) - Tests if a value is an array of probabilities that sum to one. - - Parameters - ---------- - value: any - Value to test. - - Returns - ------- - bool: boolean - Boolean indicating whether value is an array of probabilities that sum - to one. - - Examples - -------- - > var bool = {{alias}}( [ 0.25, 0.5, 0.25 ] ) - true - > bool = {{alias}}( new {{alias:@stdlib/array/uint8}}( [ 0, 1 ] ) ) - true - > bool = {{alias}}( [ 0.4, 0.4, 0.4 ] ) - false - > bool = {{alias}}( [ 3.14, 0.0 ] ) - false - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 6b41658..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,34 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import isUnityProbabilityArray = require( './index' ); - - -// TESTS // - -// The function returns a boolean... -{ - isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] ); // $ExpectType boolean - isUnityProbabilityArray( [ 2, 3 ] ); // $ExpectType boolean -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - isUnityProbabilityArray(); // $ExpectError - isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ], 123 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index b0b6bbc..0000000 --- a/examples/index.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var Uint8Array = require( '@stdlib/array-uint8' ); -var isUnityProbabilityArray = require( './../lib' ); - -var arr = [ 0.0, 1.0 ]; -console.log( isUnityProbabilityArray( arr ) ); -// => true - -arr = [ 0.5, 0.25, 0.25 ]; -console.log( isUnityProbabilityArray( arr ) ); -// => true - -arr = new Uint8Array( [ 0, 0, 1, 0 ] ); -console.log( isUnityProbabilityArray( arr ) ); -// => true - -arr = [ 0.4, 0.4, 0.4 ]; -console.log( isUnityProbabilityArray( arr ) ); -// => false - -arr = [ 3.14, -1.0 ]; -console.log( isUnityProbabilityArray( arr ) ); -// => false - -console.log( isUnityProbabilityArray( [] ) ); -// => false - -console.log( isUnityProbabilityArray( null ) ); -// => false diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..bc83655 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-typed-array@v0.1.0-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array@v0.1.1-esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-number@v0.1.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/math-base-utils-absolute-difference@v0.2.0-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/constants-float64-sqrt-eps@v0.1.1-esm/index.mjs";function n(n){var d,m;if(t(n)){for(d=0,m=0;m1||n[m]<0)return!1;d+=n[m]}return r(d,1)<=i}if(s(n)){for(d=0,m=0;m1||n[m]<0)return!1;d+=n[m]}return r(d,1)<=i}return!1}export{n as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..08904b0 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isTypedArray from '@stdlib/assert-is-typed-array';\nimport isArray from '@stdlib/assert-is-array';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport absdiff from '@stdlib/math-base-utils-absolute-difference';\nimport FLOAT64_SQRT_EPS from '@stdlib/constants-float64-sqrt-eps';\n\n\n// MAIN //\n\n/**\n* Tests if a value is an array of probabilities that sum to one.\n*\n* @param {*} v - value to test\n* @returns {boolean} boolean indicating if a value is a probability array\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] );\n* // returns true\n*\n* @example\n* var bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) );\n* // returns true\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] );\n* // returns false\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 3.14, 0.0 ] );\n* // returns false\n*/\nfunction isUnityProbabilityArray( v ) {\n\tvar sum;\n\tvar i;\n\tif ( isArray( v ) ) {\n\t\tsum = 0.0;\n\t\tfor ( i = 0; i < v.length; i++ ) {\n\t\t\tif (\n\t\t\t\t!isNumber( v[ i ] ) ||\n\t\t\t\tv[ i ] > 1.0 ||\n\t\t\t\tv[ i ] < 0.0\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tsum += v[ i ];\n\t\t}\n\t\treturn ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS );\n\t}\n\tif ( isTypedArray( v ) ) {\n\t\tsum = 0.0;\n\t\tfor ( i = 0; i < v.length; i++ ) {\n\t\t\tif (\n\t\t\t\tv[ i ] > 1.0 ||\n\t\t\t\tv[ i ] < 0.0\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tsum += v[ i ];\n\t\t}\n\t\treturn ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS );\n\t}\n\treturn false;\n}\n\n\n// EXPORTS //\n\nexport default isUnityProbabilityArray;\n"],"names":["isUnityProbabilityArray","v","sum","i","isArray","length","isNumber","absdiff","FLOAT64_SQRT_EPS","isTypedArray"],"mappings":";;ufAqDA,SAASA,EAAyBC,GACjC,IAAIC,EACAC,EACJ,GAAKC,EAASH,GAAM,CAEnB,IADAC,EAAM,EACAC,EAAI,EAAGA,EAAIF,EAAEI,OAAQF,IAAM,CAChC,IACEG,EAAUL,EAAGE,KACdF,EAAGE,GAAM,GACTF,EAAGE,GAAM,EAET,OAAO,EAERD,GAAOD,EAAGE,EACV,CACD,OAASI,EAASL,EAAK,IAASM,CAChC,CACD,GAAKC,EAAcR,GAAM,CAExB,IADAC,EAAM,EACAC,EAAI,EAAGA,EAAIF,EAAEI,OAAQF,IAAM,CAChC,GACCF,EAAGE,GAAM,GACTF,EAAGE,GAAM,EAET,OAAO,EAERD,GAAOD,EAAGE,EACV,CACD,OAASI,EAASL,EAAK,IAASM,CAChC,CACD,OAAO,CACR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 13a67d1..0000000 --- a/lib/index.js +++ /dev/null @@ -1,49 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Test if a value is an array of probabilities that sum to one. -* -* @module @stdlib/assert-is-unity-probability-array -* -* @example -* var isUnityProbabilityArray = require( '@stdlib/assert-is-unity-probability-array' ); -* -* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] ); -* // returns true -* -* bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) ); -* // returns true -* -* bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] ); -* // returns false -* -* bool = isUnityProbabilityArray( [ 3.14, 0.0 ] ); -* // returns false -*/ - -// 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 d0bda40..0000000 --- a/lib/main.js +++ /dev/null @@ -1,90 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -var isArray = require( '@stdlib/assert-is-array' ); -var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var absdiff = require( '@stdlib/math-base-utils-absolute-difference' ); -var FLOAT64_SQRT_EPS = require( '@stdlib/constants-float64-sqrt-eps' ); - - -// MAIN // - -/** -* Tests if a value is an array of probabilities that sum to one. -* -* @param {*} v - value to test -* @returns {boolean} boolean indicating if a value is a probability array -* -* @example -* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] ); -* // returns true -* -* @example -* var bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) ); -* // returns true -* -* @example -* var bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] ); -* // returns false -* -* @example -* var bool = isUnityProbabilityArray( [ 3.14, 0.0 ] ); -* // returns false -*/ -function isUnityProbabilityArray( v ) { - var sum; - var i; - if ( isArray( v ) ) { - sum = 0.0; - for ( i = 0; i < v.length; i++ ) { - if ( - !isNumber( v[ i ] ) || - v[ i ] > 1.0 || - v[ i ] < 0.0 - ) { - return false; - } - sum += v[ i ]; - } - return ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS ); - } - if ( isTypedArray( v ) ) { - sum = 0.0; - for ( i = 0; i < v.length; i++ ) { - if ( - v[ i ] > 1.0 || - v[ i ] < 0.0 - ) { - return false; - } - sum += v[ i ]; - } - return ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS ); - } - return false; -} - - -// EXPORTS // - -module.exports = isUnityProbabilityArray; diff --git a/package.json b/package.json index 32e9474..660ccd4 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.0", "description": "Test if a value is an array of probabilities that sum to one.", "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" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,47 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-array": "^0.1.1", - "@stdlib/assert-is-number": "^0.1.1", - "@stdlib/assert-is-typed-array": "^0.1.0", - "@stdlib/constants-float64-sqrt-eps": "^0.1.1", - "@stdlib/math-base-utils-absolute-difference": "^0.2.0", - "@stdlib/error-tools-fmtprodmsg": "^0.1.1" - }, - "devDependencies": { - "@stdlib/array-float32": "^0.1.1", - "@stdlib/array-float64": "^0.1.1", - "@stdlib/array-int16": "^0.1.1", - "@stdlib/array-int32": "^0.1.1", - "@stdlib/array-int8": "^0.1.1", - "@stdlib/array-uint16": "^0.1.1", - "@stdlib/array-uint32": "^0.1.1", - "@stdlib/array-uint8": "^0.1.1", - "@stdlib/array-uint8c": "^0.1.1", - "@stdlib/assert-is-boolean": "^0.1.1", - "@stdlib/bench": "^0.2.1", - "@stdlib/buffer-from-array": "^0.1.0", - "@stdlib/math-base-special-pow": "^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", "stdassert", @@ -105,4 +41,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..306c433 --- /dev/null +++ b/stats.html @@ -0,0 +1,6177 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index a0424fb..0000000 --- a/test/test.js +++ /dev/null @@ -1,106 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Int8Array = require( '@stdlib/array-int8' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Float64Array = require( '@stdlib/array-float64' ); -var array2buffer = require( '@stdlib/buffer-from-array' ); -var isUnityProbabilityArray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof isUnityProbabilityArray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns `true` if provided an array of probabilities that sum to one', function test( t ) { - var values; - var i; - - values = [ - new Int8Array( [ 0, 0, 1 ] ), - new Uint8Array( [ 1, 0, 0 ] ), - new Uint8ClampedArray( [ 0, 1 ] ), - new Int16Array( [ 0, 0, 1, 0 ] ), - new Uint16Array( [ 1 ] ), - new Int32Array( [ 1, 0, 0 ] ), - new Uint32Array( [ 0, 1, 0 ] ), - new Float32Array( [ 0.0, 0.5, 0.5 ] ), - new Float64Array( [ 0.25, 0.25, 0.5 ] ), - [ 0.5, 0.25, 0.25 ] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.strictEqual( isUnityProbabilityArray( values[i] ), true, 'returns true when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function allows a difference in sum within floating-point epsilon', function test( t ) { - var bool = isUnityProbabilityArray( [ 0.1, 0.2, 0.1, 0.1, 0.2, 0.2, 0.1 ] ); - t.strictEqual( bool, true, 'returns true' ); - t.end(); -}); - -tape( 'the function returns `false` if not provided an array of probabilities that sum to one', function test( t ) { - var values; - var i; - - values = [ - '10', - '01', - '0.5', - '5', - 5, - NaN, - null, - void 0, - true, - [], - [ 5, null ], - [ 5, '5' ], - [ 1.0, 3.14 ], - [ -1.0, 1.0, 1.0 ], - [ 0.25, 0.33, 0.5 ], - new Float64Array( [ 0.25, 0.33, 0.5 ] ), - new Float64Array( [ 0.25, 1.33, 0.5 ] ), - new Float64Array( [ 0.25, -0.33, 0.5 ] ), - {}, - function noop() {}, - array2buffer( [ 1, 1, 0 ] ) - ]; - - for ( i = 0; i < values.length; i++ ) { - t.strictEqual( isUnityProbabilityArray( values[i] ), false, 'returns false when provided '+values[i] ); - } - t.end(); -}); From 497d18a6dc75526574cacc9a1ac8f07aba442565 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Jan 2024 06:40:38 +0000 Subject: [PATCH 071/133] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 35b9562..55c2c62 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,8 @@ "@stdlib/assert-is-number": "^0.1.1", "@stdlib/assert-is-typed-array": "^0.1.0", "@stdlib/constants-float64-sqrt-eps": "^0.1.1", - "@stdlib/math-base-utils-absolute-difference": "^0.2.0" + "@stdlib/math-base-utils-absolute-difference": "^0.2.0", + "@stdlib/error-tools-fmtprodmsg": "^0.1.1" }, "devDependencies": { "@stdlib/array-float32": "^0.1.1", @@ -104,4 +105,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From dd408ed96d020194dbb786333c43b2a815669a01 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Jan 2024 13:25:30 +0000 Subject: [PATCH 072/133] Remove files --- index.d.ts | 48 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6230 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index 63a123d..0000000 --- a/index.d.ts +++ /dev/null @@ -1,48 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/** -* Tests if a value is an array of probabilities that sum to one. -* -* @param v - value to test -* @returns boolean indicating if a value is a probability array -* -* @example -* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] ); -* // returns true -* -* @example -* var bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) ); -* // returns true -* -* @example -* var bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] ); -* // returns false -* -* @example -* var bool = isUnityProbabilityArray( [ 3.14, 0.0 ] ); -* // returns false -*/ -declare function isUnityProbabilityArray( v: any ): v is ArrayLike; - - -// EXPORTS // - -export = isUnityProbabilityArray; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index bc83655..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-typed-array@v0.1.0-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array@v0.1.1-esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-number@v0.1.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/math-base-utils-absolute-difference@v0.2.0-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/constants-float64-sqrt-eps@v0.1.1-esm/index.mjs";function n(n){var d,m;if(t(n)){for(d=0,m=0;m1||n[m]<0)return!1;d+=n[m]}return r(d,1)<=i}if(s(n)){for(d=0,m=0;m1||n[m]<0)return!1;d+=n[m]}return r(d,1)<=i}return!1}export{n as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 08904b0..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isTypedArray from '@stdlib/assert-is-typed-array';\nimport isArray from '@stdlib/assert-is-array';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport absdiff from '@stdlib/math-base-utils-absolute-difference';\nimport FLOAT64_SQRT_EPS from '@stdlib/constants-float64-sqrt-eps';\n\n\n// MAIN //\n\n/**\n* Tests if a value is an array of probabilities that sum to one.\n*\n* @param {*} v - value to test\n* @returns {boolean} boolean indicating if a value is a probability array\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] );\n* // returns true\n*\n* @example\n* var bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) );\n* // returns true\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] );\n* // returns false\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 3.14, 0.0 ] );\n* // returns false\n*/\nfunction isUnityProbabilityArray( v ) {\n\tvar sum;\n\tvar i;\n\tif ( isArray( v ) ) {\n\t\tsum = 0.0;\n\t\tfor ( i = 0; i < v.length; i++ ) {\n\t\t\tif (\n\t\t\t\t!isNumber( v[ i ] ) ||\n\t\t\t\tv[ i ] > 1.0 ||\n\t\t\t\tv[ i ] < 0.0\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tsum += v[ i ];\n\t\t}\n\t\treturn ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS );\n\t}\n\tif ( isTypedArray( v ) ) {\n\t\tsum = 0.0;\n\t\tfor ( i = 0; i < v.length; i++ ) {\n\t\t\tif (\n\t\t\t\tv[ i ] > 1.0 ||\n\t\t\t\tv[ i ] < 0.0\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tsum += v[ i ];\n\t\t}\n\t\treturn ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS );\n\t}\n\treturn false;\n}\n\n\n// EXPORTS //\n\nexport default isUnityProbabilityArray;\n"],"names":["isUnityProbabilityArray","v","sum","i","isArray","length","isNumber","absdiff","FLOAT64_SQRT_EPS","isTypedArray"],"mappings":";;ufAqDA,SAASA,EAAyBC,GACjC,IAAIC,EACAC,EACJ,GAAKC,EAASH,GAAM,CAEnB,IADAC,EAAM,EACAC,EAAI,EAAGA,EAAIF,EAAEI,OAAQF,IAAM,CAChC,IACEG,EAAUL,EAAGE,KACdF,EAAGE,GAAM,GACTF,EAAGE,GAAM,EAET,OAAO,EAERD,GAAOD,EAAGE,EACV,CACD,OAASI,EAASL,EAAK,IAASM,CAChC,CACD,GAAKC,EAAcR,GAAM,CAExB,IADAC,EAAM,EACAC,EAAI,EAAGA,EAAIF,EAAEI,OAAQF,IAAM,CAChC,GACCF,EAAGE,GAAM,GACTF,EAAGE,GAAM,EAET,OAAO,EAERD,GAAOD,EAAGE,EACV,CACD,OAASI,EAASL,EAAK,IAASM,CAChC,CACD,OAAO,CACR"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 306c433..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 70a6d70782104b08258c0d8249731ba3a2bb8885 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Jan 2024 13:25:44 +0000 Subject: [PATCH 073/133] 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 | 41 +- SECURITY.md | 5 - benchmark/benchmark.js | 103 - branches.md | 53 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 29 - docs/types/test.ts | 34 - examples/index.js | 48 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 49 - lib/main.js | 90 - package.json | 70 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 106 - 43 files changed, 6202 insertions(+), 3820 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 delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/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 d562110..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-01-01T04:05:49.407Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 75a4c32..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/assert/is-unity-probability-array) 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 5119885..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/assert/is-unity-probability-array) 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 592af1d..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: '49 1 * * 1' - - # 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 + + ```
@@ -176,7 +169,7 @@ bool = isUnityProbabilityArray( null ); ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -240,9 +233,9 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/assert/is-probability]: https://github.com/stdlib-js/assert-is-probability +[@stdlib/assert/is-probability]: https://github.com/stdlib-js/assert-is-probability/tree/esm -[@stdlib/assert/is-probability-array]: https://github.com/stdlib-js/assert-is-probability-array +[@stdlib/assert/is-probability-array]: https://github.com/stdlib-js/assert-is-probability-array/tree/esm diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 510a5ed..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,103 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var isUnityProbabilityArray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x; - var i; - - x = []; - for ( i = 0; i < len; i++ ) { - x.push( 1.0/len ); - } - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: we are testing the worst case scenario where a function must scan the entire array before finding a failing value. - x[ len-1 ] = i * 3.14; - bool = isUnityProbabilityArray( x ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( isBoolean( bool ) ) { - b.pass( 'benchmark finished' ); - } else { - b.fail( 'should return a boolean' ); - } - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':len='+len, f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index d50fc89..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/assert/is-unity-probability-array" -%% click B href "https://github.com/stdlib-js/assert-is-unity-probability-array/tree/main" -%% click C href "https://github.com/stdlib-js/assert-is-unity-probability-array/tree/production" -%% click D href "https://github.com/stdlib-js/assert-is-unity-probability-array/tree/esm" -%% click E href "https://github.com/stdlib-js/assert-is-unity-probability-array/tree/deno" -%% click F href "https://github.com/stdlib-js/assert-is-unity-probability-array/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/assert/is-unity-probability-array -[production-url]: https://github.com/stdlib-js/assert-is-unity-probability-array/tree/production -[deno-url]: https://github.com/stdlib-js/assert-is-unity-probability-array/tree/deno -[umd-url]: https://github.com/stdlib-js/assert-is-unity-probability-array/tree/umd -[esm-url]: https://github.com/stdlib-js/assert-is-unity-probability-array/tree/esm \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index c77d01e..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import isUnityProbabilityArray from '../docs/types/index'; -export = isUnityProbabilityArray; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 70d7801..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var f=function(r,i){return function(){return i||r((i={exports:{}}).exports,i),i.exports}};var u=f(function(m,s){ -var n=require('@stdlib/assert-is-typed-array/dist'),l=require('@stdlib/assert-is-array/dist'),o=require('@stdlib/assert-is-number/dist').isPrimitive,a=require('@stdlib/math-base-utils-absolute-difference/dist'),t=require('@stdlib/constants-float64-sqrt-eps/dist');function q(r){var i,e;if(l(r)){for(i=0,e=0;e1||r[e]<0)return!1;i+=r[e]}return a(i,1)<=t}if(n(r)){for(i=0,e=0;e1||r[e]<0)return!1;i+=r[e]}return a(i,1)<=t}return!1}s.exports=q -});var y=u();module.exports=y; -/** @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 387d5ad..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) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isTypedArray = require( '@stdlib/assert-is-typed-array' );\nvar isArray = require( '@stdlib/assert-is-array' );\nvar isNumber = require( '@stdlib/assert-is-number' ).isPrimitive;\nvar absdiff = require( '@stdlib/math-base-utils-absolute-difference' );\nvar FLOAT64_SQRT_EPS = require( '@stdlib/constants-float64-sqrt-eps' );\n\n\n// MAIN //\n\n/**\n* Tests if a value is an array of probabilities that sum to one.\n*\n* @param {*} v - value to test\n* @returns {boolean} boolean indicating if a value is a probability array\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] );\n* // returns true\n*\n* @example\n* var bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) );\n* // returns true\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] );\n* // returns false\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 3.14, 0.0 ] );\n* // returns false\n*/\nfunction isUnityProbabilityArray( v ) {\n\tvar sum;\n\tvar i;\n\tif ( isArray( v ) ) {\n\t\tsum = 0.0;\n\t\tfor ( i = 0; i < v.length; i++ ) {\n\t\t\tif (\n\t\t\t\t!isNumber( v[ i ] ) ||\n\t\t\t\tv[ i ] > 1.0 ||\n\t\t\t\tv[ i ] < 0.0\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tsum += v[ i ];\n\t\t}\n\t\treturn ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS );\n\t}\n\tif ( isTypedArray( v ) ) {\n\t\tsum = 0.0;\n\t\tfor ( i = 0; i < v.length; i++ ) {\n\t\t\tif (\n\t\t\t\tv[ i ] > 1.0 ||\n\t\t\t\tv[ i ] < 0.0\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tsum += v[ i ];\n\t\t}\n\t\treturn ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS );\n\t}\n\treturn false;\n}\n\n\n// EXPORTS //\n\nmodule.exports = isUnityProbabilityArray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Test if a value is an array of probabilities that sum to one.\n*\n* @module @stdlib/assert-is-unity-probability-array\n*\n* @example\n* var isUnityProbabilityArray = require( '@stdlib/assert-is-unity-probability-array' );\n*\n* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] );\n* // returns true\n*\n* bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) );\n* // returns true\n*\n* bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] );\n* // returns false\n*\n* bool = isUnityProbabilityArray( [ 3.14, 0.0 ] );\n* // returns false\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,EAAe,QAAS,+BAAgC,EACxDC,EAAU,QAAS,yBAA0B,EAC7CC,EAAW,QAAS,0BAA2B,EAAE,YACjDC,EAAU,QAAS,6CAA8C,EACjEC,EAAmB,QAAS,oCAAqC,EA2BrE,SAASC,EAAyBC,EAAI,CACrC,IAAIC,EACAC,EACJ,GAAKP,EAASK,CAAE,EAAI,CAEnB,IADAC,EAAM,EACAC,EAAI,EAAGA,EAAIF,EAAE,OAAQE,IAAM,CAChC,GACC,CAACN,EAAUI,EAAGE,CAAE,CAAE,GAClBF,EAAGE,CAAE,EAAI,GACTF,EAAGE,CAAE,EAAI,EAET,MAAO,GAERD,GAAOD,EAAGE,CAAE,CACb,CACA,OAASL,EAASI,EAAK,CAAI,GAAKH,CACjC,CACA,GAAKJ,EAAcM,CAAE,EAAI,CAExB,IADAC,EAAM,EACAC,EAAI,EAAGA,EAAIF,EAAE,OAAQE,IAAM,CAChC,GACCF,EAAGE,CAAE,EAAI,GACTF,EAAGE,CAAE,EAAI,EAET,MAAO,GAERD,GAAOD,EAAGE,CAAE,CACb,CACA,OAASL,EAASI,EAAK,CAAI,GAAKH,CACjC,CACA,MAAO,EACR,CAKAL,EAAO,QAAUM,IC9CjB,IAAII,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isTypedArray", "isArray", "isNumber", "absdiff", "FLOAT64_SQRT_EPS", "isUnityProbabilityArray", "v", "sum", "i", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index a2414be..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,29 +0,0 @@ - -{{alias}}( value ) - Tests if a value is an array of probabilities that sum to one. - - Parameters - ---------- - value: any - Value to test. - - Returns - ------- - bool: boolean - Boolean indicating whether value is an array of probabilities that sum - to one. - - Examples - -------- - > var bool = {{alias}}( [ 0.25, 0.5, 0.25 ] ) - true - > bool = {{alias}}( new {{alias:@stdlib/array/uint8}}( [ 0, 1 ] ) ) - true - > bool = {{alias}}( [ 0.4, 0.4, 0.4 ] ) - false - > bool = {{alias}}( [ 3.14, 0.0 ] ) - false - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 6b41658..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,34 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import isUnityProbabilityArray = require( './index' ); - - -// TESTS // - -// The function returns a boolean... -{ - isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] ); // $ExpectType boolean - isUnityProbabilityArray( [ 2, 3 ] ); // $ExpectType boolean -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - isUnityProbabilityArray(); // $ExpectError - isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ], 123 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index b0b6bbc..0000000 --- a/examples/index.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var Uint8Array = require( '@stdlib/array-uint8' ); -var isUnityProbabilityArray = require( './../lib' ); - -var arr = [ 0.0, 1.0 ]; -console.log( isUnityProbabilityArray( arr ) ); -// => true - -arr = [ 0.5, 0.25, 0.25 ]; -console.log( isUnityProbabilityArray( arr ) ); -// => true - -arr = new Uint8Array( [ 0, 0, 1, 0 ] ); -console.log( isUnityProbabilityArray( arr ) ); -// => true - -arr = [ 0.4, 0.4, 0.4 ]; -console.log( isUnityProbabilityArray( arr ) ); -// => false - -arr = [ 3.14, -1.0 ]; -console.log( isUnityProbabilityArray( arr ) ); -// => false - -console.log( isUnityProbabilityArray( [] ) ); -// => false - -console.log( isUnityProbabilityArray( null ) ); -// => false diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..0a95bd4 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-typed-array@v0.1.0-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array@v0.1.1-esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-number@v0.1.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/math-base-utils-absolute-difference@v0.2.0-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/constants-float64-sqrt-eps@v0.1.1-esm/index.mjs";function n(n){var d,m;if(t(n)){for(d=0,m=0;m1||n[m]<0)return!1;d+=n[m]}return r(d,1)<=i}if(s(n)){for(d=0,m=0;m1||n[m]<0)return!1;d+=n[m]}return r(d,1)<=i}return!1}export{n as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..08904b0 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isTypedArray from '@stdlib/assert-is-typed-array';\nimport isArray from '@stdlib/assert-is-array';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport absdiff from '@stdlib/math-base-utils-absolute-difference';\nimport FLOAT64_SQRT_EPS from '@stdlib/constants-float64-sqrt-eps';\n\n\n// MAIN //\n\n/**\n* Tests if a value is an array of probabilities that sum to one.\n*\n* @param {*} v - value to test\n* @returns {boolean} boolean indicating if a value is a probability array\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] );\n* // returns true\n*\n* @example\n* var bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) );\n* // returns true\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] );\n* // returns false\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 3.14, 0.0 ] );\n* // returns false\n*/\nfunction isUnityProbabilityArray( v ) {\n\tvar sum;\n\tvar i;\n\tif ( isArray( v ) ) {\n\t\tsum = 0.0;\n\t\tfor ( i = 0; i < v.length; i++ ) {\n\t\t\tif (\n\t\t\t\t!isNumber( v[ i ] ) ||\n\t\t\t\tv[ i ] > 1.0 ||\n\t\t\t\tv[ i ] < 0.0\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tsum += v[ i ];\n\t\t}\n\t\treturn ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS );\n\t}\n\tif ( isTypedArray( v ) ) {\n\t\tsum = 0.0;\n\t\tfor ( i = 0; i < v.length; i++ ) {\n\t\t\tif (\n\t\t\t\tv[ i ] > 1.0 ||\n\t\t\t\tv[ i ] < 0.0\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tsum += v[ i ];\n\t\t}\n\t\treturn ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS );\n\t}\n\treturn false;\n}\n\n\n// EXPORTS //\n\nexport default isUnityProbabilityArray;\n"],"names":["isUnityProbabilityArray","v","sum","i","isArray","length","isNumber","absdiff","FLOAT64_SQRT_EPS","isTypedArray"],"mappings":";;ufAqDA,SAASA,EAAyBC,GACjC,IAAIC,EACAC,EACJ,GAAKC,EAASH,GAAM,CAEnB,IADAC,EAAM,EACAC,EAAI,EAAGA,EAAIF,EAAEI,OAAQF,IAAM,CAChC,IACEG,EAAUL,EAAGE,KACdF,EAAGE,GAAM,GACTF,EAAGE,GAAM,EAET,OAAO,EAERD,GAAOD,EAAGE,EACV,CACD,OAASI,EAASL,EAAK,IAASM,CAChC,CACD,GAAKC,EAAcR,GAAM,CAExB,IADAC,EAAM,EACAC,EAAI,EAAGA,EAAIF,EAAEI,OAAQF,IAAM,CAChC,GACCF,EAAGE,GAAM,GACTF,EAAGE,GAAM,EAET,OAAO,EAERD,GAAOD,EAAGE,EACV,CACD,OAASI,EAASL,EAAK,IAASM,CAChC,CACD,OAAO,CACR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 13a67d1..0000000 --- a/lib/index.js +++ /dev/null @@ -1,49 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Test if a value is an array of probabilities that sum to one. -* -* @module @stdlib/assert-is-unity-probability-array -* -* @example -* var isUnityProbabilityArray = require( '@stdlib/assert-is-unity-probability-array' ); -* -* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] ); -* // returns true -* -* bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) ); -* // returns true -* -* bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] ); -* // returns false -* -* bool = isUnityProbabilityArray( [ 3.14, 0.0 ] ); -* // returns false -*/ - -// 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 d0bda40..0000000 --- a/lib/main.js +++ /dev/null @@ -1,90 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -var isArray = require( '@stdlib/assert-is-array' ); -var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var absdiff = require( '@stdlib/math-base-utils-absolute-difference' ); -var FLOAT64_SQRT_EPS = require( '@stdlib/constants-float64-sqrt-eps' ); - - -// MAIN // - -/** -* Tests if a value is an array of probabilities that sum to one. -* -* @param {*} v - value to test -* @returns {boolean} boolean indicating if a value is a probability array -* -* @example -* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] ); -* // returns true -* -* @example -* var bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) ); -* // returns true -* -* @example -* var bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] ); -* // returns false -* -* @example -* var bool = isUnityProbabilityArray( [ 3.14, 0.0 ] ); -* // returns false -*/ -function isUnityProbabilityArray( v ) { - var sum; - var i; - if ( isArray( v ) ) { - sum = 0.0; - for ( i = 0; i < v.length; i++ ) { - if ( - !isNumber( v[ i ] ) || - v[ i ] > 1.0 || - v[ i ] < 0.0 - ) { - return false; - } - sum += v[ i ]; - } - return ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS ); - } - if ( isTypedArray( v ) ) { - sum = 0.0; - for ( i = 0; i < v.length; i++ ) { - if ( - v[ i ] > 1.0 || - v[ i ] < 0.0 - ) { - return false; - } - sum += v[ i ]; - } - return ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS ); - } - return false; -} - - -// EXPORTS // - -module.exports = isUnityProbabilityArray; diff --git a/package.json b/package.json index 55c2c62..660ccd4 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.0", "description": "Test if a value is an array of probabilities that sum to one.", "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" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,47 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-array": "^0.1.1", - "@stdlib/assert-is-number": "^0.1.1", - "@stdlib/assert-is-typed-array": "^0.1.0", - "@stdlib/constants-float64-sqrt-eps": "^0.1.1", - "@stdlib/math-base-utils-absolute-difference": "^0.2.0", - "@stdlib/error-tools-fmtprodmsg": "^0.1.1" - }, - "devDependencies": { - "@stdlib/array-float32": "^0.1.1", - "@stdlib/array-float64": "^0.1.1", - "@stdlib/array-int16": "^0.1.1", - "@stdlib/array-int32": "^0.1.1", - "@stdlib/array-int8": "^0.1.1", - "@stdlib/array-uint16": "^0.1.1", - "@stdlib/array-uint32": "^0.1.1", - "@stdlib/array-uint8": "^0.1.1", - "@stdlib/array-uint8c": "^0.1.1", - "@stdlib/assert-is-boolean": "^0.1.1", - "@stdlib/buffer-from-array": "^0.1.0", - "@stdlib/math-base-special-pow": "^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", - "@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", "stdassert", @@ -105,4 +41,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..03c248f --- /dev/null +++ b/stats.html @@ -0,0 +1,6177 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index a0424fb..0000000 --- a/test/test.js +++ /dev/null @@ -1,106 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Int8Array = require( '@stdlib/array-int8' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Float64Array = require( '@stdlib/array-float64' ); -var array2buffer = require( '@stdlib/buffer-from-array' ); -var isUnityProbabilityArray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof isUnityProbabilityArray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns `true` if provided an array of probabilities that sum to one', function test( t ) { - var values; - var i; - - values = [ - new Int8Array( [ 0, 0, 1 ] ), - new Uint8Array( [ 1, 0, 0 ] ), - new Uint8ClampedArray( [ 0, 1 ] ), - new Int16Array( [ 0, 0, 1, 0 ] ), - new Uint16Array( [ 1 ] ), - new Int32Array( [ 1, 0, 0 ] ), - new Uint32Array( [ 0, 1, 0 ] ), - new Float32Array( [ 0.0, 0.5, 0.5 ] ), - new Float64Array( [ 0.25, 0.25, 0.5 ] ), - [ 0.5, 0.25, 0.25 ] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.strictEqual( isUnityProbabilityArray( values[i] ), true, 'returns true when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function allows a difference in sum within floating-point epsilon', function test( t ) { - var bool = isUnityProbabilityArray( [ 0.1, 0.2, 0.1, 0.1, 0.2, 0.2, 0.1 ] ); - t.strictEqual( bool, true, 'returns true' ); - t.end(); -}); - -tape( 'the function returns `false` if not provided an array of probabilities that sum to one', function test( t ) { - var values; - var i; - - values = [ - '10', - '01', - '0.5', - '5', - 5, - NaN, - null, - void 0, - true, - [], - [ 5, null ], - [ 5, '5' ], - [ 1.0, 3.14 ], - [ -1.0, 1.0, 1.0 ], - [ 0.25, 0.33, 0.5 ], - new Float64Array( [ 0.25, 0.33, 0.5 ] ), - new Float64Array( [ 0.25, 1.33, 0.5 ] ), - new Float64Array( [ 0.25, -0.33, 0.5 ] ), - {}, - function noop() {}, - array2buffer( [ 1, 1, 0 ] ) - ]; - - for ( i = 0; i < values.length; i++ ) { - t.strictEqual( isUnityProbabilityArray( values[i] ), false, 'returns false when provided '+values[i] ); - } - t.end(); -}); From f800f060c95683b66e665f0dd842411bf377127f Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Feb 2024 07:12:03 +0000 Subject: [PATCH 074/133] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 35b9562..55c2c62 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,8 @@ "@stdlib/assert-is-number": "^0.1.1", "@stdlib/assert-is-typed-array": "^0.1.0", "@stdlib/constants-float64-sqrt-eps": "^0.1.1", - "@stdlib/math-base-utils-absolute-difference": "^0.2.0" + "@stdlib/math-base-utils-absolute-difference": "^0.2.0", + "@stdlib/error-tools-fmtprodmsg": "^0.1.1" }, "devDependencies": { "@stdlib/array-float32": "^0.1.1", @@ -104,4 +105,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 3e43f194178f80d614d6e1b71f3e4672396c07f7 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Feb 2024 12:42:38 +0000 Subject: [PATCH 075/133] Remove files --- index.d.ts | 48 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6230 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index 63a123d..0000000 --- a/index.d.ts +++ /dev/null @@ -1,48 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/** -* Tests if a value is an array of probabilities that sum to one. -* -* @param v - value to test -* @returns boolean indicating if a value is a probability array -* -* @example -* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] ); -* // returns true -* -* @example -* var bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) ); -* // returns true -* -* @example -* var bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] ); -* // returns false -* -* @example -* var bool = isUnityProbabilityArray( [ 3.14, 0.0 ] ); -* // returns false -*/ -declare function isUnityProbabilityArray( v: any ): v is ArrayLike; - - -// EXPORTS // - -export = isUnityProbabilityArray; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 0a95bd4..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-typed-array@v0.1.0-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array@v0.1.1-esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-number@v0.1.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/math-base-utils-absolute-difference@v0.2.0-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/constants-float64-sqrt-eps@v0.1.1-esm/index.mjs";function n(n){var d,m;if(t(n)){for(d=0,m=0;m1||n[m]<0)return!1;d+=n[m]}return r(d,1)<=i}if(s(n)){for(d=0,m=0;m1||n[m]<0)return!1;d+=n[m]}return r(d,1)<=i}return!1}export{n as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 08904b0..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isTypedArray from '@stdlib/assert-is-typed-array';\nimport isArray from '@stdlib/assert-is-array';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport absdiff from '@stdlib/math-base-utils-absolute-difference';\nimport FLOAT64_SQRT_EPS from '@stdlib/constants-float64-sqrt-eps';\n\n\n// MAIN //\n\n/**\n* Tests if a value is an array of probabilities that sum to one.\n*\n* @param {*} v - value to test\n* @returns {boolean} boolean indicating if a value is a probability array\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] );\n* // returns true\n*\n* @example\n* var bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) );\n* // returns true\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] );\n* // returns false\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 3.14, 0.0 ] );\n* // returns false\n*/\nfunction isUnityProbabilityArray( v ) {\n\tvar sum;\n\tvar i;\n\tif ( isArray( v ) ) {\n\t\tsum = 0.0;\n\t\tfor ( i = 0; i < v.length; i++ ) {\n\t\t\tif (\n\t\t\t\t!isNumber( v[ i ] ) ||\n\t\t\t\tv[ i ] > 1.0 ||\n\t\t\t\tv[ i ] < 0.0\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tsum += v[ i ];\n\t\t}\n\t\treturn ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS );\n\t}\n\tif ( isTypedArray( v ) ) {\n\t\tsum = 0.0;\n\t\tfor ( i = 0; i < v.length; i++ ) {\n\t\t\tif (\n\t\t\t\tv[ i ] > 1.0 ||\n\t\t\t\tv[ i ] < 0.0\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tsum += v[ i ];\n\t\t}\n\t\treturn ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS );\n\t}\n\treturn false;\n}\n\n\n// EXPORTS //\n\nexport default isUnityProbabilityArray;\n"],"names":["isUnityProbabilityArray","v","sum","i","isArray","length","isNumber","absdiff","FLOAT64_SQRT_EPS","isTypedArray"],"mappings":";;ufAqDA,SAASA,EAAyBC,GACjC,IAAIC,EACAC,EACJ,GAAKC,EAASH,GAAM,CAEnB,IADAC,EAAM,EACAC,EAAI,EAAGA,EAAIF,EAAEI,OAAQF,IAAM,CAChC,IACEG,EAAUL,EAAGE,KACdF,EAAGE,GAAM,GACTF,EAAGE,GAAM,EAET,OAAO,EAERD,GAAOD,EAAGE,EACV,CACD,OAASI,EAASL,EAAK,IAASM,CAChC,CACD,GAAKC,EAAcR,GAAM,CAExB,IADAC,EAAM,EACAC,EAAI,EAAGA,EAAIF,EAAEI,OAAQF,IAAM,CAChC,GACCF,EAAGE,GAAM,GACTF,EAAGE,GAAM,EAET,OAAO,EAERD,GAAOD,EAAGE,EACV,CACD,OAASI,EAASL,EAAK,IAASM,CAChC,CACD,OAAO,CACR"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 03c248f..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 8fe03d89791b7b9d79cad85d743b804605aa269d Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Feb 2024 12:42:55 +0000 Subject: [PATCH 076/133] 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 | 43 +- SECURITY.md | 5 - benchmark/benchmark.js | 103 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 29 - docs/types/test.ts | 34 - examples/index.js | 48 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 49 - lib/main.js | 90 - package.json | 70 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 106 - 43 files changed, 6202 insertions(+), 3825 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 delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/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 edf3f9f..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-02-01T04:54:10.866Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 75a4c32..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/assert/is-unity-probability-array) 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 5119885..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/assert/is-unity-probability-array) 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 592af1d..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: '49 1 * * 1' - - # 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 + + ```
@@ -178,7 +169,7 @@ bool = isUnityProbabilityArray( null ); ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -245,9 +236,9 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/assert/is-probability]: https://github.com/stdlib-js/assert-is-probability +[@stdlib/assert/is-probability]: https://github.com/stdlib-js/assert-is-probability/tree/esm -[@stdlib/assert/is-probability-array]: https://github.com/stdlib-js/assert-is-probability-array +[@stdlib/assert/is-probability-array]: https://github.com/stdlib-js/assert-is-probability-array/tree/esm diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 510a5ed..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,103 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var isUnityProbabilityArray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x; - var i; - - x = []; - for ( i = 0; i < len; i++ ) { - x.push( 1.0/len ); - } - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: we are testing the worst case scenario where a function must scan the entire array before finding a failing value. - x[ len-1 ] = i * 3.14; - bool = isUnityProbabilityArray( x ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( isBoolean( bool ) ) { - b.pass( 'benchmark finished' ); - } else { - b.fail( 'should return a boolean' ); - } - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':len='+len, f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index 5a6810d..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/assert/is-unity-probability-array" -%% click B href "https://github.com/stdlib-js/assert-is-unity-probability-array/tree/main" -%% click C href "https://github.com/stdlib-js/assert-is-unity-probability-array/tree/production" -%% click D href "https://github.com/stdlib-js/assert-is-unity-probability-array/tree/esm" -%% click E href "https://github.com/stdlib-js/assert-is-unity-probability-array/tree/deno" -%% click F href "https://github.com/stdlib-js/assert-is-unity-probability-array/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/assert/is-unity-probability-array -[production-url]: https://github.com/stdlib-js/assert-is-unity-probability-array/tree/production -[deno-url]: https://github.com/stdlib-js/assert-is-unity-probability-array/tree/deno -[deno-readme]: https://github.com/stdlib-js/assert-is-unity-probability-array/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/assert-is-unity-probability-array/tree/umd -[umd-readme]: https://github.com/stdlib-js/assert-is-unity-probability-array/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/assert-is-unity-probability-array/tree/esm -[esm-readme]: https://github.com/stdlib-js/assert-is-unity-probability-array/blob/esm/README.md \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index c77d01e..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import isUnityProbabilityArray from '../docs/types/index'; -export = isUnityProbabilityArray; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 70d7801..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var f=function(r,i){return function(){return i||r((i={exports:{}}).exports,i),i.exports}};var u=f(function(m,s){ -var n=require('@stdlib/assert-is-typed-array/dist'),l=require('@stdlib/assert-is-array/dist'),o=require('@stdlib/assert-is-number/dist').isPrimitive,a=require('@stdlib/math-base-utils-absolute-difference/dist'),t=require('@stdlib/constants-float64-sqrt-eps/dist');function q(r){var i,e;if(l(r)){for(i=0,e=0;e1||r[e]<0)return!1;i+=r[e]}return a(i,1)<=t}if(n(r)){for(i=0,e=0;e1||r[e]<0)return!1;i+=r[e]}return a(i,1)<=t}return!1}s.exports=q -});var y=u();module.exports=y; -/** @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 387d5ad..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) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isTypedArray = require( '@stdlib/assert-is-typed-array' );\nvar isArray = require( '@stdlib/assert-is-array' );\nvar isNumber = require( '@stdlib/assert-is-number' ).isPrimitive;\nvar absdiff = require( '@stdlib/math-base-utils-absolute-difference' );\nvar FLOAT64_SQRT_EPS = require( '@stdlib/constants-float64-sqrt-eps' );\n\n\n// MAIN //\n\n/**\n* Tests if a value is an array of probabilities that sum to one.\n*\n* @param {*} v - value to test\n* @returns {boolean} boolean indicating if a value is a probability array\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] );\n* // returns true\n*\n* @example\n* var bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) );\n* // returns true\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] );\n* // returns false\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 3.14, 0.0 ] );\n* // returns false\n*/\nfunction isUnityProbabilityArray( v ) {\n\tvar sum;\n\tvar i;\n\tif ( isArray( v ) ) {\n\t\tsum = 0.0;\n\t\tfor ( i = 0; i < v.length; i++ ) {\n\t\t\tif (\n\t\t\t\t!isNumber( v[ i ] ) ||\n\t\t\t\tv[ i ] > 1.0 ||\n\t\t\t\tv[ i ] < 0.0\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tsum += v[ i ];\n\t\t}\n\t\treturn ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS );\n\t}\n\tif ( isTypedArray( v ) ) {\n\t\tsum = 0.0;\n\t\tfor ( i = 0; i < v.length; i++ ) {\n\t\t\tif (\n\t\t\t\tv[ i ] > 1.0 ||\n\t\t\t\tv[ i ] < 0.0\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tsum += v[ i ];\n\t\t}\n\t\treturn ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS );\n\t}\n\treturn false;\n}\n\n\n// EXPORTS //\n\nmodule.exports = isUnityProbabilityArray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Test if a value is an array of probabilities that sum to one.\n*\n* @module @stdlib/assert-is-unity-probability-array\n*\n* @example\n* var isUnityProbabilityArray = require( '@stdlib/assert-is-unity-probability-array' );\n*\n* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] );\n* // returns true\n*\n* bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) );\n* // returns true\n*\n* bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] );\n* // returns false\n*\n* bool = isUnityProbabilityArray( [ 3.14, 0.0 ] );\n* // returns false\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,EAAe,QAAS,+BAAgC,EACxDC,EAAU,QAAS,yBAA0B,EAC7CC,EAAW,QAAS,0BAA2B,EAAE,YACjDC,EAAU,QAAS,6CAA8C,EACjEC,EAAmB,QAAS,oCAAqC,EA2BrE,SAASC,EAAyBC,EAAI,CACrC,IAAIC,EACAC,EACJ,GAAKP,EAASK,CAAE,EAAI,CAEnB,IADAC,EAAM,EACAC,EAAI,EAAGA,EAAIF,EAAE,OAAQE,IAAM,CAChC,GACC,CAACN,EAAUI,EAAGE,CAAE,CAAE,GAClBF,EAAGE,CAAE,EAAI,GACTF,EAAGE,CAAE,EAAI,EAET,MAAO,GAERD,GAAOD,EAAGE,CAAE,CACb,CACA,OAASL,EAASI,EAAK,CAAI,GAAKH,CACjC,CACA,GAAKJ,EAAcM,CAAE,EAAI,CAExB,IADAC,EAAM,EACAC,EAAI,EAAGA,EAAIF,EAAE,OAAQE,IAAM,CAChC,GACCF,EAAGE,CAAE,EAAI,GACTF,EAAGE,CAAE,EAAI,EAET,MAAO,GAERD,GAAOD,EAAGE,CAAE,CACb,CACA,OAASL,EAASI,EAAK,CAAI,GAAKH,CACjC,CACA,MAAO,EACR,CAKAL,EAAO,QAAUM,IC9CjB,IAAII,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isTypedArray", "isArray", "isNumber", "absdiff", "FLOAT64_SQRT_EPS", "isUnityProbabilityArray", "v", "sum", "i", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index a2414be..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,29 +0,0 @@ - -{{alias}}( value ) - Tests if a value is an array of probabilities that sum to one. - - Parameters - ---------- - value: any - Value to test. - - Returns - ------- - bool: boolean - Boolean indicating whether value is an array of probabilities that sum - to one. - - Examples - -------- - > var bool = {{alias}}( [ 0.25, 0.5, 0.25 ] ) - true - > bool = {{alias}}( new {{alias:@stdlib/array/uint8}}( [ 0, 1 ] ) ) - true - > bool = {{alias}}( [ 0.4, 0.4, 0.4 ] ) - false - > bool = {{alias}}( [ 3.14, 0.0 ] ) - false - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 6b41658..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,34 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import isUnityProbabilityArray = require( './index' ); - - -// TESTS // - -// The function returns a boolean... -{ - isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] ); // $ExpectType boolean - isUnityProbabilityArray( [ 2, 3 ] ); // $ExpectType boolean -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - isUnityProbabilityArray(); // $ExpectError - isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ], 123 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index b0b6bbc..0000000 --- a/examples/index.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var Uint8Array = require( '@stdlib/array-uint8' ); -var isUnityProbabilityArray = require( './../lib' ); - -var arr = [ 0.0, 1.0 ]; -console.log( isUnityProbabilityArray( arr ) ); -// => true - -arr = [ 0.5, 0.25, 0.25 ]; -console.log( isUnityProbabilityArray( arr ) ); -// => true - -arr = new Uint8Array( [ 0, 0, 1, 0 ] ); -console.log( isUnityProbabilityArray( arr ) ); -// => true - -arr = [ 0.4, 0.4, 0.4 ]; -console.log( isUnityProbabilityArray( arr ) ); -// => false - -arr = [ 3.14, -1.0 ]; -console.log( isUnityProbabilityArray( arr ) ); -// => false - -console.log( isUnityProbabilityArray( [] ) ); -// => false - -console.log( isUnityProbabilityArray( null ) ); -// => false diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..0a95bd4 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-typed-array@v0.1.0-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array@v0.1.1-esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-number@v0.1.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/math-base-utils-absolute-difference@v0.2.0-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/constants-float64-sqrt-eps@v0.1.1-esm/index.mjs";function n(n){var d,m;if(t(n)){for(d=0,m=0;m1||n[m]<0)return!1;d+=n[m]}return r(d,1)<=i}if(s(n)){for(d=0,m=0;m1||n[m]<0)return!1;d+=n[m]}return r(d,1)<=i}return!1}export{n as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..08904b0 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isTypedArray from '@stdlib/assert-is-typed-array';\nimport isArray from '@stdlib/assert-is-array';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport absdiff from '@stdlib/math-base-utils-absolute-difference';\nimport FLOAT64_SQRT_EPS from '@stdlib/constants-float64-sqrt-eps';\n\n\n// MAIN //\n\n/**\n* Tests if a value is an array of probabilities that sum to one.\n*\n* @param {*} v - value to test\n* @returns {boolean} boolean indicating if a value is a probability array\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] );\n* // returns true\n*\n* @example\n* var bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) );\n* // returns true\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] );\n* // returns false\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 3.14, 0.0 ] );\n* // returns false\n*/\nfunction isUnityProbabilityArray( v ) {\n\tvar sum;\n\tvar i;\n\tif ( isArray( v ) ) {\n\t\tsum = 0.0;\n\t\tfor ( i = 0; i < v.length; i++ ) {\n\t\t\tif (\n\t\t\t\t!isNumber( v[ i ] ) ||\n\t\t\t\tv[ i ] > 1.0 ||\n\t\t\t\tv[ i ] < 0.0\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tsum += v[ i ];\n\t\t}\n\t\treturn ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS );\n\t}\n\tif ( isTypedArray( v ) ) {\n\t\tsum = 0.0;\n\t\tfor ( i = 0; i < v.length; i++ ) {\n\t\t\tif (\n\t\t\t\tv[ i ] > 1.0 ||\n\t\t\t\tv[ i ] < 0.0\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tsum += v[ i ];\n\t\t}\n\t\treturn ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS );\n\t}\n\treturn false;\n}\n\n\n// EXPORTS //\n\nexport default isUnityProbabilityArray;\n"],"names":["isUnityProbabilityArray","v","sum","i","isArray","length","isNumber","absdiff","FLOAT64_SQRT_EPS","isTypedArray"],"mappings":";;ufAqDA,SAASA,EAAyBC,GACjC,IAAIC,EACAC,EACJ,GAAKC,EAASH,GAAM,CAEnB,IADAC,EAAM,EACAC,EAAI,EAAGA,EAAIF,EAAEI,OAAQF,IAAM,CAChC,IACEG,EAAUL,EAAGE,KACdF,EAAGE,GAAM,GACTF,EAAGE,GAAM,EAET,OAAO,EAERD,GAAOD,EAAGE,EACV,CACD,OAASI,EAASL,EAAK,IAASM,CAChC,CACD,GAAKC,EAAcR,GAAM,CAExB,IADAC,EAAM,EACAC,EAAI,EAAGA,EAAIF,EAAEI,OAAQF,IAAM,CAChC,GACCF,EAAGE,GAAM,GACTF,EAAGE,GAAM,EAET,OAAO,EAERD,GAAOD,EAAGE,EACV,CACD,OAASI,EAASL,EAAK,IAASM,CAChC,CACD,OAAO,CACR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 13a67d1..0000000 --- a/lib/index.js +++ /dev/null @@ -1,49 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Test if a value is an array of probabilities that sum to one. -* -* @module @stdlib/assert-is-unity-probability-array -* -* @example -* var isUnityProbabilityArray = require( '@stdlib/assert-is-unity-probability-array' ); -* -* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] ); -* // returns true -* -* bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) ); -* // returns true -* -* bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] ); -* // returns false -* -* bool = isUnityProbabilityArray( [ 3.14, 0.0 ] ); -* // returns false -*/ - -// 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 d0bda40..0000000 --- a/lib/main.js +++ /dev/null @@ -1,90 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -var isArray = require( '@stdlib/assert-is-array' ); -var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var absdiff = require( '@stdlib/math-base-utils-absolute-difference' ); -var FLOAT64_SQRT_EPS = require( '@stdlib/constants-float64-sqrt-eps' ); - - -// MAIN // - -/** -* Tests if a value is an array of probabilities that sum to one. -* -* @param {*} v - value to test -* @returns {boolean} boolean indicating if a value is a probability array -* -* @example -* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] ); -* // returns true -* -* @example -* var bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) ); -* // returns true -* -* @example -* var bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] ); -* // returns false -* -* @example -* var bool = isUnityProbabilityArray( [ 3.14, 0.0 ] ); -* // returns false -*/ -function isUnityProbabilityArray( v ) { - var sum; - var i; - if ( isArray( v ) ) { - sum = 0.0; - for ( i = 0; i < v.length; i++ ) { - if ( - !isNumber( v[ i ] ) || - v[ i ] > 1.0 || - v[ i ] < 0.0 - ) { - return false; - } - sum += v[ i ]; - } - return ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS ); - } - if ( isTypedArray( v ) ) { - sum = 0.0; - for ( i = 0; i < v.length; i++ ) { - if ( - v[ i ] > 1.0 || - v[ i ] < 0.0 - ) { - return false; - } - sum += v[ i ]; - } - return ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS ); - } - return false; -} - - -// EXPORTS // - -module.exports = isUnityProbabilityArray; diff --git a/package.json b/package.json index 55c2c62..660ccd4 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.0", "description": "Test if a value is an array of probabilities that sum to one.", "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" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,47 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-array": "^0.1.1", - "@stdlib/assert-is-number": "^0.1.1", - "@stdlib/assert-is-typed-array": "^0.1.0", - "@stdlib/constants-float64-sqrt-eps": "^0.1.1", - "@stdlib/math-base-utils-absolute-difference": "^0.2.0", - "@stdlib/error-tools-fmtprodmsg": "^0.1.1" - }, - "devDependencies": { - "@stdlib/array-float32": "^0.1.1", - "@stdlib/array-float64": "^0.1.1", - "@stdlib/array-int16": "^0.1.1", - "@stdlib/array-int32": "^0.1.1", - "@stdlib/array-int8": "^0.1.1", - "@stdlib/array-uint16": "^0.1.1", - "@stdlib/array-uint32": "^0.1.1", - "@stdlib/array-uint8": "^0.1.1", - "@stdlib/array-uint8c": "^0.1.1", - "@stdlib/assert-is-boolean": "^0.1.1", - "@stdlib/buffer-from-array": "^0.1.0", - "@stdlib/math-base-special-pow": "^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", - "@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", "stdassert", @@ -105,4 +41,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..4dfa54e --- /dev/null +++ b/stats.html @@ -0,0 +1,6177 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index a0424fb..0000000 --- a/test/test.js +++ /dev/null @@ -1,106 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Int8Array = require( '@stdlib/array-int8' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Float64Array = require( '@stdlib/array-float64' ); -var array2buffer = require( '@stdlib/buffer-from-array' ); -var isUnityProbabilityArray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof isUnityProbabilityArray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns `true` if provided an array of probabilities that sum to one', function test( t ) { - var values; - var i; - - values = [ - new Int8Array( [ 0, 0, 1 ] ), - new Uint8Array( [ 1, 0, 0 ] ), - new Uint8ClampedArray( [ 0, 1 ] ), - new Int16Array( [ 0, 0, 1, 0 ] ), - new Uint16Array( [ 1 ] ), - new Int32Array( [ 1, 0, 0 ] ), - new Uint32Array( [ 0, 1, 0 ] ), - new Float32Array( [ 0.0, 0.5, 0.5 ] ), - new Float64Array( [ 0.25, 0.25, 0.5 ] ), - [ 0.5, 0.25, 0.25 ] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.strictEqual( isUnityProbabilityArray( values[i] ), true, 'returns true when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function allows a difference in sum within floating-point epsilon', function test( t ) { - var bool = isUnityProbabilityArray( [ 0.1, 0.2, 0.1, 0.1, 0.2, 0.2, 0.1 ] ); - t.strictEqual( bool, true, 'returns true' ); - t.end(); -}); - -tape( 'the function returns `false` if not provided an array of probabilities that sum to one', function test( t ) { - var values; - var i; - - values = [ - '10', - '01', - '0.5', - '5', - 5, - NaN, - null, - void 0, - true, - [], - [ 5, null ], - [ 5, '5' ], - [ 1.0, 3.14 ], - [ -1.0, 1.0, 1.0 ], - [ 0.25, 0.33, 0.5 ], - new Float64Array( [ 0.25, 0.33, 0.5 ] ), - new Float64Array( [ 0.25, 1.33, 0.5 ] ), - new Float64Array( [ 0.25, -0.33, 0.5 ] ), - {}, - function noop() {}, - array2buffer( [ 1, 1, 0 ] ) - ]; - - for ( i = 0; i < values.length; i++ ) { - t.strictEqual( isUnityProbabilityArray( values[i] ), false, 'returns false when provided '+values[i] ); - } - t.end(); -}); From db5bf364faf9ba9d61361b551ce934bfa7b033ec Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 14 Feb 2024 13:43:36 +0000 Subject: [PATCH 077/133] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 28e38ce..70f9b42 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,8 @@ "@stdlib/assert-is-number": "^0.2.0", "@stdlib/assert-is-typed-array": "^0.2.0", "@stdlib/constants-float64-sqrt-eps": "^0.2.0", - "@stdlib/math-base-utils-absolute-difference": "^0.3.0" + "@stdlib/math-base-utils-absolute-difference": "^0.3.0", + "@stdlib/error-tools-fmtprodmsg": "^0.2.0" }, "devDependencies": { "@stdlib/array-float32": "^0.1.1", @@ -104,4 +105,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From c03fbc035c37a7fa8229f746ba3f421551b8d388 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 14 Feb 2024 20:49:58 +0000 Subject: [PATCH 078/133] Remove files --- index.d.ts | 48 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6230 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index 63a123d..0000000 --- a/index.d.ts +++ /dev/null @@ -1,48 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/** -* Tests if a value is an array of probabilities that sum to one. -* -* @param v - value to test -* @returns boolean indicating if a value is a probability array -* -* @example -* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] ); -* // returns true -* -* @example -* var bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) ); -* // returns true -* -* @example -* var bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] ); -* // returns false -* -* @example -* var bool = isUnityProbabilityArray( [ 3.14, 0.0 ] ); -* // returns false -*/ -declare function isUnityProbabilityArray( v: any ): v is ArrayLike; - - -// EXPORTS // - -export = isUnityProbabilityArray; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 0a95bd4..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-typed-array@v0.1.0-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array@v0.1.1-esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-number@v0.1.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/math-base-utils-absolute-difference@v0.2.0-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/constants-float64-sqrt-eps@v0.1.1-esm/index.mjs";function n(n){var d,m;if(t(n)){for(d=0,m=0;m1||n[m]<0)return!1;d+=n[m]}return r(d,1)<=i}if(s(n)){for(d=0,m=0;m1||n[m]<0)return!1;d+=n[m]}return r(d,1)<=i}return!1}export{n as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 08904b0..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isTypedArray from '@stdlib/assert-is-typed-array';\nimport isArray from '@stdlib/assert-is-array';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport absdiff from '@stdlib/math-base-utils-absolute-difference';\nimport FLOAT64_SQRT_EPS from '@stdlib/constants-float64-sqrt-eps';\n\n\n// MAIN //\n\n/**\n* Tests if a value is an array of probabilities that sum to one.\n*\n* @param {*} v - value to test\n* @returns {boolean} boolean indicating if a value is a probability array\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] );\n* // returns true\n*\n* @example\n* var bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) );\n* // returns true\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] );\n* // returns false\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 3.14, 0.0 ] );\n* // returns false\n*/\nfunction isUnityProbabilityArray( v ) {\n\tvar sum;\n\tvar i;\n\tif ( isArray( v ) ) {\n\t\tsum = 0.0;\n\t\tfor ( i = 0; i < v.length; i++ ) {\n\t\t\tif (\n\t\t\t\t!isNumber( v[ i ] ) ||\n\t\t\t\tv[ i ] > 1.0 ||\n\t\t\t\tv[ i ] < 0.0\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tsum += v[ i ];\n\t\t}\n\t\treturn ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS );\n\t}\n\tif ( isTypedArray( v ) ) {\n\t\tsum = 0.0;\n\t\tfor ( i = 0; i < v.length; i++ ) {\n\t\t\tif (\n\t\t\t\tv[ i ] > 1.0 ||\n\t\t\t\tv[ i ] < 0.0\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tsum += v[ i ];\n\t\t}\n\t\treturn ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS );\n\t}\n\treturn false;\n}\n\n\n// EXPORTS //\n\nexport default isUnityProbabilityArray;\n"],"names":["isUnityProbabilityArray","v","sum","i","isArray","length","isNumber","absdiff","FLOAT64_SQRT_EPS","isTypedArray"],"mappings":";;ufAqDA,SAASA,EAAyBC,GACjC,IAAIC,EACAC,EACJ,GAAKC,EAASH,GAAM,CAEnB,IADAC,EAAM,EACAC,EAAI,EAAGA,EAAIF,EAAEI,OAAQF,IAAM,CAChC,IACEG,EAAUL,EAAGE,KACdF,EAAGE,GAAM,GACTF,EAAGE,GAAM,EAET,OAAO,EAERD,GAAOD,EAAGE,EACV,CACD,OAASI,EAASL,EAAK,IAASM,CAChC,CACD,GAAKC,EAAcR,GAAM,CAExB,IADAC,EAAM,EACAC,EAAI,EAAGA,EAAIF,EAAEI,OAAQF,IAAM,CAChC,GACCF,EAAGE,GAAM,GACTF,EAAGE,GAAM,EAET,OAAO,EAERD,GAAOD,EAAGE,EACV,CACD,OAASI,EAASL,EAAK,IAASM,CAChC,CACD,OAAO,CACR"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 4dfa54e..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From cde0fc86950d0e49c5217283cacd457c60489a50 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 14 Feb 2024 20:50:27 +0000 Subject: [PATCH 079/133] 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 | 43 +- SECURITY.md | 5 - benchmark/benchmark.js | 103 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 29 - docs/types/test.ts | 34 - examples/index.js | 48 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 49 - lib/main.js | 90 - package.json | 70 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 106 - 42 files changed, 6202 insertions(+), 3828 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 delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/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 75a4c32..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/assert/is-unity-probability-array) 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 5119885..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/assert/is-unity-probability-array) 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 7f62c1a..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: '49 1 * * 1' - - # 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 + + ```
@@ -178,7 +169,7 @@ bool = isUnityProbabilityArray( null ); ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -245,9 +236,9 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/assert/is-probability]: https://github.com/stdlib-js/assert-is-probability +[@stdlib/assert/is-probability]: https://github.com/stdlib-js/assert-is-probability/tree/esm -[@stdlib/assert/is-probability-array]: https://github.com/stdlib-js/assert-is-probability-array +[@stdlib/assert/is-probability-array]: https://github.com/stdlib-js/assert-is-probability-array/tree/esm diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 510a5ed..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,103 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var isUnityProbabilityArray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x; - var i; - - x = []; - for ( i = 0; i < len; i++ ) { - x.push( 1.0/len ); - } - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: we are testing the worst case scenario where a function must scan the entire array before finding a failing value. - x[ len-1 ] = i * 3.14; - bool = isUnityProbabilityArray( x ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( isBoolean( bool ) ) { - b.pass( 'benchmark finished' ); - } else { - b.fail( 'should return a boolean' ); - } - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':len='+len, f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index 5a6810d..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/assert/is-unity-probability-array" -%% click B href "https://github.com/stdlib-js/assert-is-unity-probability-array/tree/main" -%% click C href "https://github.com/stdlib-js/assert-is-unity-probability-array/tree/production" -%% click D href "https://github.com/stdlib-js/assert-is-unity-probability-array/tree/esm" -%% click E href "https://github.com/stdlib-js/assert-is-unity-probability-array/tree/deno" -%% click F href "https://github.com/stdlib-js/assert-is-unity-probability-array/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/assert/is-unity-probability-array -[production-url]: https://github.com/stdlib-js/assert-is-unity-probability-array/tree/production -[deno-url]: https://github.com/stdlib-js/assert-is-unity-probability-array/tree/deno -[deno-readme]: https://github.com/stdlib-js/assert-is-unity-probability-array/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/assert-is-unity-probability-array/tree/umd -[umd-readme]: https://github.com/stdlib-js/assert-is-unity-probability-array/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/assert-is-unity-probability-array/tree/esm -[esm-readme]: https://github.com/stdlib-js/assert-is-unity-probability-array/blob/esm/README.md \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index c77d01e..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import isUnityProbabilityArray from '../docs/types/index'; -export = isUnityProbabilityArray; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 70d7801..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var f=function(r,i){return function(){return i||r((i={exports:{}}).exports,i),i.exports}};var u=f(function(m,s){ -var n=require('@stdlib/assert-is-typed-array/dist'),l=require('@stdlib/assert-is-array/dist'),o=require('@stdlib/assert-is-number/dist').isPrimitive,a=require('@stdlib/math-base-utils-absolute-difference/dist'),t=require('@stdlib/constants-float64-sqrt-eps/dist');function q(r){var i,e;if(l(r)){for(i=0,e=0;e1||r[e]<0)return!1;i+=r[e]}return a(i,1)<=t}if(n(r)){for(i=0,e=0;e1||r[e]<0)return!1;i+=r[e]}return a(i,1)<=t}return!1}s.exports=q -});var y=u();module.exports=y; -/** @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 387d5ad..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) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isTypedArray = require( '@stdlib/assert-is-typed-array' );\nvar isArray = require( '@stdlib/assert-is-array' );\nvar isNumber = require( '@stdlib/assert-is-number' ).isPrimitive;\nvar absdiff = require( '@stdlib/math-base-utils-absolute-difference' );\nvar FLOAT64_SQRT_EPS = require( '@stdlib/constants-float64-sqrt-eps' );\n\n\n// MAIN //\n\n/**\n* Tests if a value is an array of probabilities that sum to one.\n*\n* @param {*} v - value to test\n* @returns {boolean} boolean indicating if a value is a probability array\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] );\n* // returns true\n*\n* @example\n* var bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) );\n* // returns true\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] );\n* // returns false\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 3.14, 0.0 ] );\n* // returns false\n*/\nfunction isUnityProbabilityArray( v ) {\n\tvar sum;\n\tvar i;\n\tif ( isArray( v ) ) {\n\t\tsum = 0.0;\n\t\tfor ( i = 0; i < v.length; i++ ) {\n\t\t\tif (\n\t\t\t\t!isNumber( v[ i ] ) ||\n\t\t\t\tv[ i ] > 1.0 ||\n\t\t\t\tv[ i ] < 0.0\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tsum += v[ i ];\n\t\t}\n\t\treturn ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS );\n\t}\n\tif ( isTypedArray( v ) ) {\n\t\tsum = 0.0;\n\t\tfor ( i = 0; i < v.length; i++ ) {\n\t\t\tif (\n\t\t\t\tv[ i ] > 1.0 ||\n\t\t\t\tv[ i ] < 0.0\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tsum += v[ i ];\n\t\t}\n\t\treturn ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS );\n\t}\n\treturn false;\n}\n\n\n// EXPORTS //\n\nmodule.exports = isUnityProbabilityArray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Test if a value is an array of probabilities that sum to one.\n*\n* @module @stdlib/assert-is-unity-probability-array\n*\n* @example\n* var isUnityProbabilityArray = require( '@stdlib/assert-is-unity-probability-array' );\n*\n* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] );\n* // returns true\n*\n* bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) );\n* // returns true\n*\n* bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] );\n* // returns false\n*\n* bool = isUnityProbabilityArray( [ 3.14, 0.0 ] );\n* // returns false\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,EAAe,QAAS,+BAAgC,EACxDC,EAAU,QAAS,yBAA0B,EAC7CC,EAAW,QAAS,0BAA2B,EAAE,YACjDC,EAAU,QAAS,6CAA8C,EACjEC,EAAmB,QAAS,oCAAqC,EA2BrE,SAASC,EAAyBC,EAAI,CACrC,IAAIC,EACAC,EACJ,GAAKP,EAASK,CAAE,EAAI,CAEnB,IADAC,EAAM,EACAC,EAAI,EAAGA,EAAIF,EAAE,OAAQE,IAAM,CAChC,GACC,CAACN,EAAUI,EAAGE,CAAE,CAAE,GAClBF,EAAGE,CAAE,EAAI,GACTF,EAAGE,CAAE,EAAI,EAET,MAAO,GAERD,GAAOD,EAAGE,CAAE,CACb,CACA,OAASL,EAASI,EAAK,CAAI,GAAKH,CACjC,CACA,GAAKJ,EAAcM,CAAE,EAAI,CAExB,IADAC,EAAM,EACAC,EAAI,EAAGA,EAAIF,EAAE,OAAQE,IAAM,CAChC,GACCF,EAAGE,CAAE,EAAI,GACTF,EAAGE,CAAE,EAAI,EAET,MAAO,GAERD,GAAOD,EAAGE,CAAE,CACb,CACA,OAASL,EAASI,EAAK,CAAI,GAAKH,CACjC,CACA,MAAO,EACR,CAKAL,EAAO,QAAUM,IC9CjB,IAAII,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isTypedArray", "isArray", "isNumber", "absdiff", "FLOAT64_SQRT_EPS", "isUnityProbabilityArray", "v", "sum", "i", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index a2414be..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,29 +0,0 @@ - -{{alias}}( value ) - Tests if a value is an array of probabilities that sum to one. - - Parameters - ---------- - value: any - Value to test. - - Returns - ------- - bool: boolean - Boolean indicating whether value is an array of probabilities that sum - to one. - - Examples - -------- - > var bool = {{alias}}( [ 0.25, 0.5, 0.25 ] ) - true - > bool = {{alias}}( new {{alias:@stdlib/array/uint8}}( [ 0, 1 ] ) ) - true - > bool = {{alias}}( [ 0.4, 0.4, 0.4 ] ) - false - > bool = {{alias}}( [ 3.14, 0.0 ] ) - false - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 6b41658..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,34 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import isUnityProbabilityArray = require( './index' ); - - -// TESTS // - -// The function returns a boolean... -{ - isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] ); // $ExpectType boolean - isUnityProbabilityArray( [ 2, 3 ] ); // $ExpectType boolean -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - isUnityProbabilityArray(); // $ExpectError - isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ], 123 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index b0b6bbc..0000000 --- a/examples/index.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var Uint8Array = require( '@stdlib/array-uint8' ); -var isUnityProbabilityArray = require( './../lib' ); - -var arr = [ 0.0, 1.0 ]; -console.log( isUnityProbabilityArray( arr ) ); -// => true - -arr = [ 0.5, 0.25, 0.25 ]; -console.log( isUnityProbabilityArray( arr ) ); -// => true - -arr = new Uint8Array( [ 0, 0, 1, 0 ] ); -console.log( isUnityProbabilityArray( arr ) ); -// => true - -arr = [ 0.4, 0.4, 0.4 ]; -console.log( isUnityProbabilityArray( arr ) ); -// => false - -arr = [ 3.14, -1.0 ]; -console.log( isUnityProbabilityArray( arr ) ); -// => false - -console.log( isUnityProbabilityArray( [] ) ); -// => false - -console.log( isUnityProbabilityArray( null ) ); -// => false diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..15451c0 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-typed-array@v0.1.0-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array@v0.2.0-esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-number@v0.2.0-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/math-base-utils-absolute-difference@v0.2.0-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/constants-float64-sqrt-eps@v0.2.0-esm/index.mjs";function n(n){var d,m;if(t(n)){for(d=0,m=0;m1||n[m]<0)return!1;d+=n[m]}return r(d,1)<=i}if(s(n)){for(d=0,m=0;m1||n[m]<0)return!1;d+=n[m]}return r(d,1)<=i}return!1}export{n as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..08904b0 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isTypedArray from '@stdlib/assert-is-typed-array';\nimport isArray from '@stdlib/assert-is-array';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport absdiff from '@stdlib/math-base-utils-absolute-difference';\nimport FLOAT64_SQRT_EPS from '@stdlib/constants-float64-sqrt-eps';\n\n\n// MAIN //\n\n/**\n* Tests if a value is an array of probabilities that sum to one.\n*\n* @param {*} v - value to test\n* @returns {boolean} boolean indicating if a value is a probability array\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] );\n* // returns true\n*\n* @example\n* var bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) );\n* // returns true\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] );\n* // returns false\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 3.14, 0.0 ] );\n* // returns false\n*/\nfunction isUnityProbabilityArray( v ) {\n\tvar sum;\n\tvar i;\n\tif ( isArray( v ) ) {\n\t\tsum = 0.0;\n\t\tfor ( i = 0; i < v.length; i++ ) {\n\t\t\tif (\n\t\t\t\t!isNumber( v[ i ] ) ||\n\t\t\t\tv[ i ] > 1.0 ||\n\t\t\t\tv[ i ] < 0.0\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tsum += v[ i ];\n\t\t}\n\t\treturn ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS );\n\t}\n\tif ( isTypedArray( v ) ) {\n\t\tsum = 0.0;\n\t\tfor ( i = 0; i < v.length; i++ ) {\n\t\t\tif (\n\t\t\t\tv[ i ] > 1.0 ||\n\t\t\t\tv[ i ] < 0.0\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tsum += v[ i ];\n\t\t}\n\t\treturn ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS );\n\t}\n\treturn false;\n}\n\n\n// EXPORTS //\n\nexport default isUnityProbabilityArray;\n"],"names":["isUnityProbabilityArray","v","sum","i","isArray","length","isNumber","absdiff","FLOAT64_SQRT_EPS","isTypedArray"],"mappings":";;ufAqDA,SAASA,EAAyBC,GACjC,IAAIC,EACAC,EACJ,GAAKC,EAASH,GAAM,CAEnB,IADAC,EAAM,EACAC,EAAI,EAAGA,EAAIF,EAAEI,OAAQF,IAAM,CAChC,IACEG,EAAUL,EAAGE,KACdF,EAAGE,GAAM,GACTF,EAAGE,GAAM,EAET,OAAO,EAERD,GAAOD,EAAGE,EACV,CACD,OAASI,EAASL,EAAK,IAASM,CAChC,CACD,GAAKC,EAAcR,GAAM,CAExB,IADAC,EAAM,EACAC,EAAI,EAAGA,EAAIF,EAAEI,OAAQF,IAAM,CAChC,GACCF,EAAGE,GAAM,GACTF,EAAGE,GAAM,EAET,OAAO,EAERD,GAAOD,EAAGE,EACV,CACD,OAASI,EAASL,EAAK,IAASM,CAChC,CACD,OAAO,CACR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 13a67d1..0000000 --- a/lib/index.js +++ /dev/null @@ -1,49 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Test if a value is an array of probabilities that sum to one. -* -* @module @stdlib/assert-is-unity-probability-array -* -* @example -* var isUnityProbabilityArray = require( '@stdlib/assert-is-unity-probability-array' ); -* -* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] ); -* // returns true -* -* bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) ); -* // returns true -* -* bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] ); -* // returns false -* -* bool = isUnityProbabilityArray( [ 3.14, 0.0 ] ); -* // returns false -*/ - -// 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 d0bda40..0000000 --- a/lib/main.js +++ /dev/null @@ -1,90 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -var isArray = require( '@stdlib/assert-is-array' ); -var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var absdiff = require( '@stdlib/math-base-utils-absolute-difference' ); -var FLOAT64_SQRT_EPS = require( '@stdlib/constants-float64-sqrt-eps' ); - - -// MAIN // - -/** -* Tests if a value is an array of probabilities that sum to one. -* -* @param {*} v - value to test -* @returns {boolean} boolean indicating if a value is a probability array -* -* @example -* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] ); -* // returns true -* -* @example -* var bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) ); -* // returns true -* -* @example -* var bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] ); -* // returns false -* -* @example -* var bool = isUnityProbabilityArray( [ 3.14, 0.0 ] ); -* // returns false -*/ -function isUnityProbabilityArray( v ) { - var sum; - var i; - if ( isArray( v ) ) { - sum = 0.0; - for ( i = 0; i < v.length; i++ ) { - if ( - !isNumber( v[ i ] ) || - v[ i ] > 1.0 || - v[ i ] < 0.0 - ) { - return false; - } - sum += v[ i ]; - } - return ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS ); - } - if ( isTypedArray( v ) ) { - sum = 0.0; - for ( i = 0; i < v.length; i++ ) { - if ( - v[ i ] > 1.0 || - v[ i ] < 0.0 - ) { - return false; - } - sum += v[ i ]; - } - return ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS ); - } - return false; -} - - -// EXPORTS // - -module.exports = isUnityProbabilityArray; diff --git a/package.json b/package.json index 70f9b42..04d0a96 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.0", "description": "Test if a value is an array of probabilities that sum to one.", "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" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,47 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-array": "^0.2.0", - "@stdlib/assert-is-number": "^0.2.0", - "@stdlib/assert-is-typed-array": "^0.2.0", - "@stdlib/constants-float64-sqrt-eps": "^0.2.0", - "@stdlib/math-base-utils-absolute-difference": "^0.3.0", - "@stdlib/error-tools-fmtprodmsg": "^0.2.0" - }, - "devDependencies": { - "@stdlib/array-float32": "^0.1.1", - "@stdlib/array-float64": "^0.1.1", - "@stdlib/array-int16": "^0.1.1", - "@stdlib/array-int32": "^0.1.1", - "@stdlib/array-int8": "^0.1.1", - "@stdlib/array-uint16": "^0.1.1", - "@stdlib/array-uint32": "^0.1.1", - "@stdlib/array-uint8": "^0.1.1", - "@stdlib/array-uint8c": "^0.1.1", - "@stdlib/assert-is-boolean": "^0.1.1", - "@stdlib/buffer-from-array": "^0.1.0", - "@stdlib/math-base-special-pow": "^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", - "@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", "stdassert", @@ -105,4 +41,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..da6f2e1 --- /dev/null +++ b/stats.html @@ -0,0 +1,6177 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index a0424fb..0000000 --- a/test/test.js +++ /dev/null @@ -1,106 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Int8Array = require( '@stdlib/array-int8' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Float64Array = require( '@stdlib/array-float64' ); -var array2buffer = require( '@stdlib/buffer-from-array' ); -var isUnityProbabilityArray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof isUnityProbabilityArray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns `true` if provided an array of probabilities that sum to one', function test( t ) { - var values; - var i; - - values = [ - new Int8Array( [ 0, 0, 1 ] ), - new Uint8Array( [ 1, 0, 0 ] ), - new Uint8ClampedArray( [ 0, 1 ] ), - new Int16Array( [ 0, 0, 1, 0 ] ), - new Uint16Array( [ 1 ] ), - new Int32Array( [ 1, 0, 0 ] ), - new Uint32Array( [ 0, 1, 0 ] ), - new Float32Array( [ 0.0, 0.5, 0.5 ] ), - new Float64Array( [ 0.25, 0.25, 0.5 ] ), - [ 0.5, 0.25, 0.25 ] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.strictEqual( isUnityProbabilityArray( values[i] ), true, 'returns true when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function allows a difference in sum within floating-point epsilon', function test( t ) { - var bool = isUnityProbabilityArray( [ 0.1, 0.2, 0.1, 0.1, 0.2, 0.2, 0.1 ] ); - t.strictEqual( bool, true, 'returns true' ); - t.end(); -}); - -tape( 'the function returns `false` if not provided an array of probabilities that sum to one', function test( t ) { - var values; - var i; - - values = [ - '10', - '01', - '0.5', - '5', - 5, - NaN, - null, - void 0, - true, - [], - [ 5, null ], - [ 5, '5' ], - [ 1.0, 3.14 ], - [ -1.0, 1.0, 1.0 ], - [ 0.25, 0.33, 0.5 ], - new Float64Array( [ 0.25, 0.33, 0.5 ] ), - new Float64Array( [ 0.25, 1.33, 0.5 ] ), - new Float64Array( [ 0.25, -0.33, 0.5 ] ), - {}, - function noop() {}, - array2buffer( [ 1, 1, 0 ] ) - ]; - - for ( i = 0; i < values.length; i++ ) { - t.strictEqual( isUnityProbabilityArray( values[i] ), false, 'returns false when provided '+values[i] ); - } - t.end(); -}); From 4c5aa0dd85973008a4c52a64933fa7c01532e20d Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 14 Feb 2024 22:07:14 +0000 Subject: [PATCH 080/133] Update README.md for ESM bundle v0.2.0 --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index bbfd35e..1e4a9d6 100644 --- a/README.md +++ b/README.md @@ -42,7 +42,7 @@ limitations under the License. ## Usage ```javascript -import isUnityProbabilityArray from 'https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-unity-probability-array@esm/index.mjs'; +import isUnityProbabilityArray from 'https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-unity-probability-array@v0.2.0-esm/index.mjs'; ``` #### isUnityProbabilityArray( value ) @@ -108,7 +108,7 @@ bool = isUnityProbabilityArray( [ 3.14, 0.0 ] ); - - - - From bd1236c1e6dc834372d31ec751eecb40060f7940 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 25 Feb 2024 05:24:20 +0000 Subject: [PATCH 084/133] 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 | 43 +- SECURITY.md | 5 - benchmark/benchmark.js | 103 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 29 - docs/types/test.ts | 34 - examples/index.js | 48 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 49 - lib/main.js | 90 - package.json | 70 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 106 - 42 files changed, 4867 insertions(+), 3822 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 delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/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 75a4c32..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/assert/is-unity-probability-array) 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 5119885..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/assert/is-unity-probability-array) 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 3b386b0..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: '49 1 * * 1' - - # 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 + + ```
@@ -178,7 +169,7 @@ bool = isUnityProbabilityArray( null ); ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -245,9 +236,9 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/assert/is-probability]: https://github.com/stdlib-js/assert-is-probability +[@stdlib/assert/is-probability]: https://github.com/stdlib-js/assert-is-probability/tree/esm -[@stdlib/assert/is-probability-array]: https://github.com/stdlib-js/assert-is-probability-array +[@stdlib/assert/is-probability-array]: https://github.com/stdlib-js/assert-is-probability-array/tree/esm diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 510a5ed..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,103 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var isUnityProbabilityArray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x; - var i; - - x = []; - for ( i = 0; i < len; i++ ) { - x.push( 1.0/len ); - } - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: we are testing the worst case scenario where a function must scan the entire array before finding a failing value. - x[ len-1 ] = i * 3.14; - bool = isUnityProbabilityArray( x ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( isBoolean( bool ) ) { - b.pass( 'benchmark finished' ); - } else { - b.fail( 'should return a boolean' ); - } - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':len='+len, f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index 5a6810d..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/assert/is-unity-probability-array" -%% click B href "https://github.com/stdlib-js/assert-is-unity-probability-array/tree/main" -%% click C href "https://github.com/stdlib-js/assert-is-unity-probability-array/tree/production" -%% click D href "https://github.com/stdlib-js/assert-is-unity-probability-array/tree/esm" -%% click E href "https://github.com/stdlib-js/assert-is-unity-probability-array/tree/deno" -%% click F href "https://github.com/stdlib-js/assert-is-unity-probability-array/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/assert/is-unity-probability-array -[production-url]: https://github.com/stdlib-js/assert-is-unity-probability-array/tree/production -[deno-url]: https://github.com/stdlib-js/assert-is-unity-probability-array/tree/deno -[deno-readme]: https://github.com/stdlib-js/assert-is-unity-probability-array/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/assert-is-unity-probability-array/tree/umd -[umd-readme]: https://github.com/stdlib-js/assert-is-unity-probability-array/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/assert-is-unity-probability-array/tree/esm -[esm-readme]: https://github.com/stdlib-js/assert-is-unity-probability-array/blob/esm/README.md \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index c77d01e..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import isUnityProbabilityArray from '../docs/types/index'; -export = isUnityProbabilityArray; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 70d7801..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var f=function(r,i){return function(){return i||r((i={exports:{}}).exports,i),i.exports}};var u=f(function(m,s){ -var n=require('@stdlib/assert-is-typed-array/dist'),l=require('@stdlib/assert-is-array/dist'),o=require('@stdlib/assert-is-number/dist').isPrimitive,a=require('@stdlib/math-base-utils-absolute-difference/dist'),t=require('@stdlib/constants-float64-sqrt-eps/dist');function q(r){var i,e;if(l(r)){for(i=0,e=0;e1||r[e]<0)return!1;i+=r[e]}return a(i,1)<=t}if(n(r)){for(i=0,e=0;e1||r[e]<0)return!1;i+=r[e]}return a(i,1)<=t}return!1}s.exports=q -});var y=u();module.exports=y; -/** @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 387d5ad..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) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isTypedArray = require( '@stdlib/assert-is-typed-array' );\nvar isArray = require( '@stdlib/assert-is-array' );\nvar isNumber = require( '@stdlib/assert-is-number' ).isPrimitive;\nvar absdiff = require( '@stdlib/math-base-utils-absolute-difference' );\nvar FLOAT64_SQRT_EPS = require( '@stdlib/constants-float64-sqrt-eps' );\n\n\n// MAIN //\n\n/**\n* Tests if a value is an array of probabilities that sum to one.\n*\n* @param {*} v - value to test\n* @returns {boolean} boolean indicating if a value is a probability array\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] );\n* // returns true\n*\n* @example\n* var bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) );\n* // returns true\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] );\n* // returns false\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 3.14, 0.0 ] );\n* // returns false\n*/\nfunction isUnityProbabilityArray( v ) {\n\tvar sum;\n\tvar i;\n\tif ( isArray( v ) ) {\n\t\tsum = 0.0;\n\t\tfor ( i = 0; i < v.length; i++ ) {\n\t\t\tif (\n\t\t\t\t!isNumber( v[ i ] ) ||\n\t\t\t\tv[ i ] > 1.0 ||\n\t\t\t\tv[ i ] < 0.0\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tsum += v[ i ];\n\t\t}\n\t\treturn ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS );\n\t}\n\tif ( isTypedArray( v ) ) {\n\t\tsum = 0.0;\n\t\tfor ( i = 0; i < v.length; i++ ) {\n\t\t\tif (\n\t\t\t\tv[ i ] > 1.0 ||\n\t\t\t\tv[ i ] < 0.0\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tsum += v[ i ];\n\t\t}\n\t\treturn ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS );\n\t}\n\treturn false;\n}\n\n\n// EXPORTS //\n\nmodule.exports = isUnityProbabilityArray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Test if a value is an array of probabilities that sum to one.\n*\n* @module @stdlib/assert-is-unity-probability-array\n*\n* @example\n* var isUnityProbabilityArray = require( '@stdlib/assert-is-unity-probability-array' );\n*\n* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] );\n* // returns true\n*\n* bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) );\n* // returns true\n*\n* bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] );\n* // returns false\n*\n* bool = isUnityProbabilityArray( [ 3.14, 0.0 ] );\n* // returns false\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,EAAe,QAAS,+BAAgC,EACxDC,EAAU,QAAS,yBAA0B,EAC7CC,EAAW,QAAS,0BAA2B,EAAE,YACjDC,EAAU,QAAS,6CAA8C,EACjEC,EAAmB,QAAS,oCAAqC,EA2BrE,SAASC,EAAyBC,EAAI,CACrC,IAAIC,EACAC,EACJ,GAAKP,EAASK,CAAE,EAAI,CAEnB,IADAC,EAAM,EACAC,EAAI,EAAGA,EAAIF,EAAE,OAAQE,IAAM,CAChC,GACC,CAACN,EAAUI,EAAGE,CAAE,CAAE,GAClBF,EAAGE,CAAE,EAAI,GACTF,EAAGE,CAAE,EAAI,EAET,MAAO,GAERD,GAAOD,EAAGE,CAAE,CACb,CACA,OAASL,EAASI,EAAK,CAAI,GAAKH,CACjC,CACA,GAAKJ,EAAcM,CAAE,EAAI,CAExB,IADAC,EAAM,EACAC,EAAI,EAAGA,EAAIF,EAAE,OAAQE,IAAM,CAChC,GACCF,EAAGE,CAAE,EAAI,GACTF,EAAGE,CAAE,EAAI,EAET,MAAO,GAERD,GAAOD,EAAGE,CAAE,CACb,CACA,OAASL,EAASI,EAAK,CAAI,GAAKH,CACjC,CACA,MAAO,EACR,CAKAL,EAAO,QAAUM,IC9CjB,IAAII,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isTypedArray", "isArray", "isNumber", "absdiff", "FLOAT64_SQRT_EPS", "isUnityProbabilityArray", "v", "sum", "i", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index a2414be..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,29 +0,0 @@ - -{{alias}}( value ) - Tests if a value is an array of probabilities that sum to one. - - Parameters - ---------- - value: any - Value to test. - - Returns - ------- - bool: boolean - Boolean indicating whether value is an array of probabilities that sum - to one. - - Examples - -------- - > var bool = {{alias}}( [ 0.25, 0.5, 0.25 ] ) - true - > bool = {{alias}}( new {{alias:@stdlib/array/uint8}}( [ 0, 1 ] ) ) - true - > bool = {{alias}}( [ 0.4, 0.4, 0.4 ] ) - false - > bool = {{alias}}( [ 3.14, 0.0 ] ) - false - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 6b41658..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,34 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import isUnityProbabilityArray = require( './index' ); - - -// TESTS // - -// The function returns a boolean... -{ - isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] ); // $ExpectType boolean - isUnityProbabilityArray( [ 2, 3 ] ); // $ExpectType boolean -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - isUnityProbabilityArray(); // $ExpectError - isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ], 123 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index b0b6bbc..0000000 --- a/examples/index.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var Uint8Array = require( '@stdlib/array-uint8' ); -var isUnityProbabilityArray = require( './../lib' ); - -var arr = [ 0.0, 1.0 ]; -console.log( isUnityProbabilityArray( arr ) ); -// => true - -arr = [ 0.5, 0.25, 0.25 ]; -console.log( isUnityProbabilityArray( arr ) ); -// => true - -arr = new Uint8Array( [ 0, 0, 1, 0 ] ); -console.log( isUnityProbabilityArray( arr ) ); -// => true - -arr = [ 0.4, 0.4, 0.4 ]; -console.log( isUnityProbabilityArray( arr ) ); -// => false - -arr = [ 3.14, -1.0 ]; -console.log( isUnityProbabilityArray( arr ) ); -// => false - -console.log( isUnityProbabilityArray( [] ) ); -// => false - -console.log( isUnityProbabilityArray( null ) ); -// => false diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..0441598 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-typed-array@v0.2.0-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array@v0.2.1-esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-number@v0.2.0-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/math-base-utils-absolute-difference@v0.3.1-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/constants-float64-sqrt-eps@v0.2.1-esm/index.mjs";function n(n){var d,m;if(t(n)){for(d=0,m=0;m1||n[m]<0)return!1;d+=n[m]}return r(d,1)<=i}if(s(n)){for(d=0,m=0;m1||n[m]<0)return!1;d+=n[m]}return r(d,1)<=i}return!1}export{n as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..08904b0 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isTypedArray from '@stdlib/assert-is-typed-array';\nimport isArray from '@stdlib/assert-is-array';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport absdiff from '@stdlib/math-base-utils-absolute-difference';\nimport FLOAT64_SQRT_EPS from '@stdlib/constants-float64-sqrt-eps';\n\n\n// MAIN //\n\n/**\n* Tests if a value is an array of probabilities that sum to one.\n*\n* @param {*} v - value to test\n* @returns {boolean} boolean indicating if a value is a probability array\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] );\n* // returns true\n*\n* @example\n* var bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) );\n* // returns true\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] );\n* // returns false\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 3.14, 0.0 ] );\n* // returns false\n*/\nfunction isUnityProbabilityArray( v ) {\n\tvar sum;\n\tvar i;\n\tif ( isArray( v ) ) {\n\t\tsum = 0.0;\n\t\tfor ( i = 0; i < v.length; i++ ) {\n\t\t\tif (\n\t\t\t\t!isNumber( v[ i ] ) ||\n\t\t\t\tv[ i ] > 1.0 ||\n\t\t\t\tv[ i ] < 0.0\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tsum += v[ i ];\n\t\t}\n\t\treturn ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS );\n\t}\n\tif ( isTypedArray( v ) ) {\n\t\tsum = 0.0;\n\t\tfor ( i = 0; i < v.length; i++ ) {\n\t\t\tif (\n\t\t\t\tv[ i ] > 1.0 ||\n\t\t\t\tv[ i ] < 0.0\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tsum += v[ i ];\n\t\t}\n\t\treturn ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS );\n\t}\n\treturn false;\n}\n\n\n// EXPORTS //\n\nexport default isUnityProbabilityArray;\n"],"names":["isUnityProbabilityArray","v","sum","i","isArray","length","isNumber","absdiff","FLOAT64_SQRT_EPS","isTypedArray"],"mappings":";;ufAqDA,SAASA,EAAyBC,GACjC,IAAIC,EACAC,EACJ,GAAKC,EAASH,GAAM,CAEnB,IADAC,EAAM,EACAC,EAAI,EAAGA,EAAIF,EAAEI,OAAQF,IAAM,CAChC,IACEG,EAAUL,EAAGE,KACdF,EAAGE,GAAM,GACTF,EAAGE,GAAM,EAET,OAAO,EAERD,GAAOD,EAAGE,EACV,CACD,OAASI,EAASL,EAAK,IAASM,CAChC,CACD,GAAKC,EAAcR,GAAM,CAExB,IADAC,EAAM,EACAC,EAAI,EAAGA,EAAIF,EAAEI,OAAQF,IAAM,CAChC,GACCF,EAAGE,GAAM,GACTF,EAAGE,GAAM,EAET,OAAO,EAERD,GAAOD,EAAGE,EACV,CACD,OAASI,EAASL,EAAK,IAASM,CAChC,CACD,OAAO,CACR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 13a67d1..0000000 --- a/lib/index.js +++ /dev/null @@ -1,49 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Test if a value is an array of probabilities that sum to one. -* -* @module @stdlib/assert-is-unity-probability-array -* -* @example -* var isUnityProbabilityArray = require( '@stdlib/assert-is-unity-probability-array' ); -* -* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] ); -* // returns true -* -* bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) ); -* // returns true -* -* bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] ); -* // returns false -* -* bool = isUnityProbabilityArray( [ 3.14, 0.0 ] ); -* // returns false -*/ - -// 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 d0bda40..0000000 --- a/lib/main.js +++ /dev/null @@ -1,90 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -var isArray = require( '@stdlib/assert-is-array' ); -var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var absdiff = require( '@stdlib/math-base-utils-absolute-difference' ); -var FLOAT64_SQRT_EPS = require( '@stdlib/constants-float64-sqrt-eps' ); - - -// MAIN // - -/** -* Tests if a value is an array of probabilities that sum to one. -* -* @param {*} v - value to test -* @returns {boolean} boolean indicating if a value is a probability array -* -* @example -* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] ); -* // returns true -* -* @example -* var bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) ); -* // returns true -* -* @example -* var bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] ); -* // returns false -* -* @example -* var bool = isUnityProbabilityArray( [ 3.14, 0.0 ] ); -* // returns false -*/ -function isUnityProbabilityArray( v ) { - var sum; - var i; - if ( isArray( v ) ) { - sum = 0.0; - for ( i = 0; i < v.length; i++ ) { - if ( - !isNumber( v[ i ] ) || - v[ i ] > 1.0 || - v[ i ] < 0.0 - ) { - return false; - } - sum += v[ i ]; - } - return ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS ); - } - if ( isTypedArray( v ) ) { - sum = 0.0; - for ( i = 0; i < v.length; i++ ) { - if ( - v[ i ] > 1.0 || - v[ i ] < 0.0 - ) { - return false; - } - sum += v[ i ]; - } - return ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS ); - } - return false; -} - - -// EXPORTS // - -module.exports = isUnityProbabilityArray; diff --git a/package.json b/package.json index e1f2917..7b64e4b 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.1", "description": "Test if a value is an array of probabilities that sum to one.", "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" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,47 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-array": "^0.2.1", - "@stdlib/assert-is-number": "^0.2.1", - "@stdlib/assert-is-typed-array": "^0.2.1", - "@stdlib/constants-float64-sqrt-eps": "^0.2.1", - "@stdlib/math-base-utils-absolute-difference": "^0.3.1", - "@stdlib/error-tools-fmtprodmsg": "^0.2.1" - }, - "devDependencies": { - "@stdlib/array-float32": "^0.2.1", - "@stdlib/array-float64": "^0.2.1", - "@stdlib/array-int16": "^0.2.1", - "@stdlib/array-int32": "^0.2.1", - "@stdlib/array-int8": "^0.2.1", - "@stdlib/array-uint16": "^0.2.1", - "@stdlib/array-uint32": "^0.2.1", - "@stdlib/array-uint8": "^0.2.1", - "@stdlib/array-uint8c": "^0.2.1", - "@stdlib/assert-is-boolean": "^0.2.1", - "@stdlib/buffer-from-array": "^0.2.1", - "@stdlib/math-base-special-pow": "^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.1" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdassert", @@ -105,4 +41,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..5651ed7 --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index a0424fb..0000000 --- a/test/test.js +++ /dev/null @@ -1,106 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Int8Array = require( '@stdlib/array-int8' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Float64Array = require( '@stdlib/array-float64' ); -var array2buffer = require( '@stdlib/buffer-from-array' ); -var isUnityProbabilityArray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof isUnityProbabilityArray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns `true` if provided an array of probabilities that sum to one', function test( t ) { - var values; - var i; - - values = [ - new Int8Array( [ 0, 0, 1 ] ), - new Uint8Array( [ 1, 0, 0 ] ), - new Uint8ClampedArray( [ 0, 1 ] ), - new Int16Array( [ 0, 0, 1, 0 ] ), - new Uint16Array( [ 1 ] ), - new Int32Array( [ 1, 0, 0 ] ), - new Uint32Array( [ 0, 1, 0 ] ), - new Float32Array( [ 0.0, 0.5, 0.5 ] ), - new Float64Array( [ 0.25, 0.25, 0.5 ] ), - [ 0.5, 0.25, 0.25 ] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.strictEqual( isUnityProbabilityArray( values[i] ), true, 'returns true when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function allows a difference in sum within floating-point epsilon', function test( t ) { - var bool = isUnityProbabilityArray( [ 0.1, 0.2, 0.1, 0.1, 0.2, 0.2, 0.1 ] ); - t.strictEqual( bool, true, 'returns true' ); - t.end(); -}); - -tape( 'the function returns `false` if not provided an array of probabilities that sum to one', function test( t ) { - var values; - var i; - - values = [ - '10', - '01', - '0.5', - '5', - 5, - NaN, - null, - void 0, - true, - [], - [ 5, null ], - [ 5, '5' ], - [ 1.0, 3.14 ], - [ -1.0, 1.0, 1.0 ], - [ 0.25, 0.33, 0.5 ], - new Float64Array( [ 0.25, 0.33, 0.5 ] ), - new Float64Array( [ 0.25, 1.33, 0.5 ] ), - new Float64Array( [ 0.25, -0.33, 0.5 ] ), - {}, - function noop() {}, - array2buffer( [ 1, 1, 0 ] ) - ]; - - for ( i = 0; i < values.length; i++ ) { - t.strictEqual( isUnityProbabilityArray( values[i] ), false, 'returns false when provided '+values[i] ); - } - t.end(); -}); From 593f852e271496e6e434f15ddc555329bdd065fc Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 25 Feb 2024 07:21:19 +0000 Subject: [PATCH 085/133] Update README.md for ESM bundle v0.2.1 --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 10c9951..749c5a3 100644 --- a/README.md +++ b/README.md @@ -42,7 +42,7 @@ limitations under the License. ## Usage ```javascript -import isUnityProbabilityArray from 'https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-unity-probability-array@esm/index.mjs'; +import isUnityProbabilityArray from 'https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-unity-probability-array@v0.2.1-esm/index.mjs'; ``` #### isUnityProbabilityArray( value ) @@ -108,7 +108,7 @@ bool = isUnityProbabilityArray( [ 3.14, 0.0 ] ); - - - - From 009be619fa83094420365ad9926fca26523be5d5 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Mar 2024 11:47:33 +0000 Subject: [PATCH 089/133] 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 | 43 +- SECURITY.md | 5 - benchmark/benchmark.js | 103 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 29 - docs/types/test.ts | 34 - examples/index.js | 48 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 49 - lib/main.js | 90 - package.json | 70 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 106 - 43 files changed, 4867 insertions(+), 3824 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 delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/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 e19d475..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-03-01T04:41:27.631Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 75a4c32..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/assert/is-unity-probability-array) 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 5119885..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/assert/is-unity-probability-array) 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 3b386b0..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: '49 1 * * 1' - - # 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 + + ```
@@ -178,7 +169,7 @@ bool = isUnityProbabilityArray( null ); ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -245,9 +236,9 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/assert/is-probability]: https://github.com/stdlib-js/assert-is-probability +[@stdlib/assert/is-probability]: https://github.com/stdlib-js/assert-is-probability/tree/esm -[@stdlib/assert/is-probability-array]: https://github.com/stdlib-js/assert-is-probability-array +[@stdlib/assert/is-probability-array]: https://github.com/stdlib-js/assert-is-probability-array/tree/esm diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 510a5ed..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,103 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var isUnityProbabilityArray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x; - var i; - - x = []; - for ( i = 0; i < len; i++ ) { - x.push( 1.0/len ); - } - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: we are testing the worst case scenario where a function must scan the entire array before finding a failing value. - x[ len-1 ] = i * 3.14; - bool = isUnityProbabilityArray( x ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( isBoolean( bool ) ) { - b.pass( 'benchmark finished' ); - } else { - b.fail( 'should return a boolean' ); - } - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':len='+len, f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index 5a6810d..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/assert/is-unity-probability-array" -%% click B href "https://github.com/stdlib-js/assert-is-unity-probability-array/tree/main" -%% click C href "https://github.com/stdlib-js/assert-is-unity-probability-array/tree/production" -%% click D href "https://github.com/stdlib-js/assert-is-unity-probability-array/tree/esm" -%% click E href "https://github.com/stdlib-js/assert-is-unity-probability-array/tree/deno" -%% click F href "https://github.com/stdlib-js/assert-is-unity-probability-array/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/assert/is-unity-probability-array -[production-url]: https://github.com/stdlib-js/assert-is-unity-probability-array/tree/production -[deno-url]: https://github.com/stdlib-js/assert-is-unity-probability-array/tree/deno -[deno-readme]: https://github.com/stdlib-js/assert-is-unity-probability-array/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/assert-is-unity-probability-array/tree/umd -[umd-readme]: https://github.com/stdlib-js/assert-is-unity-probability-array/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/assert-is-unity-probability-array/tree/esm -[esm-readme]: https://github.com/stdlib-js/assert-is-unity-probability-array/blob/esm/README.md \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index c77d01e..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import isUnityProbabilityArray from '../docs/types/index'; -export = isUnityProbabilityArray; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 70d7801..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var f=function(r,i){return function(){return i||r((i={exports:{}}).exports,i),i.exports}};var u=f(function(m,s){ -var n=require('@stdlib/assert-is-typed-array/dist'),l=require('@stdlib/assert-is-array/dist'),o=require('@stdlib/assert-is-number/dist').isPrimitive,a=require('@stdlib/math-base-utils-absolute-difference/dist'),t=require('@stdlib/constants-float64-sqrt-eps/dist');function q(r){var i,e;if(l(r)){for(i=0,e=0;e1||r[e]<0)return!1;i+=r[e]}return a(i,1)<=t}if(n(r)){for(i=0,e=0;e1||r[e]<0)return!1;i+=r[e]}return a(i,1)<=t}return!1}s.exports=q -});var y=u();module.exports=y; -/** @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 387d5ad..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) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isTypedArray = require( '@stdlib/assert-is-typed-array' );\nvar isArray = require( '@stdlib/assert-is-array' );\nvar isNumber = require( '@stdlib/assert-is-number' ).isPrimitive;\nvar absdiff = require( '@stdlib/math-base-utils-absolute-difference' );\nvar FLOAT64_SQRT_EPS = require( '@stdlib/constants-float64-sqrt-eps' );\n\n\n// MAIN //\n\n/**\n* Tests if a value is an array of probabilities that sum to one.\n*\n* @param {*} v - value to test\n* @returns {boolean} boolean indicating if a value is a probability array\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] );\n* // returns true\n*\n* @example\n* var bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) );\n* // returns true\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] );\n* // returns false\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 3.14, 0.0 ] );\n* // returns false\n*/\nfunction isUnityProbabilityArray( v ) {\n\tvar sum;\n\tvar i;\n\tif ( isArray( v ) ) {\n\t\tsum = 0.0;\n\t\tfor ( i = 0; i < v.length; i++ ) {\n\t\t\tif (\n\t\t\t\t!isNumber( v[ i ] ) ||\n\t\t\t\tv[ i ] > 1.0 ||\n\t\t\t\tv[ i ] < 0.0\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tsum += v[ i ];\n\t\t}\n\t\treturn ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS );\n\t}\n\tif ( isTypedArray( v ) ) {\n\t\tsum = 0.0;\n\t\tfor ( i = 0; i < v.length; i++ ) {\n\t\t\tif (\n\t\t\t\tv[ i ] > 1.0 ||\n\t\t\t\tv[ i ] < 0.0\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tsum += v[ i ];\n\t\t}\n\t\treturn ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS );\n\t}\n\treturn false;\n}\n\n\n// EXPORTS //\n\nmodule.exports = isUnityProbabilityArray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Test if a value is an array of probabilities that sum to one.\n*\n* @module @stdlib/assert-is-unity-probability-array\n*\n* @example\n* var isUnityProbabilityArray = require( '@stdlib/assert-is-unity-probability-array' );\n*\n* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] );\n* // returns true\n*\n* bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) );\n* // returns true\n*\n* bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] );\n* // returns false\n*\n* bool = isUnityProbabilityArray( [ 3.14, 0.0 ] );\n* // returns false\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,EAAe,QAAS,+BAAgC,EACxDC,EAAU,QAAS,yBAA0B,EAC7CC,EAAW,QAAS,0BAA2B,EAAE,YACjDC,EAAU,QAAS,6CAA8C,EACjEC,EAAmB,QAAS,oCAAqC,EA2BrE,SAASC,EAAyBC,EAAI,CACrC,IAAIC,EACAC,EACJ,GAAKP,EAASK,CAAE,EAAI,CAEnB,IADAC,EAAM,EACAC,EAAI,EAAGA,EAAIF,EAAE,OAAQE,IAAM,CAChC,GACC,CAACN,EAAUI,EAAGE,CAAE,CAAE,GAClBF,EAAGE,CAAE,EAAI,GACTF,EAAGE,CAAE,EAAI,EAET,MAAO,GAERD,GAAOD,EAAGE,CAAE,CACb,CACA,OAASL,EAASI,EAAK,CAAI,GAAKH,CACjC,CACA,GAAKJ,EAAcM,CAAE,EAAI,CAExB,IADAC,EAAM,EACAC,EAAI,EAAGA,EAAIF,EAAE,OAAQE,IAAM,CAChC,GACCF,EAAGE,CAAE,EAAI,GACTF,EAAGE,CAAE,EAAI,EAET,MAAO,GAERD,GAAOD,EAAGE,CAAE,CACb,CACA,OAASL,EAASI,EAAK,CAAI,GAAKH,CACjC,CACA,MAAO,EACR,CAKAL,EAAO,QAAUM,IC9CjB,IAAII,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isTypedArray", "isArray", "isNumber", "absdiff", "FLOAT64_SQRT_EPS", "isUnityProbabilityArray", "v", "sum", "i", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index a2414be..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,29 +0,0 @@ - -{{alias}}( value ) - Tests if a value is an array of probabilities that sum to one. - - Parameters - ---------- - value: any - Value to test. - - Returns - ------- - bool: boolean - Boolean indicating whether value is an array of probabilities that sum - to one. - - Examples - -------- - > var bool = {{alias}}( [ 0.25, 0.5, 0.25 ] ) - true - > bool = {{alias}}( new {{alias:@stdlib/array/uint8}}( [ 0, 1 ] ) ) - true - > bool = {{alias}}( [ 0.4, 0.4, 0.4 ] ) - false - > bool = {{alias}}( [ 3.14, 0.0 ] ) - false - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 6b41658..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,34 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import isUnityProbabilityArray = require( './index' ); - - -// TESTS // - -// The function returns a boolean... -{ - isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] ); // $ExpectType boolean - isUnityProbabilityArray( [ 2, 3 ] ); // $ExpectType boolean -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - isUnityProbabilityArray(); // $ExpectError - isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ], 123 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index b0b6bbc..0000000 --- a/examples/index.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var Uint8Array = require( '@stdlib/array-uint8' ); -var isUnityProbabilityArray = require( './../lib' ); - -var arr = [ 0.0, 1.0 ]; -console.log( isUnityProbabilityArray( arr ) ); -// => true - -arr = [ 0.5, 0.25, 0.25 ]; -console.log( isUnityProbabilityArray( arr ) ); -// => true - -arr = new Uint8Array( [ 0, 0, 1, 0 ] ); -console.log( isUnityProbabilityArray( arr ) ); -// => true - -arr = [ 0.4, 0.4, 0.4 ]; -console.log( isUnityProbabilityArray( arr ) ); -// => false - -arr = [ 3.14, -1.0 ]; -console.log( isUnityProbabilityArray( arr ) ); -// => false - -console.log( isUnityProbabilityArray( [] ) ); -// => false - -console.log( isUnityProbabilityArray( null ) ); -// => false diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..01aa353 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-typed-array@v0.2.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array@v0.2.1-esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-number@v0.2.0-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/math-base-utils-absolute-difference@v0.3.1-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/constants-float64-sqrt-eps@v0.2.1-esm/index.mjs";function n(n){var d,m;if(t(n)){for(d=0,m=0;m1||n[m]<0)return!1;d+=n[m]}return r(d,1)<=i}if(s(n)){for(d=0,m=0;m1||n[m]<0)return!1;d+=n[m]}return r(d,1)<=i}return!1}export{n as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..08904b0 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isTypedArray from '@stdlib/assert-is-typed-array';\nimport isArray from '@stdlib/assert-is-array';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport absdiff from '@stdlib/math-base-utils-absolute-difference';\nimport FLOAT64_SQRT_EPS from '@stdlib/constants-float64-sqrt-eps';\n\n\n// MAIN //\n\n/**\n* Tests if a value is an array of probabilities that sum to one.\n*\n* @param {*} v - value to test\n* @returns {boolean} boolean indicating if a value is a probability array\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] );\n* // returns true\n*\n* @example\n* var bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) );\n* // returns true\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] );\n* // returns false\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 3.14, 0.0 ] );\n* // returns false\n*/\nfunction isUnityProbabilityArray( v ) {\n\tvar sum;\n\tvar i;\n\tif ( isArray( v ) ) {\n\t\tsum = 0.0;\n\t\tfor ( i = 0; i < v.length; i++ ) {\n\t\t\tif (\n\t\t\t\t!isNumber( v[ i ] ) ||\n\t\t\t\tv[ i ] > 1.0 ||\n\t\t\t\tv[ i ] < 0.0\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tsum += v[ i ];\n\t\t}\n\t\treturn ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS );\n\t}\n\tif ( isTypedArray( v ) ) {\n\t\tsum = 0.0;\n\t\tfor ( i = 0; i < v.length; i++ ) {\n\t\t\tif (\n\t\t\t\tv[ i ] > 1.0 ||\n\t\t\t\tv[ i ] < 0.0\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tsum += v[ i ];\n\t\t}\n\t\treturn ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS );\n\t}\n\treturn false;\n}\n\n\n// EXPORTS //\n\nexport default isUnityProbabilityArray;\n"],"names":["isUnityProbabilityArray","v","sum","i","isArray","length","isNumber","absdiff","FLOAT64_SQRT_EPS","isTypedArray"],"mappings":";;ufAqDA,SAASA,EAAyBC,GACjC,IAAIC,EACAC,EACJ,GAAKC,EAASH,GAAM,CAEnB,IADAC,EAAM,EACAC,EAAI,EAAGA,EAAIF,EAAEI,OAAQF,IAAM,CAChC,IACEG,EAAUL,EAAGE,KACdF,EAAGE,GAAM,GACTF,EAAGE,GAAM,EAET,OAAO,EAERD,GAAOD,EAAGE,EACV,CACD,OAASI,EAASL,EAAK,IAASM,CAChC,CACD,GAAKC,EAAcR,GAAM,CAExB,IADAC,EAAM,EACAC,EAAI,EAAGA,EAAIF,EAAEI,OAAQF,IAAM,CAChC,GACCF,EAAGE,GAAM,GACTF,EAAGE,GAAM,EAET,OAAO,EAERD,GAAOD,EAAGE,EACV,CACD,OAASI,EAASL,EAAK,IAASM,CAChC,CACD,OAAO,CACR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 13a67d1..0000000 --- a/lib/index.js +++ /dev/null @@ -1,49 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Test if a value is an array of probabilities that sum to one. -* -* @module @stdlib/assert-is-unity-probability-array -* -* @example -* var isUnityProbabilityArray = require( '@stdlib/assert-is-unity-probability-array' ); -* -* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] ); -* // returns true -* -* bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) ); -* // returns true -* -* bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] ); -* // returns false -* -* bool = isUnityProbabilityArray( [ 3.14, 0.0 ] ); -* // returns false -*/ - -// 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 d0bda40..0000000 --- a/lib/main.js +++ /dev/null @@ -1,90 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -var isArray = require( '@stdlib/assert-is-array' ); -var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var absdiff = require( '@stdlib/math-base-utils-absolute-difference' ); -var FLOAT64_SQRT_EPS = require( '@stdlib/constants-float64-sqrt-eps' ); - - -// MAIN // - -/** -* Tests if a value is an array of probabilities that sum to one. -* -* @param {*} v - value to test -* @returns {boolean} boolean indicating if a value is a probability array -* -* @example -* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] ); -* // returns true -* -* @example -* var bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) ); -* // returns true -* -* @example -* var bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] ); -* // returns false -* -* @example -* var bool = isUnityProbabilityArray( [ 3.14, 0.0 ] ); -* // returns false -*/ -function isUnityProbabilityArray( v ) { - var sum; - var i; - if ( isArray( v ) ) { - sum = 0.0; - for ( i = 0; i < v.length; i++ ) { - if ( - !isNumber( v[ i ] ) || - v[ i ] > 1.0 || - v[ i ] < 0.0 - ) { - return false; - } - sum += v[ i ]; - } - return ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS ); - } - if ( isTypedArray( v ) ) { - sum = 0.0; - for ( i = 0; i < v.length; i++ ) { - if ( - v[ i ] > 1.0 || - v[ i ] < 0.0 - ) { - return false; - } - sum += v[ i ]; - } - return ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS ); - } - return false; -} - - -// EXPORTS // - -module.exports = isUnityProbabilityArray; diff --git a/package.json b/package.json index e94508b..7b64e4b 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.1", "description": "Test if a value is an array of probabilities that sum to one.", "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" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,47 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-array": "^0.2.1", - "@stdlib/assert-is-number": "^0.2.1", - "@stdlib/assert-is-typed-array": "^0.2.1", - "@stdlib/constants-float64-sqrt-eps": "^0.2.1", - "@stdlib/math-base-utils-absolute-difference": "^0.3.1", - "@stdlib/error-tools-fmtprodmsg": "^0.2.1" - }, - "devDependencies": { - "@stdlib/array-float32": "^0.2.1", - "@stdlib/array-float64": "^0.2.1", - "@stdlib/array-int16": "^0.2.1", - "@stdlib/array-int32": "^0.2.1", - "@stdlib/array-int8": "^0.2.1", - "@stdlib/array-uint16": "^0.2.1", - "@stdlib/array-uint32": "^0.2.1", - "@stdlib/array-uint8": "^0.2.1", - "@stdlib/array-uint8c": "^0.2.1", - "@stdlib/assert-is-boolean": "^0.2.1", - "@stdlib/buffer-from-array": "^0.2.1", - "@stdlib/math-base-special-pow": "^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", "stdassert", @@ -105,4 +41,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..3fed9bd --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index a0424fb..0000000 --- a/test/test.js +++ /dev/null @@ -1,106 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Int8Array = require( '@stdlib/array-int8' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Float64Array = require( '@stdlib/array-float64' ); -var array2buffer = require( '@stdlib/buffer-from-array' ); -var isUnityProbabilityArray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof isUnityProbabilityArray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns `true` if provided an array of probabilities that sum to one', function test( t ) { - var values; - var i; - - values = [ - new Int8Array( [ 0, 0, 1 ] ), - new Uint8Array( [ 1, 0, 0 ] ), - new Uint8ClampedArray( [ 0, 1 ] ), - new Int16Array( [ 0, 0, 1, 0 ] ), - new Uint16Array( [ 1 ] ), - new Int32Array( [ 1, 0, 0 ] ), - new Uint32Array( [ 0, 1, 0 ] ), - new Float32Array( [ 0.0, 0.5, 0.5 ] ), - new Float64Array( [ 0.25, 0.25, 0.5 ] ), - [ 0.5, 0.25, 0.25 ] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.strictEqual( isUnityProbabilityArray( values[i] ), true, 'returns true when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function allows a difference in sum within floating-point epsilon', function test( t ) { - var bool = isUnityProbabilityArray( [ 0.1, 0.2, 0.1, 0.1, 0.2, 0.2, 0.1 ] ); - t.strictEqual( bool, true, 'returns true' ); - t.end(); -}); - -tape( 'the function returns `false` if not provided an array of probabilities that sum to one', function test( t ) { - var values; - var i; - - values = [ - '10', - '01', - '0.5', - '5', - 5, - NaN, - null, - void 0, - true, - [], - [ 5, null ], - [ 5, '5' ], - [ 1.0, 3.14 ], - [ -1.0, 1.0, 1.0 ], - [ 0.25, 0.33, 0.5 ], - new Float64Array( [ 0.25, 0.33, 0.5 ] ), - new Float64Array( [ 0.25, 1.33, 0.5 ] ), - new Float64Array( [ 0.25, -0.33, 0.5 ] ), - {}, - function noop() {}, - array2buffer( [ 1, 1, 0 ] ) - ]; - - for ( i = 0; i < values.length; i++ ) { - t.strictEqual( isUnityProbabilityArray( values[i] ), false, 'returns false when provided '+values[i] ); - } - t.end(); -}); From 2d3243d7cc1aae98bec6446ac11f3a72b686a9b5 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Apr 2024 05:50:51 +0000 Subject: [PATCH 090/133] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 874e8e2..e94508b 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,8 @@ "@stdlib/assert-is-number": "^0.2.1", "@stdlib/assert-is-typed-array": "^0.2.1", "@stdlib/constants-float64-sqrt-eps": "^0.2.1", - "@stdlib/math-base-utils-absolute-difference": "^0.3.1" + "@stdlib/math-base-utils-absolute-difference": "^0.3.1", + "@stdlib/error-tools-fmtprodmsg": "^0.2.1" }, "devDependencies": { "@stdlib/array-float32": "^0.2.1", @@ -104,4 +105,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 63b483be324acf52a9314420f5a230f49fe02c62 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Apr 2024 10:57:20 +0000 Subject: [PATCH 091/133] Remove files --- index.d.ts | 48 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4895 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index 63a123d..0000000 --- a/index.d.ts +++ /dev/null @@ -1,48 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/** -* Tests if a value is an array of probabilities that sum to one. -* -* @param v - value to test -* @returns boolean indicating if a value is a probability array -* -* @example -* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] ); -* // returns true -* -* @example -* var bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) ); -* // returns true -* -* @example -* var bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] ); -* // returns false -* -* @example -* var bool = isUnityProbabilityArray( [ 3.14, 0.0 ] ); -* // returns false -*/ -declare function isUnityProbabilityArray( v: any ): v is ArrayLike; - - -// EXPORTS // - -export = isUnityProbabilityArray; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 01aa353..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-typed-array@v0.2.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array@v0.2.1-esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-number@v0.2.0-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/math-base-utils-absolute-difference@v0.3.1-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/constants-float64-sqrt-eps@v0.2.1-esm/index.mjs";function n(n){var d,m;if(t(n)){for(d=0,m=0;m1||n[m]<0)return!1;d+=n[m]}return r(d,1)<=i}if(s(n)){for(d=0,m=0;m1||n[m]<0)return!1;d+=n[m]}return r(d,1)<=i}return!1}export{n as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 08904b0..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isTypedArray from '@stdlib/assert-is-typed-array';\nimport isArray from '@stdlib/assert-is-array';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport absdiff from '@stdlib/math-base-utils-absolute-difference';\nimport FLOAT64_SQRT_EPS from '@stdlib/constants-float64-sqrt-eps';\n\n\n// MAIN //\n\n/**\n* Tests if a value is an array of probabilities that sum to one.\n*\n* @param {*} v - value to test\n* @returns {boolean} boolean indicating if a value is a probability array\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] );\n* // returns true\n*\n* @example\n* var bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) );\n* // returns true\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] );\n* // returns false\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 3.14, 0.0 ] );\n* // returns false\n*/\nfunction isUnityProbabilityArray( v ) {\n\tvar sum;\n\tvar i;\n\tif ( isArray( v ) ) {\n\t\tsum = 0.0;\n\t\tfor ( i = 0; i < v.length; i++ ) {\n\t\t\tif (\n\t\t\t\t!isNumber( v[ i ] ) ||\n\t\t\t\tv[ i ] > 1.0 ||\n\t\t\t\tv[ i ] < 0.0\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tsum += v[ i ];\n\t\t}\n\t\treturn ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS );\n\t}\n\tif ( isTypedArray( v ) ) {\n\t\tsum = 0.0;\n\t\tfor ( i = 0; i < v.length; i++ ) {\n\t\t\tif (\n\t\t\t\tv[ i ] > 1.0 ||\n\t\t\t\tv[ i ] < 0.0\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tsum += v[ i ];\n\t\t}\n\t\treturn ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS );\n\t}\n\treturn false;\n}\n\n\n// EXPORTS //\n\nexport default isUnityProbabilityArray;\n"],"names":["isUnityProbabilityArray","v","sum","i","isArray","length","isNumber","absdiff","FLOAT64_SQRT_EPS","isTypedArray"],"mappings":";;ufAqDA,SAASA,EAAyBC,GACjC,IAAIC,EACAC,EACJ,GAAKC,EAASH,GAAM,CAEnB,IADAC,EAAM,EACAC,EAAI,EAAGA,EAAIF,EAAEI,OAAQF,IAAM,CAChC,IACEG,EAAUL,EAAGE,KACdF,EAAGE,GAAM,GACTF,EAAGE,GAAM,EAET,OAAO,EAERD,GAAOD,EAAGE,EACV,CACD,OAASI,EAASL,EAAK,IAASM,CAChC,CACD,GAAKC,EAAcR,GAAM,CAExB,IADAC,EAAM,EACAC,EAAI,EAAGA,EAAIF,EAAEI,OAAQF,IAAM,CAChC,GACCF,EAAGE,GAAM,GACTF,EAAGE,GAAM,EAET,OAAO,EAERD,GAAOD,EAAGE,EACV,CACD,OAASI,EAASL,EAAK,IAASM,CAChC,CACD,OAAO,CACR"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 3fed9bd..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From c2ea826018d5e2b4de7f50b6a29b792e9fbf0978 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Apr 2024 10:57:30 +0000 Subject: [PATCH 092/133] 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 | 43 +- SECURITY.md | 5 - benchmark/benchmark.js | 103 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 29 - docs/types/test.ts | 34 - examples/index.js | 48 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 49 - lib/main.js | 90 - package.json | 70 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 106 - 43 files changed, 4867 insertions(+), 3827 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 delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/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 77a9036..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-04-01T03:57:59.365Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 75a4c32..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/assert/is-unity-probability-array) 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 5119885..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/assert/is-unity-probability-array) 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 3b386b0..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: '49 1 * * 1' - - # 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 + + ```
@@ -178,7 +169,7 @@ bool = isUnityProbabilityArray( null ); ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -245,9 +236,9 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/assert/is-probability]: https://github.com/stdlib-js/assert-is-probability +[@stdlib/assert/is-probability]: https://github.com/stdlib-js/assert-is-probability/tree/esm -[@stdlib/assert/is-probability-array]: https://github.com/stdlib-js/assert-is-probability-array +[@stdlib/assert/is-probability-array]: https://github.com/stdlib-js/assert-is-probability-array/tree/esm diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 510a5ed..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,103 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var isUnityProbabilityArray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x; - var i; - - x = []; - for ( i = 0; i < len; i++ ) { - x.push( 1.0/len ); - } - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: we are testing the worst case scenario where a function must scan the entire array before finding a failing value. - x[ len-1 ] = i * 3.14; - bool = isUnityProbabilityArray( x ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( isBoolean( bool ) ) { - b.pass( 'benchmark finished' ); - } else { - b.fail( 'should return a boolean' ); - } - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':len='+len, f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index 5a6810d..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/assert/is-unity-probability-array" -%% click B href "https://github.com/stdlib-js/assert-is-unity-probability-array/tree/main" -%% click C href "https://github.com/stdlib-js/assert-is-unity-probability-array/tree/production" -%% click D href "https://github.com/stdlib-js/assert-is-unity-probability-array/tree/esm" -%% click E href "https://github.com/stdlib-js/assert-is-unity-probability-array/tree/deno" -%% click F href "https://github.com/stdlib-js/assert-is-unity-probability-array/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/assert/is-unity-probability-array -[production-url]: https://github.com/stdlib-js/assert-is-unity-probability-array/tree/production -[deno-url]: https://github.com/stdlib-js/assert-is-unity-probability-array/tree/deno -[deno-readme]: https://github.com/stdlib-js/assert-is-unity-probability-array/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/assert-is-unity-probability-array/tree/umd -[umd-readme]: https://github.com/stdlib-js/assert-is-unity-probability-array/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/assert-is-unity-probability-array/tree/esm -[esm-readme]: https://github.com/stdlib-js/assert-is-unity-probability-array/blob/esm/README.md \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index c77d01e..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import isUnityProbabilityArray from '../docs/types/index'; -export = isUnityProbabilityArray; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 70d7801..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var f=function(r,i){return function(){return i||r((i={exports:{}}).exports,i),i.exports}};var u=f(function(m,s){ -var n=require('@stdlib/assert-is-typed-array/dist'),l=require('@stdlib/assert-is-array/dist'),o=require('@stdlib/assert-is-number/dist').isPrimitive,a=require('@stdlib/math-base-utils-absolute-difference/dist'),t=require('@stdlib/constants-float64-sqrt-eps/dist');function q(r){var i,e;if(l(r)){for(i=0,e=0;e1||r[e]<0)return!1;i+=r[e]}return a(i,1)<=t}if(n(r)){for(i=0,e=0;e1||r[e]<0)return!1;i+=r[e]}return a(i,1)<=t}return!1}s.exports=q -});var y=u();module.exports=y; -/** @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 387d5ad..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) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isTypedArray = require( '@stdlib/assert-is-typed-array' );\nvar isArray = require( '@stdlib/assert-is-array' );\nvar isNumber = require( '@stdlib/assert-is-number' ).isPrimitive;\nvar absdiff = require( '@stdlib/math-base-utils-absolute-difference' );\nvar FLOAT64_SQRT_EPS = require( '@stdlib/constants-float64-sqrt-eps' );\n\n\n// MAIN //\n\n/**\n* Tests if a value is an array of probabilities that sum to one.\n*\n* @param {*} v - value to test\n* @returns {boolean} boolean indicating if a value is a probability array\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] );\n* // returns true\n*\n* @example\n* var bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) );\n* // returns true\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] );\n* // returns false\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 3.14, 0.0 ] );\n* // returns false\n*/\nfunction isUnityProbabilityArray( v ) {\n\tvar sum;\n\tvar i;\n\tif ( isArray( v ) ) {\n\t\tsum = 0.0;\n\t\tfor ( i = 0; i < v.length; i++ ) {\n\t\t\tif (\n\t\t\t\t!isNumber( v[ i ] ) ||\n\t\t\t\tv[ i ] > 1.0 ||\n\t\t\t\tv[ i ] < 0.0\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tsum += v[ i ];\n\t\t}\n\t\treturn ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS );\n\t}\n\tif ( isTypedArray( v ) ) {\n\t\tsum = 0.0;\n\t\tfor ( i = 0; i < v.length; i++ ) {\n\t\t\tif (\n\t\t\t\tv[ i ] > 1.0 ||\n\t\t\t\tv[ i ] < 0.0\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tsum += v[ i ];\n\t\t}\n\t\treturn ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS );\n\t}\n\treturn false;\n}\n\n\n// EXPORTS //\n\nmodule.exports = isUnityProbabilityArray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Test if a value is an array of probabilities that sum to one.\n*\n* @module @stdlib/assert-is-unity-probability-array\n*\n* @example\n* var isUnityProbabilityArray = require( '@stdlib/assert-is-unity-probability-array' );\n*\n* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] );\n* // returns true\n*\n* bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) );\n* // returns true\n*\n* bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] );\n* // returns false\n*\n* bool = isUnityProbabilityArray( [ 3.14, 0.0 ] );\n* // returns false\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,EAAe,QAAS,+BAAgC,EACxDC,EAAU,QAAS,yBAA0B,EAC7CC,EAAW,QAAS,0BAA2B,EAAE,YACjDC,EAAU,QAAS,6CAA8C,EACjEC,EAAmB,QAAS,oCAAqC,EA2BrE,SAASC,EAAyBC,EAAI,CACrC,IAAIC,EACAC,EACJ,GAAKP,EAASK,CAAE,EAAI,CAEnB,IADAC,EAAM,EACAC,EAAI,EAAGA,EAAIF,EAAE,OAAQE,IAAM,CAChC,GACC,CAACN,EAAUI,EAAGE,CAAE,CAAE,GAClBF,EAAGE,CAAE,EAAI,GACTF,EAAGE,CAAE,EAAI,EAET,MAAO,GAERD,GAAOD,EAAGE,CAAE,CACb,CACA,OAASL,EAASI,EAAK,CAAI,GAAKH,CACjC,CACA,GAAKJ,EAAcM,CAAE,EAAI,CAExB,IADAC,EAAM,EACAC,EAAI,EAAGA,EAAIF,EAAE,OAAQE,IAAM,CAChC,GACCF,EAAGE,CAAE,EAAI,GACTF,EAAGE,CAAE,EAAI,EAET,MAAO,GAERD,GAAOD,EAAGE,CAAE,CACb,CACA,OAASL,EAASI,EAAK,CAAI,GAAKH,CACjC,CACA,MAAO,EACR,CAKAL,EAAO,QAAUM,IC9CjB,IAAII,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isTypedArray", "isArray", "isNumber", "absdiff", "FLOAT64_SQRT_EPS", "isUnityProbabilityArray", "v", "sum", "i", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index a2414be..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,29 +0,0 @@ - -{{alias}}( value ) - Tests if a value is an array of probabilities that sum to one. - - Parameters - ---------- - value: any - Value to test. - - Returns - ------- - bool: boolean - Boolean indicating whether value is an array of probabilities that sum - to one. - - Examples - -------- - > var bool = {{alias}}( [ 0.25, 0.5, 0.25 ] ) - true - > bool = {{alias}}( new {{alias:@stdlib/array/uint8}}( [ 0, 1 ] ) ) - true - > bool = {{alias}}( [ 0.4, 0.4, 0.4 ] ) - false - > bool = {{alias}}( [ 3.14, 0.0 ] ) - false - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 6b41658..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,34 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import isUnityProbabilityArray = require( './index' ); - - -// TESTS // - -// The function returns a boolean... -{ - isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] ); // $ExpectType boolean - isUnityProbabilityArray( [ 2, 3 ] ); // $ExpectType boolean -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - isUnityProbabilityArray(); // $ExpectError - isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ], 123 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index b0b6bbc..0000000 --- a/examples/index.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var Uint8Array = require( '@stdlib/array-uint8' ); -var isUnityProbabilityArray = require( './../lib' ); - -var arr = [ 0.0, 1.0 ]; -console.log( isUnityProbabilityArray( arr ) ); -// => true - -arr = [ 0.5, 0.25, 0.25 ]; -console.log( isUnityProbabilityArray( arr ) ); -// => true - -arr = new Uint8Array( [ 0, 0, 1, 0 ] ); -console.log( isUnityProbabilityArray( arr ) ); -// => true - -arr = [ 0.4, 0.4, 0.4 ]; -console.log( isUnityProbabilityArray( arr ) ); -// => false - -arr = [ 3.14, -1.0 ]; -console.log( isUnityProbabilityArray( arr ) ); -// => false - -console.log( isUnityProbabilityArray( [] ) ); -// => false - -console.log( isUnityProbabilityArray( null ) ); -// => false diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..01aa353 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-typed-array@v0.2.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array@v0.2.1-esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-number@v0.2.0-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/math-base-utils-absolute-difference@v0.3.1-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/constants-float64-sqrt-eps@v0.2.1-esm/index.mjs";function n(n){var d,m;if(t(n)){for(d=0,m=0;m1||n[m]<0)return!1;d+=n[m]}return r(d,1)<=i}if(s(n)){for(d=0,m=0;m1||n[m]<0)return!1;d+=n[m]}return r(d,1)<=i}return!1}export{n as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..08904b0 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isTypedArray from '@stdlib/assert-is-typed-array';\nimport isArray from '@stdlib/assert-is-array';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport absdiff from '@stdlib/math-base-utils-absolute-difference';\nimport FLOAT64_SQRT_EPS from '@stdlib/constants-float64-sqrt-eps';\n\n\n// MAIN //\n\n/**\n* Tests if a value is an array of probabilities that sum to one.\n*\n* @param {*} v - value to test\n* @returns {boolean} boolean indicating if a value is a probability array\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] );\n* // returns true\n*\n* @example\n* var bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) );\n* // returns true\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] );\n* // returns false\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 3.14, 0.0 ] );\n* // returns false\n*/\nfunction isUnityProbabilityArray( v ) {\n\tvar sum;\n\tvar i;\n\tif ( isArray( v ) ) {\n\t\tsum = 0.0;\n\t\tfor ( i = 0; i < v.length; i++ ) {\n\t\t\tif (\n\t\t\t\t!isNumber( v[ i ] ) ||\n\t\t\t\tv[ i ] > 1.0 ||\n\t\t\t\tv[ i ] < 0.0\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tsum += v[ i ];\n\t\t}\n\t\treturn ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS );\n\t}\n\tif ( isTypedArray( v ) ) {\n\t\tsum = 0.0;\n\t\tfor ( i = 0; i < v.length; i++ ) {\n\t\t\tif (\n\t\t\t\tv[ i ] > 1.0 ||\n\t\t\t\tv[ i ] < 0.0\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tsum += v[ i ];\n\t\t}\n\t\treturn ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS );\n\t}\n\treturn false;\n}\n\n\n// EXPORTS //\n\nexport default isUnityProbabilityArray;\n"],"names":["isUnityProbabilityArray","v","sum","i","isArray","length","isNumber","absdiff","FLOAT64_SQRT_EPS","isTypedArray"],"mappings":";;ufAqDA,SAASA,EAAyBC,GACjC,IAAIC,EACAC,EACJ,GAAKC,EAASH,GAAM,CAEnB,IADAC,EAAM,EACAC,EAAI,EAAGA,EAAIF,EAAEI,OAAQF,IAAM,CAChC,IACEG,EAAUL,EAAGE,KACdF,EAAGE,GAAM,GACTF,EAAGE,GAAM,EAET,OAAO,EAERD,GAAOD,EAAGE,EACV,CACD,OAASI,EAASL,EAAK,IAASM,CAChC,CACD,GAAKC,EAAcR,GAAM,CAExB,IADAC,EAAM,EACAC,EAAI,EAAGA,EAAIF,EAAEI,OAAQF,IAAM,CAChC,GACCF,EAAGE,GAAM,GACTF,EAAGE,GAAM,EAET,OAAO,EAERD,GAAOD,EAAGE,EACV,CACD,OAASI,EAASL,EAAK,IAASM,CAChC,CACD,OAAO,CACR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 13a67d1..0000000 --- a/lib/index.js +++ /dev/null @@ -1,49 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Test if a value is an array of probabilities that sum to one. -* -* @module @stdlib/assert-is-unity-probability-array -* -* @example -* var isUnityProbabilityArray = require( '@stdlib/assert-is-unity-probability-array' ); -* -* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] ); -* // returns true -* -* bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) ); -* // returns true -* -* bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] ); -* // returns false -* -* bool = isUnityProbabilityArray( [ 3.14, 0.0 ] ); -* // returns false -*/ - -// 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 d0bda40..0000000 --- a/lib/main.js +++ /dev/null @@ -1,90 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -var isArray = require( '@stdlib/assert-is-array' ); -var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var absdiff = require( '@stdlib/math-base-utils-absolute-difference' ); -var FLOAT64_SQRT_EPS = require( '@stdlib/constants-float64-sqrt-eps' ); - - -// MAIN // - -/** -* Tests if a value is an array of probabilities that sum to one. -* -* @param {*} v - value to test -* @returns {boolean} boolean indicating if a value is a probability array -* -* @example -* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] ); -* // returns true -* -* @example -* var bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) ); -* // returns true -* -* @example -* var bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] ); -* // returns false -* -* @example -* var bool = isUnityProbabilityArray( [ 3.14, 0.0 ] ); -* // returns false -*/ -function isUnityProbabilityArray( v ) { - var sum; - var i; - if ( isArray( v ) ) { - sum = 0.0; - for ( i = 0; i < v.length; i++ ) { - if ( - !isNumber( v[ i ] ) || - v[ i ] > 1.0 || - v[ i ] < 0.0 - ) { - return false; - } - sum += v[ i ]; - } - return ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS ); - } - if ( isTypedArray( v ) ) { - sum = 0.0; - for ( i = 0; i < v.length; i++ ) { - if ( - v[ i ] > 1.0 || - v[ i ] < 0.0 - ) { - return false; - } - sum += v[ i ]; - } - return ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS ); - } - return false; -} - - -// EXPORTS // - -module.exports = isUnityProbabilityArray; diff --git a/package.json b/package.json index e94508b..7b64e4b 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.1", "description": "Test if a value is an array of probabilities that sum to one.", "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" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,47 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-array": "^0.2.1", - "@stdlib/assert-is-number": "^0.2.1", - "@stdlib/assert-is-typed-array": "^0.2.1", - "@stdlib/constants-float64-sqrt-eps": "^0.2.1", - "@stdlib/math-base-utils-absolute-difference": "^0.3.1", - "@stdlib/error-tools-fmtprodmsg": "^0.2.1" - }, - "devDependencies": { - "@stdlib/array-float32": "^0.2.1", - "@stdlib/array-float64": "^0.2.1", - "@stdlib/array-int16": "^0.2.1", - "@stdlib/array-int32": "^0.2.1", - "@stdlib/array-int8": "^0.2.1", - "@stdlib/array-uint16": "^0.2.1", - "@stdlib/array-uint32": "^0.2.1", - "@stdlib/array-uint8": "^0.2.1", - "@stdlib/array-uint8c": "^0.2.1", - "@stdlib/assert-is-boolean": "^0.2.1", - "@stdlib/buffer-from-array": "^0.2.1", - "@stdlib/math-base-special-pow": "^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", "stdassert", @@ -105,4 +41,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..3fed9bd --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index a0424fb..0000000 --- a/test/test.js +++ /dev/null @@ -1,106 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Int8Array = require( '@stdlib/array-int8' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Float64Array = require( '@stdlib/array-float64' ); -var array2buffer = require( '@stdlib/buffer-from-array' ); -var isUnityProbabilityArray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof isUnityProbabilityArray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns `true` if provided an array of probabilities that sum to one', function test( t ) { - var values; - var i; - - values = [ - new Int8Array( [ 0, 0, 1 ] ), - new Uint8Array( [ 1, 0, 0 ] ), - new Uint8ClampedArray( [ 0, 1 ] ), - new Int16Array( [ 0, 0, 1, 0 ] ), - new Uint16Array( [ 1 ] ), - new Int32Array( [ 1, 0, 0 ] ), - new Uint32Array( [ 0, 1, 0 ] ), - new Float32Array( [ 0.0, 0.5, 0.5 ] ), - new Float64Array( [ 0.25, 0.25, 0.5 ] ), - [ 0.5, 0.25, 0.25 ] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.strictEqual( isUnityProbabilityArray( values[i] ), true, 'returns true when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function allows a difference in sum within floating-point epsilon', function test( t ) { - var bool = isUnityProbabilityArray( [ 0.1, 0.2, 0.1, 0.1, 0.2, 0.2, 0.1 ] ); - t.strictEqual( bool, true, 'returns true' ); - t.end(); -}); - -tape( 'the function returns `false` if not provided an array of probabilities that sum to one', function test( t ) { - var values; - var i; - - values = [ - '10', - '01', - '0.5', - '5', - 5, - NaN, - null, - void 0, - true, - [], - [ 5, null ], - [ 5, '5' ], - [ 1.0, 3.14 ], - [ -1.0, 1.0, 1.0 ], - [ 0.25, 0.33, 0.5 ], - new Float64Array( [ 0.25, 0.33, 0.5 ] ), - new Float64Array( [ 0.25, 1.33, 0.5 ] ), - new Float64Array( [ 0.25, -0.33, 0.5 ] ), - {}, - function noop() {}, - array2buffer( [ 1, 1, 0 ] ) - ]; - - for ( i = 0; i < values.length; i++ ) { - t.strictEqual( isUnityProbabilityArray( values[i] ), false, 'returns false when provided '+values[i] ); - } - t.end(); -}); From 5f6f7c5773e83742880aebb9d562398c61ac7270 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 12 Apr 2024 02:14:38 +0000 Subject: [PATCH 093/133] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 874e8e2..e94508b 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,8 @@ "@stdlib/assert-is-number": "^0.2.1", "@stdlib/assert-is-typed-array": "^0.2.1", "@stdlib/constants-float64-sqrt-eps": "^0.2.1", - "@stdlib/math-base-utils-absolute-difference": "^0.3.1" + "@stdlib/math-base-utils-absolute-difference": "^0.3.1", + "@stdlib/error-tools-fmtprodmsg": "^0.2.1" }, "devDependencies": { "@stdlib/array-float32": "^0.2.1", @@ -104,4 +105,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From e0d6940bd378aec703be3591f08da1f4fca869f6 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 12 Apr 2024 07:42:38 +0000 Subject: [PATCH 094/133] Remove files --- index.d.ts | 48 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4895 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index 63a123d..0000000 --- a/index.d.ts +++ /dev/null @@ -1,48 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/** -* Tests if a value is an array of probabilities that sum to one. -* -* @param v - value to test -* @returns boolean indicating if a value is a probability array -* -* @example -* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] ); -* // returns true -* -* @example -* var bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) ); -* // returns true -* -* @example -* var bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] ); -* // returns false -* -* @example -* var bool = isUnityProbabilityArray( [ 3.14, 0.0 ] ); -* // returns false -*/ -declare function isUnityProbabilityArray( v: any ): v is ArrayLike; - - -// EXPORTS // - -export = isUnityProbabilityArray; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 01aa353..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-typed-array@v0.2.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array@v0.2.1-esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-number@v0.2.0-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/math-base-utils-absolute-difference@v0.3.1-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/constants-float64-sqrt-eps@v0.2.1-esm/index.mjs";function n(n){var d,m;if(t(n)){for(d=0,m=0;m1||n[m]<0)return!1;d+=n[m]}return r(d,1)<=i}if(s(n)){for(d=0,m=0;m1||n[m]<0)return!1;d+=n[m]}return r(d,1)<=i}return!1}export{n as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 08904b0..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isTypedArray from '@stdlib/assert-is-typed-array';\nimport isArray from '@stdlib/assert-is-array';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport absdiff from '@stdlib/math-base-utils-absolute-difference';\nimport FLOAT64_SQRT_EPS from '@stdlib/constants-float64-sqrt-eps';\n\n\n// MAIN //\n\n/**\n* Tests if a value is an array of probabilities that sum to one.\n*\n* @param {*} v - value to test\n* @returns {boolean} boolean indicating if a value is a probability array\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] );\n* // returns true\n*\n* @example\n* var bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) );\n* // returns true\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] );\n* // returns false\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 3.14, 0.0 ] );\n* // returns false\n*/\nfunction isUnityProbabilityArray( v ) {\n\tvar sum;\n\tvar i;\n\tif ( isArray( v ) ) {\n\t\tsum = 0.0;\n\t\tfor ( i = 0; i < v.length; i++ ) {\n\t\t\tif (\n\t\t\t\t!isNumber( v[ i ] ) ||\n\t\t\t\tv[ i ] > 1.0 ||\n\t\t\t\tv[ i ] < 0.0\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tsum += v[ i ];\n\t\t}\n\t\treturn ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS );\n\t}\n\tif ( isTypedArray( v ) ) {\n\t\tsum = 0.0;\n\t\tfor ( i = 0; i < v.length; i++ ) {\n\t\t\tif (\n\t\t\t\tv[ i ] > 1.0 ||\n\t\t\t\tv[ i ] < 0.0\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tsum += v[ i ];\n\t\t}\n\t\treturn ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS );\n\t}\n\treturn false;\n}\n\n\n// EXPORTS //\n\nexport default isUnityProbabilityArray;\n"],"names":["isUnityProbabilityArray","v","sum","i","isArray","length","isNumber","absdiff","FLOAT64_SQRT_EPS","isTypedArray"],"mappings":";;ufAqDA,SAASA,EAAyBC,GACjC,IAAIC,EACAC,EACJ,GAAKC,EAASH,GAAM,CAEnB,IADAC,EAAM,EACAC,EAAI,EAAGA,EAAIF,EAAEI,OAAQF,IAAM,CAChC,IACEG,EAAUL,EAAGE,KACdF,EAAGE,GAAM,GACTF,EAAGE,GAAM,EAET,OAAO,EAERD,GAAOD,EAAGE,EACV,CACD,OAASI,EAASL,EAAK,IAASM,CAChC,CACD,GAAKC,EAAcR,GAAM,CAExB,IADAC,EAAM,EACAC,EAAI,EAAGA,EAAIF,EAAEI,OAAQF,IAAM,CAChC,GACCF,EAAGE,GAAM,GACTF,EAAGE,GAAM,EAET,OAAO,EAERD,GAAOD,EAAGE,EACV,CACD,OAASI,EAASL,EAAK,IAASM,CAChC,CACD,OAAO,CACR"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 3fed9bd..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 610ba07b5b0f202d56b937913d74b5df2ff6a045 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 12 Apr 2024 07:42:58 +0000 Subject: [PATCH 095/133] 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 | 43 +- SECURITY.md | 5 - benchmark/benchmark.js | 103 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 29 - docs/types/test.ts | 34 - examples/index.js | 48 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 49 - lib/main.js | 90 - package.json | 70 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 106 - 42 files changed, 4867 insertions(+), 3828 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 delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/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 75a4c32..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/assert/is-unity-probability-array) 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 5119885..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/assert/is-unity-probability-array) 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 3b386b0..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: '49 1 * * 1' - - # 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 + + ```
@@ -178,7 +169,7 @@ bool = isUnityProbabilityArray( null ); ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -245,9 +236,9 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/assert/is-probability]: https://github.com/stdlib-js/assert-is-probability +[@stdlib/assert/is-probability]: https://github.com/stdlib-js/assert-is-probability/tree/esm -[@stdlib/assert/is-probability-array]: https://github.com/stdlib-js/assert-is-probability-array +[@stdlib/assert/is-probability-array]: https://github.com/stdlib-js/assert-is-probability-array/tree/esm diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 510a5ed..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,103 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var isUnityProbabilityArray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x; - var i; - - x = []; - for ( i = 0; i < len; i++ ) { - x.push( 1.0/len ); - } - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: we are testing the worst case scenario where a function must scan the entire array before finding a failing value. - x[ len-1 ] = i * 3.14; - bool = isUnityProbabilityArray( x ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( isBoolean( bool ) ) { - b.pass( 'benchmark finished' ); - } else { - b.fail( 'should return a boolean' ); - } - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':len='+len, f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index 5a6810d..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/assert/is-unity-probability-array" -%% click B href "https://github.com/stdlib-js/assert-is-unity-probability-array/tree/main" -%% click C href "https://github.com/stdlib-js/assert-is-unity-probability-array/tree/production" -%% click D href "https://github.com/stdlib-js/assert-is-unity-probability-array/tree/esm" -%% click E href "https://github.com/stdlib-js/assert-is-unity-probability-array/tree/deno" -%% click F href "https://github.com/stdlib-js/assert-is-unity-probability-array/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/assert/is-unity-probability-array -[production-url]: https://github.com/stdlib-js/assert-is-unity-probability-array/tree/production -[deno-url]: https://github.com/stdlib-js/assert-is-unity-probability-array/tree/deno -[deno-readme]: https://github.com/stdlib-js/assert-is-unity-probability-array/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/assert-is-unity-probability-array/tree/umd -[umd-readme]: https://github.com/stdlib-js/assert-is-unity-probability-array/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/assert-is-unity-probability-array/tree/esm -[esm-readme]: https://github.com/stdlib-js/assert-is-unity-probability-array/blob/esm/README.md \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index c77d01e..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import isUnityProbabilityArray from '../docs/types/index'; -export = isUnityProbabilityArray; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 70d7801..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var f=function(r,i){return function(){return i||r((i={exports:{}}).exports,i),i.exports}};var u=f(function(m,s){ -var n=require('@stdlib/assert-is-typed-array/dist'),l=require('@stdlib/assert-is-array/dist'),o=require('@stdlib/assert-is-number/dist').isPrimitive,a=require('@stdlib/math-base-utils-absolute-difference/dist'),t=require('@stdlib/constants-float64-sqrt-eps/dist');function q(r){var i,e;if(l(r)){for(i=0,e=0;e1||r[e]<0)return!1;i+=r[e]}return a(i,1)<=t}if(n(r)){for(i=0,e=0;e1||r[e]<0)return!1;i+=r[e]}return a(i,1)<=t}return!1}s.exports=q -});var y=u();module.exports=y; -/** @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 387d5ad..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) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isTypedArray = require( '@stdlib/assert-is-typed-array' );\nvar isArray = require( '@stdlib/assert-is-array' );\nvar isNumber = require( '@stdlib/assert-is-number' ).isPrimitive;\nvar absdiff = require( '@stdlib/math-base-utils-absolute-difference' );\nvar FLOAT64_SQRT_EPS = require( '@stdlib/constants-float64-sqrt-eps' );\n\n\n// MAIN //\n\n/**\n* Tests if a value is an array of probabilities that sum to one.\n*\n* @param {*} v - value to test\n* @returns {boolean} boolean indicating if a value is a probability array\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] );\n* // returns true\n*\n* @example\n* var bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) );\n* // returns true\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] );\n* // returns false\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 3.14, 0.0 ] );\n* // returns false\n*/\nfunction isUnityProbabilityArray( v ) {\n\tvar sum;\n\tvar i;\n\tif ( isArray( v ) ) {\n\t\tsum = 0.0;\n\t\tfor ( i = 0; i < v.length; i++ ) {\n\t\t\tif (\n\t\t\t\t!isNumber( v[ i ] ) ||\n\t\t\t\tv[ i ] > 1.0 ||\n\t\t\t\tv[ i ] < 0.0\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tsum += v[ i ];\n\t\t}\n\t\treturn ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS );\n\t}\n\tif ( isTypedArray( v ) ) {\n\t\tsum = 0.0;\n\t\tfor ( i = 0; i < v.length; i++ ) {\n\t\t\tif (\n\t\t\t\tv[ i ] > 1.0 ||\n\t\t\t\tv[ i ] < 0.0\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tsum += v[ i ];\n\t\t}\n\t\treturn ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS );\n\t}\n\treturn false;\n}\n\n\n// EXPORTS //\n\nmodule.exports = isUnityProbabilityArray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Test if a value is an array of probabilities that sum to one.\n*\n* @module @stdlib/assert-is-unity-probability-array\n*\n* @example\n* var isUnityProbabilityArray = require( '@stdlib/assert-is-unity-probability-array' );\n*\n* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] );\n* // returns true\n*\n* bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) );\n* // returns true\n*\n* bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] );\n* // returns false\n*\n* bool = isUnityProbabilityArray( [ 3.14, 0.0 ] );\n* // returns false\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,EAAe,QAAS,+BAAgC,EACxDC,EAAU,QAAS,yBAA0B,EAC7CC,EAAW,QAAS,0BAA2B,EAAE,YACjDC,EAAU,QAAS,6CAA8C,EACjEC,EAAmB,QAAS,oCAAqC,EA2BrE,SAASC,EAAyBC,EAAI,CACrC,IAAIC,EACAC,EACJ,GAAKP,EAASK,CAAE,EAAI,CAEnB,IADAC,EAAM,EACAC,EAAI,EAAGA,EAAIF,EAAE,OAAQE,IAAM,CAChC,GACC,CAACN,EAAUI,EAAGE,CAAE,CAAE,GAClBF,EAAGE,CAAE,EAAI,GACTF,EAAGE,CAAE,EAAI,EAET,MAAO,GAERD,GAAOD,EAAGE,CAAE,CACb,CACA,OAASL,EAASI,EAAK,CAAI,GAAKH,CACjC,CACA,GAAKJ,EAAcM,CAAE,EAAI,CAExB,IADAC,EAAM,EACAC,EAAI,EAAGA,EAAIF,EAAE,OAAQE,IAAM,CAChC,GACCF,EAAGE,CAAE,EAAI,GACTF,EAAGE,CAAE,EAAI,EAET,MAAO,GAERD,GAAOD,EAAGE,CAAE,CACb,CACA,OAASL,EAASI,EAAK,CAAI,GAAKH,CACjC,CACA,MAAO,EACR,CAKAL,EAAO,QAAUM,IC9CjB,IAAII,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isTypedArray", "isArray", "isNumber", "absdiff", "FLOAT64_SQRT_EPS", "isUnityProbabilityArray", "v", "sum", "i", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index a2414be..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,29 +0,0 @@ - -{{alias}}( value ) - Tests if a value is an array of probabilities that sum to one. - - Parameters - ---------- - value: any - Value to test. - - Returns - ------- - bool: boolean - Boolean indicating whether value is an array of probabilities that sum - to one. - - Examples - -------- - > var bool = {{alias}}( [ 0.25, 0.5, 0.25 ] ) - true - > bool = {{alias}}( new {{alias:@stdlib/array/uint8}}( [ 0, 1 ] ) ) - true - > bool = {{alias}}( [ 0.4, 0.4, 0.4 ] ) - false - > bool = {{alias}}( [ 3.14, 0.0 ] ) - false - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 6b41658..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,34 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import isUnityProbabilityArray = require( './index' ); - - -// TESTS // - -// The function returns a boolean... -{ - isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] ); // $ExpectType boolean - isUnityProbabilityArray( [ 2, 3 ] ); // $ExpectType boolean -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - isUnityProbabilityArray(); // $ExpectError - isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ], 123 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index b0b6bbc..0000000 --- a/examples/index.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var Uint8Array = require( '@stdlib/array-uint8' ); -var isUnityProbabilityArray = require( './../lib' ); - -var arr = [ 0.0, 1.0 ]; -console.log( isUnityProbabilityArray( arr ) ); -// => true - -arr = [ 0.5, 0.25, 0.25 ]; -console.log( isUnityProbabilityArray( arr ) ); -// => true - -arr = new Uint8Array( [ 0, 0, 1, 0 ] ); -console.log( isUnityProbabilityArray( arr ) ); -// => true - -arr = [ 0.4, 0.4, 0.4 ]; -console.log( isUnityProbabilityArray( arr ) ); -// => false - -arr = [ 3.14, -1.0 ]; -console.log( isUnityProbabilityArray( arr ) ); -// => false - -console.log( isUnityProbabilityArray( [] ) ); -// => false - -console.log( isUnityProbabilityArray( null ) ); -// => false diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..01aa353 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-typed-array@v0.2.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array@v0.2.1-esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-number@v0.2.0-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/math-base-utils-absolute-difference@v0.3.1-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/constants-float64-sqrt-eps@v0.2.1-esm/index.mjs";function n(n){var d,m;if(t(n)){for(d=0,m=0;m1||n[m]<0)return!1;d+=n[m]}return r(d,1)<=i}if(s(n)){for(d=0,m=0;m1||n[m]<0)return!1;d+=n[m]}return r(d,1)<=i}return!1}export{n as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..08904b0 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isTypedArray from '@stdlib/assert-is-typed-array';\nimport isArray from '@stdlib/assert-is-array';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport absdiff from '@stdlib/math-base-utils-absolute-difference';\nimport FLOAT64_SQRT_EPS from '@stdlib/constants-float64-sqrt-eps';\n\n\n// MAIN //\n\n/**\n* Tests if a value is an array of probabilities that sum to one.\n*\n* @param {*} v - value to test\n* @returns {boolean} boolean indicating if a value is a probability array\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] );\n* // returns true\n*\n* @example\n* var bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) );\n* // returns true\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] );\n* // returns false\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 3.14, 0.0 ] );\n* // returns false\n*/\nfunction isUnityProbabilityArray( v ) {\n\tvar sum;\n\tvar i;\n\tif ( isArray( v ) ) {\n\t\tsum = 0.0;\n\t\tfor ( i = 0; i < v.length; i++ ) {\n\t\t\tif (\n\t\t\t\t!isNumber( v[ i ] ) ||\n\t\t\t\tv[ i ] > 1.0 ||\n\t\t\t\tv[ i ] < 0.0\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tsum += v[ i ];\n\t\t}\n\t\treturn ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS );\n\t}\n\tif ( isTypedArray( v ) ) {\n\t\tsum = 0.0;\n\t\tfor ( i = 0; i < v.length; i++ ) {\n\t\t\tif (\n\t\t\t\tv[ i ] > 1.0 ||\n\t\t\t\tv[ i ] < 0.0\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tsum += v[ i ];\n\t\t}\n\t\treturn ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS );\n\t}\n\treturn false;\n}\n\n\n// EXPORTS //\n\nexport default isUnityProbabilityArray;\n"],"names":["isUnityProbabilityArray","v","sum","i","isArray","length","isNumber","absdiff","FLOAT64_SQRT_EPS","isTypedArray"],"mappings":";;ufAqDA,SAASA,EAAyBC,GACjC,IAAIC,EACAC,EACJ,GAAKC,EAASH,GAAM,CAEnB,IADAC,EAAM,EACAC,EAAI,EAAGA,EAAIF,EAAEI,OAAQF,IAAM,CAChC,IACEG,EAAUL,EAAGE,KACdF,EAAGE,GAAM,GACTF,EAAGE,GAAM,EAET,OAAO,EAERD,GAAOD,EAAGE,EACV,CACD,OAASI,EAASL,EAAK,IAASM,CAChC,CACD,GAAKC,EAAcR,GAAM,CAExB,IADAC,EAAM,EACAC,EAAI,EAAGA,EAAIF,EAAEI,OAAQF,IAAM,CAChC,GACCF,EAAGE,GAAM,GACTF,EAAGE,GAAM,EAET,OAAO,EAERD,GAAOD,EAAGE,EACV,CACD,OAASI,EAASL,EAAK,IAASM,CAChC,CACD,OAAO,CACR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 13a67d1..0000000 --- a/lib/index.js +++ /dev/null @@ -1,49 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Test if a value is an array of probabilities that sum to one. -* -* @module @stdlib/assert-is-unity-probability-array -* -* @example -* var isUnityProbabilityArray = require( '@stdlib/assert-is-unity-probability-array' ); -* -* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] ); -* // returns true -* -* bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) ); -* // returns true -* -* bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] ); -* // returns false -* -* bool = isUnityProbabilityArray( [ 3.14, 0.0 ] ); -* // returns false -*/ - -// 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 d0bda40..0000000 --- a/lib/main.js +++ /dev/null @@ -1,90 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -var isArray = require( '@stdlib/assert-is-array' ); -var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var absdiff = require( '@stdlib/math-base-utils-absolute-difference' ); -var FLOAT64_SQRT_EPS = require( '@stdlib/constants-float64-sqrt-eps' ); - - -// MAIN // - -/** -* Tests if a value is an array of probabilities that sum to one. -* -* @param {*} v - value to test -* @returns {boolean} boolean indicating if a value is a probability array -* -* @example -* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] ); -* // returns true -* -* @example -* var bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) ); -* // returns true -* -* @example -* var bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] ); -* // returns false -* -* @example -* var bool = isUnityProbabilityArray( [ 3.14, 0.0 ] ); -* // returns false -*/ -function isUnityProbabilityArray( v ) { - var sum; - var i; - if ( isArray( v ) ) { - sum = 0.0; - for ( i = 0; i < v.length; i++ ) { - if ( - !isNumber( v[ i ] ) || - v[ i ] > 1.0 || - v[ i ] < 0.0 - ) { - return false; - } - sum += v[ i ]; - } - return ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS ); - } - if ( isTypedArray( v ) ) { - sum = 0.0; - for ( i = 0; i < v.length; i++ ) { - if ( - v[ i ] > 1.0 || - v[ i ] < 0.0 - ) { - return false; - } - sum += v[ i ]; - } - return ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS ); - } - return false; -} - - -// EXPORTS // - -module.exports = isUnityProbabilityArray; diff --git a/package.json b/package.json index e94508b..7b64e4b 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.1", "description": "Test if a value is an array of probabilities that sum to one.", "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" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,47 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-array": "^0.2.1", - "@stdlib/assert-is-number": "^0.2.1", - "@stdlib/assert-is-typed-array": "^0.2.1", - "@stdlib/constants-float64-sqrt-eps": "^0.2.1", - "@stdlib/math-base-utils-absolute-difference": "^0.3.1", - "@stdlib/error-tools-fmtprodmsg": "^0.2.1" - }, - "devDependencies": { - "@stdlib/array-float32": "^0.2.1", - "@stdlib/array-float64": "^0.2.1", - "@stdlib/array-int16": "^0.2.1", - "@stdlib/array-int32": "^0.2.1", - "@stdlib/array-int8": "^0.2.1", - "@stdlib/array-uint16": "^0.2.1", - "@stdlib/array-uint32": "^0.2.1", - "@stdlib/array-uint8": "^0.2.1", - "@stdlib/array-uint8c": "^0.2.1", - "@stdlib/assert-is-boolean": "^0.2.1", - "@stdlib/buffer-from-array": "^0.2.1", - "@stdlib/math-base-special-pow": "^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", "stdassert", @@ -105,4 +41,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..3fed9bd --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index a0424fb..0000000 --- a/test/test.js +++ /dev/null @@ -1,106 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Int8Array = require( '@stdlib/array-int8' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Float64Array = require( '@stdlib/array-float64' ); -var array2buffer = require( '@stdlib/buffer-from-array' ); -var isUnityProbabilityArray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof isUnityProbabilityArray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns `true` if provided an array of probabilities that sum to one', function test( t ) { - var values; - var i; - - values = [ - new Int8Array( [ 0, 0, 1 ] ), - new Uint8Array( [ 1, 0, 0 ] ), - new Uint8ClampedArray( [ 0, 1 ] ), - new Int16Array( [ 0, 0, 1, 0 ] ), - new Uint16Array( [ 1 ] ), - new Int32Array( [ 1, 0, 0 ] ), - new Uint32Array( [ 0, 1, 0 ] ), - new Float32Array( [ 0.0, 0.5, 0.5 ] ), - new Float64Array( [ 0.25, 0.25, 0.5 ] ), - [ 0.5, 0.25, 0.25 ] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.strictEqual( isUnityProbabilityArray( values[i] ), true, 'returns true when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function allows a difference in sum within floating-point epsilon', function test( t ) { - var bool = isUnityProbabilityArray( [ 0.1, 0.2, 0.1, 0.1, 0.2, 0.2, 0.1 ] ); - t.strictEqual( bool, true, 'returns true' ); - t.end(); -}); - -tape( 'the function returns `false` if not provided an array of probabilities that sum to one', function test( t ) { - var values; - var i; - - values = [ - '10', - '01', - '0.5', - '5', - 5, - NaN, - null, - void 0, - true, - [], - [ 5, null ], - [ 5, '5' ], - [ 1.0, 3.14 ], - [ -1.0, 1.0, 1.0 ], - [ 0.25, 0.33, 0.5 ], - new Float64Array( [ 0.25, 0.33, 0.5 ] ), - new Float64Array( [ 0.25, 1.33, 0.5 ] ), - new Float64Array( [ 0.25, -0.33, 0.5 ] ), - {}, - function noop() {}, - array2buffer( [ 1, 1, 0 ] ) - ]; - - for ( i = 0; i < values.length; i++ ) { - t.strictEqual( isUnityProbabilityArray( values[i] ), false, 'returns false when provided '+values[i] ); - } - t.end(); -}); From b37b0943941397d8a9a91804252c2b4ce31d89e5 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 28 Jul 2024 21:02:44 +0000 Subject: [PATCH 096/133] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 892146d..f902d28 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,8 @@ "@stdlib/assert-is-number": "^0.2.2", "@stdlib/assert-is-typed-array": "^0.2.1", "@stdlib/constants-float64-sqrt-eps": "^0.2.2", - "@stdlib/math-base-utils-absolute-difference": "^0.3.2" + "@stdlib/math-base-utils-absolute-difference": "^0.3.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2" }, "devDependencies": { "@stdlib/array-float32": "^0.2.2", @@ -104,4 +105,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From d83c92108551afe1c38c67832c3dd94eb136bc01 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 28 Jul 2024 21:03:23 +0000 Subject: [PATCH 097/133] Remove files --- index.d.ts | 48 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4895 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index 63a123d..0000000 --- a/index.d.ts +++ /dev/null @@ -1,48 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/** -* Tests if a value is an array of probabilities that sum to one. -* -* @param v - value to test -* @returns boolean indicating if a value is a probability array -* -* @example -* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] ); -* // returns true -* -* @example -* var bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) ); -* // returns true -* -* @example -* var bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] ); -* // returns false -* -* @example -* var bool = isUnityProbabilityArray( [ 3.14, 0.0 ] ); -* // returns false -*/ -declare function isUnityProbabilityArray( v: any ): v is ArrayLike; - - -// EXPORTS // - -export = isUnityProbabilityArray; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 01aa353..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-typed-array@v0.2.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array@v0.2.1-esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-number@v0.2.0-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/math-base-utils-absolute-difference@v0.3.1-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/constants-float64-sqrt-eps@v0.2.1-esm/index.mjs";function n(n){var d,m;if(t(n)){for(d=0,m=0;m1||n[m]<0)return!1;d+=n[m]}return r(d,1)<=i}if(s(n)){for(d=0,m=0;m1||n[m]<0)return!1;d+=n[m]}return r(d,1)<=i}return!1}export{n as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 08904b0..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isTypedArray from '@stdlib/assert-is-typed-array';\nimport isArray from '@stdlib/assert-is-array';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport absdiff from '@stdlib/math-base-utils-absolute-difference';\nimport FLOAT64_SQRT_EPS from '@stdlib/constants-float64-sqrt-eps';\n\n\n// MAIN //\n\n/**\n* Tests if a value is an array of probabilities that sum to one.\n*\n* @param {*} v - value to test\n* @returns {boolean} boolean indicating if a value is a probability array\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] );\n* // returns true\n*\n* @example\n* var bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) );\n* // returns true\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] );\n* // returns false\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 3.14, 0.0 ] );\n* // returns false\n*/\nfunction isUnityProbabilityArray( v ) {\n\tvar sum;\n\tvar i;\n\tif ( isArray( v ) ) {\n\t\tsum = 0.0;\n\t\tfor ( i = 0; i < v.length; i++ ) {\n\t\t\tif (\n\t\t\t\t!isNumber( v[ i ] ) ||\n\t\t\t\tv[ i ] > 1.0 ||\n\t\t\t\tv[ i ] < 0.0\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tsum += v[ i ];\n\t\t}\n\t\treturn ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS );\n\t}\n\tif ( isTypedArray( v ) ) {\n\t\tsum = 0.0;\n\t\tfor ( i = 0; i < v.length; i++ ) {\n\t\t\tif (\n\t\t\t\tv[ i ] > 1.0 ||\n\t\t\t\tv[ i ] < 0.0\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tsum += v[ i ];\n\t\t}\n\t\treturn ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS );\n\t}\n\treturn false;\n}\n\n\n// EXPORTS //\n\nexport default isUnityProbabilityArray;\n"],"names":["isUnityProbabilityArray","v","sum","i","isArray","length","isNumber","absdiff","FLOAT64_SQRT_EPS","isTypedArray"],"mappings":";;ufAqDA,SAASA,EAAyBC,GACjC,IAAIC,EACAC,EACJ,GAAKC,EAASH,GAAM,CAEnB,IADAC,EAAM,EACAC,EAAI,EAAGA,EAAIF,EAAEI,OAAQF,IAAM,CAChC,IACEG,EAAUL,EAAGE,KACdF,EAAGE,GAAM,GACTF,EAAGE,GAAM,EAET,OAAO,EAERD,GAAOD,EAAGE,EACV,CACD,OAASI,EAASL,EAAK,IAASM,CAChC,CACD,GAAKC,EAAcR,GAAM,CAExB,IADAC,EAAM,EACAC,EAAI,EAAGA,EAAIF,EAAEI,OAAQF,IAAM,CAChC,GACCF,EAAGE,GAAM,GACTF,EAAGE,GAAM,EAET,OAAO,EAERD,GAAOD,EAAGE,EACV,CACD,OAASI,EAASL,EAAK,IAASM,CAChC,CACD,OAAO,CACR"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 3fed9bd..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 599d3c57dde49ba542f8b6e58b6be2e60934b8f3 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 28 Jul 2024 21:03:36 +0000 Subject: [PATCH 098/133] 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 | 164 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 43 +- SECURITY.md | 5 - benchmark/benchmark.js | 103 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 29 - docs/types/test.ts | 34 - examples/index.js | 48 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 49 - lib/main.js | 90 - package.json | 70 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 106 - 42 files changed, 4867 insertions(+), 3998 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 delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/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 75a4c32..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/assert/is-unity-probability-array) 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 5119885..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/assert/is-unity-probability-array) 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 3b386b0..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: '49 1 * * 1' - - # 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 + + ```
@@ -178,7 +169,7 @@ bool = isUnityProbabilityArray( null ); ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -245,9 +236,9 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/assert/is-probability]: https://github.com/stdlib-js/assert-is-probability +[@stdlib/assert/is-probability]: https://github.com/stdlib-js/assert-is-probability/tree/esm -[@stdlib/assert/is-probability-array]: https://github.com/stdlib-js/assert-is-probability-array +[@stdlib/assert/is-probability-array]: https://github.com/stdlib-js/assert-is-probability-array/tree/esm diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 510a5ed..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,103 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var isUnityProbabilityArray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x; - var i; - - x = []; - for ( i = 0; i < len; i++ ) { - x.push( 1.0/len ); - } - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: we are testing the worst case scenario where a function must scan the entire array before finding a failing value. - x[ len-1 ] = i * 3.14; - bool = isUnityProbabilityArray( x ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( isBoolean( bool ) ) { - b.pass( 'benchmark finished' ); - } else { - b.fail( 'should return a boolean' ); - } - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':len='+len, f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index 5a6810d..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/assert/is-unity-probability-array" -%% click B href "https://github.com/stdlib-js/assert-is-unity-probability-array/tree/main" -%% click C href "https://github.com/stdlib-js/assert-is-unity-probability-array/tree/production" -%% click D href "https://github.com/stdlib-js/assert-is-unity-probability-array/tree/esm" -%% click E href "https://github.com/stdlib-js/assert-is-unity-probability-array/tree/deno" -%% click F href "https://github.com/stdlib-js/assert-is-unity-probability-array/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/assert/is-unity-probability-array -[production-url]: https://github.com/stdlib-js/assert-is-unity-probability-array/tree/production -[deno-url]: https://github.com/stdlib-js/assert-is-unity-probability-array/tree/deno -[deno-readme]: https://github.com/stdlib-js/assert-is-unity-probability-array/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/assert-is-unity-probability-array/tree/umd -[umd-readme]: https://github.com/stdlib-js/assert-is-unity-probability-array/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/assert-is-unity-probability-array/tree/esm -[esm-readme]: https://github.com/stdlib-js/assert-is-unity-probability-array/blob/esm/README.md \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index c77d01e..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import isUnityProbabilityArray from '../docs/types/index'; -export = isUnityProbabilityArray; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 70d7801..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var f=function(r,i){return function(){return i||r((i={exports:{}}).exports,i),i.exports}};var u=f(function(m,s){ -var n=require('@stdlib/assert-is-typed-array/dist'),l=require('@stdlib/assert-is-array/dist'),o=require('@stdlib/assert-is-number/dist').isPrimitive,a=require('@stdlib/math-base-utils-absolute-difference/dist'),t=require('@stdlib/constants-float64-sqrt-eps/dist');function q(r){var i,e;if(l(r)){for(i=0,e=0;e1||r[e]<0)return!1;i+=r[e]}return a(i,1)<=t}if(n(r)){for(i=0,e=0;e1||r[e]<0)return!1;i+=r[e]}return a(i,1)<=t}return!1}s.exports=q -});var y=u();module.exports=y; -/** @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 387d5ad..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) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isTypedArray = require( '@stdlib/assert-is-typed-array' );\nvar isArray = require( '@stdlib/assert-is-array' );\nvar isNumber = require( '@stdlib/assert-is-number' ).isPrimitive;\nvar absdiff = require( '@stdlib/math-base-utils-absolute-difference' );\nvar FLOAT64_SQRT_EPS = require( '@stdlib/constants-float64-sqrt-eps' );\n\n\n// MAIN //\n\n/**\n* Tests if a value is an array of probabilities that sum to one.\n*\n* @param {*} v - value to test\n* @returns {boolean} boolean indicating if a value is a probability array\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] );\n* // returns true\n*\n* @example\n* var bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) );\n* // returns true\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] );\n* // returns false\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 3.14, 0.0 ] );\n* // returns false\n*/\nfunction isUnityProbabilityArray( v ) {\n\tvar sum;\n\tvar i;\n\tif ( isArray( v ) ) {\n\t\tsum = 0.0;\n\t\tfor ( i = 0; i < v.length; i++ ) {\n\t\t\tif (\n\t\t\t\t!isNumber( v[ i ] ) ||\n\t\t\t\tv[ i ] > 1.0 ||\n\t\t\t\tv[ i ] < 0.0\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tsum += v[ i ];\n\t\t}\n\t\treturn ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS );\n\t}\n\tif ( isTypedArray( v ) ) {\n\t\tsum = 0.0;\n\t\tfor ( i = 0; i < v.length; i++ ) {\n\t\t\tif (\n\t\t\t\tv[ i ] > 1.0 ||\n\t\t\t\tv[ i ] < 0.0\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tsum += v[ i ];\n\t\t}\n\t\treturn ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS );\n\t}\n\treturn false;\n}\n\n\n// EXPORTS //\n\nmodule.exports = isUnityProbabilityArray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Test if a value is an array of probabilities that sum to one.\n*\n* @module @stdlib/assert-is-unity-probability-array\n*\n* @example\n* var isUnityProbabilityArray = require( '@stdlib/assert-is-unity-probability-array' );\n*\n* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] );\n* // returns true\n*\n* bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) );\n* // returns true\n*\n* bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] );\n* // returns false\n*\n* bool = isUnityProbabilityArray( [ 3.14, 0.0 ] );\n* // returns false\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,EAAe,QAAS,+BAAgC,EACxDC,EAAU,QAAS,yBAA0B,EAC7CC,EAAW,QAAS,0BAA2B,EAAE,YACjDC,EAAU,QAAS,6CAA8C,EACjEC,EAAmB,QAAS,oCAAqC,EA2BrE,SAASC,EAAyBC,EAAI,CACrC,IAAIC,EACAC,EACJ,GAAKP,EAASK,CAAE,EAAI,CAEnB,IADAC,EAAM,EACAC,EAAI,EAAGA,EAAIF,EAAE,OAAQE,IAAM,CAChC,GACC,CAACN,EAAUI,EAAGE,CAAE,CAAE,GAClBF,EAAGE,CAAE,EAAI,GACTF,EAAGE,CAAE,EAAI,EAET,MAAO,GAERD,GAAOD,EAAGE,CAAE,CACb,CACA,OAASL,EAASI,EAAK,CAAI,GAAKH,CACjC,CACA,GAAKJ,EAAcM,CAAE,EAAI,CAExB,IADAC,EAAM,EACAC,EAAI,EAAGA,EAAIF,EAAE,OAAQE,IAAM,CAChC,GACCF,EAAGE,CAAE,EAAI,GACTF,EAAGE,CAAE,EAAI,EAET,MAAO,GAERD,GAAOD,EAAGE,CAAE,CACb,CACA,OAASL,EAASI,EAAK,CAAI,GAAKH,CACjC,CACA,MAAO,EACR,CAKAL,EAAO,QAAUM,IC9CjB,IAAII,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isTypedArray", "isArray", "isNumber", "absdiff", "FLOAT64_SQRT_EPS", "isUnityProbabilityArray", "v", "sum", "i", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index a2414be..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,29 +0,0 @@ - -{{alias}}( value ) - Tests if a value is an array of probabilities that sum to one. - - Parameters - ---------- - value: any - Value to test. - - Returns - ------- - bool: boolean - Boolean indicating whether value is an array of probabilities that sum - to one. - - Examples - -------- - > var bool = {{alias}}( [ 0.25, 0.5, 0.25 ] ) - true - > bool = {{alias}}( new {{alias:@stdlib/array/uint8}}( [ 0, 1 ] ) ) - true - > bool = {{alias}}( [ 0.4, 0.4, 0.4 ] ) - false - > bool = {{alias}}( [ 3.14, 0.0 ] ) - false - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 6b41658..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,34 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import isUnityProbabilityArray = require( './index' ); - - -// TESTS // - -// The function returns a boolean... -{ - isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] ); // $ExpectType boolean - isUnityProbabilityArray( [ 2, 3 ] ); // $ExpectType boolean -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - isUnityProbabilityArray(); // $ExpectError - isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ], 123 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index b0b6bbc..0000000 --- a/examples/index.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var Uint8Array = require( '@stdlib/array-uint8' ); -var isUnityProbabilityArray = require( './../lib' ); - -var arr = [ 0.0, 1.0 ]; -console.log( isUnityProbabilityArray( arr ) ); -// => true - -arr = [ 0.5, 0.25, 0.25 ]; -console.log( isUnityProbabilityArray( arr ) ); -// => true - -arr = new Uint8Array( [ 0, 0, 1, 0 ] ); -console.log( isUnityProbabilityArray( arr ) ); -// => true - -arr = [ 0.4, 0.4, 0.4 ]; -console.log( isUnityProbabilityArray( arr ) ); -// => false - -arr = [ 3.14, -1.0 ]; -console.log( isUnityProbabilityArray( arr ) ); -// => false - -console.log( isUnityProbabilityArray( [] ) ); -// => false - -console.log( isUnityProbabilityArray( null ) ); -// => false diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..f8cc2b3 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-typed-array@v0.2.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array@v0.2.2-esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-number@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/math-base-utils-absolute-difference@v0.3.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/constants-float64-sqrt-eps@v0.2.2-esm/index.mjs";function n(n){var d,m;if(t(n)){for(d=0,m=0;m1||n[m]<0)return!1;d+=n[m]}return r(d,1)<=i}if(s(n)){for(d=0,m=0;m1||n[m]<0)return!1;d+=n[m]}return r(d,1)<=i}return!1}export{n as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..08904b0 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isTypedArray from '@stdlib/assert-is-typed-array';\nimport isArray from '@stdlib/assert-is-array';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport absdiff from '@stdlib/math-base-utils-absolute-difference';\nimport FLOAT64_SQRT_EPS from '@stdlib/constants-float64-sqrt-eps';\n\n\n// MAIN //\n\n/**\n* Tests if a value is an array of probabilities that sum to one.\n*\n* @param {*} v - value to test\n* @returns {boolean} boolean indicating if a value is a probability array\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] );\n* // returns true\n*\n* @example\n* var bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) );\n* // returns true\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] );\n* // returns false\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 3.14, 0.0 ] );\n* // returns false\n*/\nfunction isUnityProbabilityArray( v ) {\n\tvar sum;\n\tvar i;\n\tif ( isArray( v ) ) {\n\t\tsum = 0.0;\n\t\tfor ( i = 0; i < v.length; i++ ) {\n\t\t\tif (\n\t\t\t\t!isNumber( v[ i ] ) ||\n\t\t\t\tv[ i ] > 1.0 ||\n\t\t\t\tv[ i ] < 0.0\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tsum += v[ i ];\n\t\t}\n\t\treturn ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS );\n\t}\n\tif ( isTypedArray( v ) ) {\n\t\tsum = 0.0;\n\t\tfor ( i = 0; i < v.length; i++ ) {\n\t\t\tif (\n\t\t\t\tv[ i ] > 1.0 ||\n\t\t\t\tv[ i ] < 0.0\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tsum += v[ i ];\n\t\t}\n\t\treturn ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS );\n\t}\n\treturn false;\n}\n\n\n// EXPORTS //\n\nexport default isUnityProbabilityArray;\n"],"names":["isUnityProbabilityArray","v","sum","i","isArray","length","isNumber","absdiff","FLOAT64_SQRT_EPS","isTypedArray"],"mappings":";;ufAqDA,SAASA,EAAyBC,GACjC,IAAIC,EACAC,EACJ,GAAKC,EAASH,GAAM,CAEnB,IADAC,EAAM,EACAC,EAAI,EAAGA,EAAIF,EAAEI,OAAQF,IAAM,CAChC,IACEG,EAAUL,EAAGE,KACdF,EAAGE,GAAM,GACTF,EAAGE,GAAM,EAET,OAAO,EAERD,GAAOD,EAAGE,EACV,CACD,OAASI,EAASL,EAAK,IAASM,CAChC,CACD,GAAKC,EAAcR,GAAM,CAExB,IADAC,EAAM,EACAC,EAAI,EAAGA,EAAIF,EAAEI,OAAQF,IAAM,CAChC,GACCF,EAAGE,GAAM,GACTF,EAAGE,GAAM,EAET,OAAO,EAERD,GAAOD,EAAGE,EACV,CACD,OAASI,EAASL,EAAK,IAASM,CAChC,CACD,OAAO,CACR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 13a67d1..0000000 --- a/lib/index.js +++ /dev/null @@ -1,49 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Test if a value is an array of probabilities that sum to one. -* -* @module @stdlib/assert-is-unity-probability-array -* -* @example -* var isUnityProbabilityArray = require( '@stdlib/assert-is-unity-probability-array' ); -* -* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] ); -* // returns true -* -* bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) ); -* // returns true -* -* bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] ); -* // returns false -* -* bool = isUnityProbabilityArray( [ 3.14, 0.0 ] ); -* // returns false -*/ - -// 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 d0bda40..0000000 --- a/lib/main.js +++ /dev/null @@ -1,90 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -var isArray = require( '@stdlib/assert-is-array' ); -var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var absdiff = require( '@stdlib/math-base-utils-absolute-difference' ); -var FLOAT64_SQRT_EPS = require( '@stdlib/constants-float64-sqrt-eps' ); - - -// MAIN // - -/** -* Tests if a value is an array of probabilities that sum to one. -* -* @param {*} v - value to test -* @returns {boolean} boolean indicating if a value is a probability array -* -* @example -* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] ); -* // returns true -* -* @example -* var bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) ); -* // returns true -* -* @example -* var bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] ); -* // returns false -* -* @example -* var bool = isUnityProbabilityArray( [ 3.14, 0.0 ] ); -* // returns false -*/ -function isUnityProbabilityArray( v ) { - var sum; - var i; - if ( isArray( v ) ) { - sum = 0.0; - for ( i = 0; i < v.length; i++ ) { - if ( - !isNumber( v[ i ] ) || - v[ i ] > 1.0 || - v[ i ] < 0.0 - ) { - return false; - } - sum += v[ i ]; - } - return ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS ); - } - if ( isTypedArray( v ) ) { - sum = 0.0; - for ( i = 0; i < v.length; i++ ) { - if ( - v[ i ] > 1.0 || - v[ i ] < 0.0 - ) { - return false; - } - sum += v[ i ]; - } - return ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS ); - } - return false; -} - - -// EXPORTS // - -module.exports = isUnityProbabilityArray; diff --git a/package.json b/package.json index f902d28..9ba851e 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.2", "description": "Test if a value is an array of probabilities that sum to one.", "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" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,47 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-array": "^0.2.2", - "@stdlib/assert-is-number": "^0.2.2", - "@stdlib/assert-is-typed-array": "^0.2.1", - "@stdlib/constants-float64-sqrt-eps": "^0.2.2", - "@stdlib/math-base-utils-absolute-difference": "^0.3.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/array-float32": "^0.2.2", - "@stdlib/array-float64": "^0.2.2", - "@stdlib/array-int16": "^0.2.2", - "@stdlib/array-int32": "^0.2.2", - "@stdlib/array-int8": "^0.2.2", - "@stdlib/array-uint16": "^0.2.2", - "@stdlib/array-uint32": "^0.2.2", - "@stdlib/array-uint8": "^0.2.2", - "@stdlib/array-uint8c": "^0.2.2", - "@stdlib/assert-is-boolean": "^0.2.2", - "@stdlib/buffer-from-array": "^0.2.2", - "@stdlib/math-base-special-pow": "^0.3.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.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdassert", @@ -105,4 +41,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..40b5cb8 --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index a0424fb..0000000 --- a/test/test.js +++ /dev/null @@ -1,106 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Int8Array = require( '@stdlib/array-int8' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Float64Array = require( '@stdlib/array-float64' ); -var array2buffer = require( '@stdlib/buffer-from-array' ); -var isUnityProbabilityArray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof isUnityProbabilityArray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns `true` if provided an array of probabilities that sum to one', function test( t ) { - var values; - var i; - - values = [ - new Int8Array( [ 0, 0, 1 ] ), - new Uint8Array( [ 1, 0, 0 ] ), - new Uint8ClampedArray( [ 0, 1 ] ), - new Int16Array( [ 0, 0, 1, 0 ] ), - new Uint16Array( [ 1 ] ), - new Int32Array( [ 1, 0, 0 ] ), - new Uint32Array( [ 0, 1, 0 ] ), - new Float32Array( [ 0.0, 0.5, 0.5 ] ), - new Float64Array( [ 0.25, 0.25, 0.5 ] ), - [ 0.5, 0.25, 0.25 ] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.strictEqual( isUnityProbabilityArray( values[i] ), true, 'returns true when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function allows a difference in sum within floating-point epsilon', function test( t ) { - var bool = isUnityProbabilityArray( [ 0.1, 0.2, 0.1, 0.1, 0.2, 0.2, 0.1 ] ); - t.strictEqual( bool, true, 'returns true' ); - t.end(); -}); - -tape( 'the function returns `false` if not provided an array of probabilities that sum to one', function test( t ) { - var values; - var i; - - values = [ - '10', - '01', - '0.5', - '5', - 5, - NaN, - null, - void 0, - true, - [], - [ 5, null ], - [ 5, '5' ], - [ 1.0, 3.14 ], - [ -1.0, 1.0, 1.0 ], - [ 0.25, 0.33, 0.5 ], - new Float64Array( [ 0.25, 0.33, 0.5 ] ), - new Float64Array( [ 0.25, 1.33, 0.5 ] ), - new Float64Array( [ 0.25, -0.33, 0.5 ] ), - {}, - function noop() {}, - array2buffer( [ 1, 1, 0 ] ) - ]; - - for ( i = 0; i < values.length; i++ ) { - t.strictEqual( isUnityProbabilityArray( values[i] ), false, 'returns false when provided '+values[i] ); - } - t.end(); -}); From b75887a7e97bf81613bbf954f13f67e8f0ca6047 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 28 Jul 2024 21:04:32 +0000 Subject: [PATCH 099/133] Update README.md for ESM bundle v0.2.2 --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index bab3948..a167142 100644 --- a/README.md +++ b/README.md @@ -42,7 +42,7 @@ limitations under the License. ## Usage ```javascript -import isUnityProbabilityArray from 'https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-unity-probability-array@esm/index.mjs'; +import isUnityProbabilityArray from 'https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-unity-probability-array@v0.2.2-esm/index.mjs'; ``` #### isUnityProbabilityArray( value ) @@ -108,7 +108,7 @@ bool = isUnityProbabilityArray( [ 3.14, 0.0 ] ); - - - - From 515c1c823793103ff81efb1d698e36189ad166b1 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Aug 2024 11:17:54 +0000 Subject: [PATCH 103/133] 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 | 148 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 43 +- SECURITY.md | 5 - benchmark/benchmark.js | 103 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 29 - docs/types/test.ts | 34 - examples/index.js | 48 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 49 - lib/main.js | 90 - package.json | 70 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 106 - 43 files changed, 4867 insertions(+), 3985 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 delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/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 bedebf8..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-08-01T04:48:02.045Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 75a4c32..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/assert/is-unity-probability-array) 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 5119885..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/assert/is-unity-probability-array) 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 3b386b0..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: '49 1 * * 1' - - # 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 + + ```
@@ -178,7 +169,7 @@ bool = isUnityProbabilityArray( null ); ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -245,9 +236,9 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/assert/is-probability]: https://github.com/stdlib-js/assert-is-probability +[@stdlib/assert/is-probability]: https://github.com/stdlib-js/assert-is-probability/tree/esm -[@stdlib/assert/is-probability-array]: https://github.com/stdlib-js/assert-is-probability-array +[@stdlib/assert/is-probability-array]: https://github.com/stdlib-js/assert-is-probability-array/tree/esm diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 510a5ed..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,103 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var isUnityProbabilityArray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x; - var i; - - x = []; - for ( i = 0; i < len; i++ ) { - x.push( 1.0/len ); - } - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: we are testing the worst case scenario where a function must scan the entire array before finding a failing value. - x[ len-1 ] = i * 3.14; - bool = isUnityProbabilityArray( x ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( isBoolean( bool ) ) { - b.pass( 'benchmark finished' ); - } else { - b.fail( 'should return a boolean' ); - } - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':len='+len, f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index 5a6810d..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/assert/is-unity-probability-array" -%% click B href "https://github.com/stdlib-js/assert-is-unity-probability-array/tree/main" -%% click C href "https://github.com/stdlib-js/assert-is-unity-probability-array/tree/production" -%% click D href "https://github.com/stdlib-js/assert-is-unity-probability-array/tree/esm" -%% click E href "https://github.com/stdlib-js/assert-is-unity-probability-array/tree/deno" -%% click F href "https://github.com/stdlib-js/assert-is-unity-probability-array/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/assert/is-unity-probability-array -[production-url]: https://github.com/stdlib-js/assert-is-unity-probability-array/tree/production -[deno-url]: https://github.com/stdlib-js/assert-is-unity-probability-array/tree/deno -[deno-readme]: https://github.com/stdlib-js/assert-is-unity-probability-array/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/assert-is-unity-probability-array/tree/umd -[umd-readme]: https://github.com/stdlib-js/assert-is-unity-probability-array/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/assert-is-unity-probability-array/tree/esm -[esm-readme]: https://github.com/stdlib-js/assert-is-unity-probability-array/blob/esm/README.md \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index c77d01e..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import isUnityProbabilityArray from '../docs/types/index'; -export = isUnityProbabilityArray; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 70d7801..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var f=function(r,i){return function(){return i||r((i={exports:{}}).exports,i),i.exports}};var u=f(function(m,s){ -var n=require('@stdlib/assert-is-typed-array/dist'),l=require('@stdlib/assert-is-array/dist'),o=require('@stdlib/assert-is-number/dist').isPrimitive,a=require('@stdlib/math-base-utils-absolute-difference/dist'),t=require('@stdlib/constants-float64-sqrt-eps/dist');function q(r){var i,e;if(l(r)){for(i=0,e=0;e1||r[e]<0)return!1;i+=r[e]}return a(i,1)<=t}if(n(r)){for(i=0,e=0;e1||r[e]<0)return!1;i+=r[e]}return a(i,1)<=t}return!1}s.exports=q -});var y=u();module.exports=y; -/** @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 387d5ad..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) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isTypedArray = require( '@stdlib/assert-is-typed-array' );\nvar isArray = require( '@stdlib/assert-is-array' );\nvar isNumber = require( '@stdlib/assert-is-number' ).isPrimitive;\nvar absdiff = require( '@stdlib/math-base-utils-absolute-difference' );\nvar FLOAT64_SQRT_EPS = require( '@stdlib/constants-float64-sqrt-eps' );\n\n\n// MAIN //\n\n/**\n* Tests if a value is an array of probabilities that sum to one.\n*\n* @param {*} v - value to test\n* @returns {boolean} boolean indicating if a value is a probability array\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] );\n* // returns true\n*\n* @example\n* var bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) );\n* // returns true\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] );\n* // returns false\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 3.14, 0.0 ] );\n* // returns false\n*/\nfunction isUnityProbabilityArray( v ) {\n\tvar sum;\n\tvar i;\n\tif ( isArray( v ) ) {\n\t\tsum = 0.0;\n\t\tfor ( i = 0; i < v.length; i++ ) {\n\t\t\tif (\n\t\t\t\t!isNumber( v[ i ] ) ||\n\t\t\t\tv[ i ] > 1.0 ||\n\t\t\t\tv[ i ] < 0.0\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tsum += v[ i ];\n\t\t}\n\t\treturn ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS );\n\t}\n\tif ( isTypedArray( v ) ) {\n\t\tsum = 0.0;\n\t\tfor ( i = 0; i < v.length; i++ ) {\n\t\t\tif (\n\t\t\t\tv[ i ] > 1.0 ||\n\t\t\t\tv[ i ] < 0.0\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tsum += v[ i ];\n\t\t}\n\t\treturn ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS );\n\t}\n\treturn false;\n}\n\n\n// EXPORTS //\n\nmodule.exports = isUnityProbabilityArray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Test if a value is an array of probabilities that sum to one.\n*\n* @module @stdlib/assert-is-unity-probability-array\n*\n* @example\n* var isUnityProbabilityArray = require( '@stdlib/assert-is-unity-probability-array' );\n*\n* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] );\n* // returns true\n*\n* bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) );\n* // returns true\n*\n* bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] );\n* // returns false\n*\n* bool = isUnityProbabilityArray( [ 3.14, 0.0 ] );\n* // returns false\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,EAAe,QAAS,+BAAgC,EACxDC,EAAU,QAAS,yBAA0B,EAC7CC,EAAW,QAAS,0BAA2B,EAAE,YACjDC,EAAU,QAAS,6CAA8C,EACjEC,EAAmB,QAAS,oCAAqC,EA2BrE,SAASC,EAAyBC,EAAI,CACrC,IAAIC,EACAC,EACJ,GAAKP,EAASK,CAAE,EAAI,CAEnB,IADAC,EAAM,EACAC,EAAI,EAAGA,EAAIF,EAAE,OAAQE,IAAM,CAChC,GACC,CAACN,EAAUI,EAAGE,CAAE,CAAE,GAClBF,EAAGE,CAAE,EAAI,GACTF,EAAGE,CAAE,EAAI,EAET,MAAO,GAERD,GAAOD,EAAGE,CAAE,CACb,CACA,OAASL,EAASI,EAAK,CAAI,GAAKH,CACjC,CACA,GAAKJ,EAAcM,CAAE,EAAI,CAExB,IADAC,EAAM,EACAC,EAAI,EAAGA,EAAIF,EAAE,OAAQE,IAAM,CAChC,GACCF,EAAGE,CAAE,EAAI,GACTF,EAAGE,CAAE,EAAI,EAET,MAAO,GAERD,GAAOD,EAAGE,CAAE,CACb,CACA,OAASL,EAASI,EAAK,CAAI,GAAKH,CACjC,CACA,MAAO,EACR,CAKAL,EAAO,QAAUM,IC9CjB,IAAII,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isTypedArray", "isArray", "isNumber", "absdiff", "FLOAT64_SQRT_EPS", "isUnityProbabilityArray", "v", "sum", "i", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index a2414be..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,29 +0,0 @@ - -{{alias}}( value ) - Tests if a value is an array of probabilities that sum to one. - - Parameters - ---------- - value: any - Value to test. - - Returns - ------- - bool: boolean - Boolean indicating whether value is an array of probabilities that sum - to one. - - Examples - -------- - > var bool = {{alias}}( [ 0.25, 0.5, 0.25 ] ) - true - > bool = {{alias}}( new {{alias:@stdlib/array/uint8}}( [ 0, 1 ] ) ) - true - > bool = {{alias}}( [ 0.4, 0.4, 0.4 ] ) - false - > bool = {{alias}}( [ 3.14, 0.0 ] ) - false - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 6b41658..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,34 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import isUnityProbabilityArray = require( './index' ); - - -// TESTS // - -// The function returns a boolean... -{ - isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] ); // $ExpectType boolean - isUnityProbabilityArray( [ 2, 3 ] ); // $ExpectType boolean -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - isUnityProbabilityArray(); // $ExpectError - isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ], 123 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index b0b6bbc..0000000 --- a/examples/index.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var Uint8Array = require( '@stdlib/array-uint8' ); -var isUnityProbabilityArray = require( './../lib' ); - -var arr = [ 0.0, 1.0 ]; -console.log( isUnityProbabilityArray( arr ) ); -// => true - -arr = [ 0.5, 0.25, 0.25 ]; -console.log( isUnityProbabilityArray( arr ) ); -// => true - -arr = new Uint8Array( [ 0, 0, 1, 0 ] ); -console.log( isUnityProbabilityArray( arr ) ); -// => true - -arr = [ 0.4, 0.4, 0.4 ]; -console.log( isUnityProbabilityArray( arr ) ); -// => false - -arr = [ 3.14, -1.0 ]; -console.log( isUnityProbabilityArray( arr ) ); -// => false - -console.log( isUnityProbabilityArray( [] ) ); -// => false - -console.log( isUnityProbabilityArray( null ) ); -// => false diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..08d3bcb --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-typed-array@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array@v0.2.2-esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-number@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/math-base-utils-absolute-difference@v0.3.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/constants-float64-sqrt-eps@v0.2.2-esm/index.mjs";function n(n){var d,m;if(t(n)){for(d=0,m=0;m1||n[m]<0)return!1;d+=n[m]}return r(d,1)<=i}if(s(n)){for(d=0,m=0;m1||n[m]<0)return!1;d+=n[m]}return r(d,1)<=i}return!1}export{n as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..08904b0 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isTypedArray from '@stdlib/assert-is-typed-array';\nimport isArray from '@stdlib/assert-is-array';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport absdiff from '@stdlib/math-base-utils-absolute-difference';\nimport FLOAT64_SQRT_EPS from '@stdlib/constants-float64-sqrt-eps';\n\n\n// MAIN //\n\n/**\n* Tests if a value is an array of probabilities that sum to one.\n*\n* @param {*} v - value to test\n* @returns {boolean} boolean indicating if a value is a probability array\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] );\n* // returns true\n*\n* @example\n* var bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) );\n* // returns true\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] );\n* // returns false\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 3.14, 0.0 ] );\n* // returns false\n*/\nfunction isUnityProbabilityArray( v ) {\n\tvar sum;\n\tvar i;\n\tif ( isArray( v ) ) {\n\t\tsum = 0.0;\n\t\tfor ( i = 0; i < v.length; i++ ) {\n\t\t\tif (\n\t\t\t\t!isNumber( v[ i ] ) ||\n\t\t\t\tv[ i ] > 1.0 ||\n\t\t\t\tv[ i ] < 0.0\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tsum += v[ i ];\n\t\t}\n\t\treturn ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS );\n\t}\n\tif ( isTypedArray( v ) ) {\n\t\tsum = 0.0;\n\t\tfor ( i = 0; i < v.length; i++ ) {\n\t\t\tif (\n\t\t\t\tv[ i ] > 1.0 ||\n\t\t\t\tv[ i ] < 0.0\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tsum += v[ i ];\n\t\t}\n\t\treturn ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS );\n\t}\n\treturn false;\n}\n\n\n// EXPORTS //\n\nexport default isUnityProbabilityArray;\n"],"names":["isUnityProbabilityArray","v","sum","i","isArray","length","isNumber","absdiff","FLOAT64_SQRT_EPS","isTypedArray"],"mappings":";;ufAqDA,SAASA,EAAyBC,GACjC,IAAIC,EACAC,EACJ,GAAKC,EAASH,GAAM,CAEnB,IADAC,EAAM,EACAC,EAAI,EAAGA,EAAIF,EAAEI,OAAQF,IAAM,CAChC,IACEG,EAAUL,EAAGE,KACdF,EAAGE,GAAM,GACTF,EAAGE,GAAM,EAET,OAAO,EAERD,GAAOD,EAAGE,EACV,CACD,OAASI,EAASL,EAAK,IAASM,CAChC,CACD,GAAKC,EAAcR,GAAM,CAExB,IADAC,EAAM,EACAC,EAAI,EAAGA,EAAIF,EAAEI,OAAQF,IAAM,CAChC,GACCF,EAAGE,GAAM,GACTF,EAAGE,GAAM,EAET,OAAO,EAERD,GAAOD,EAAGE,EACV,CACD,OAASI,EAASL,EAAK,IAASM,CAChC,CACD,OAAO,CACR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 13a67d1..0000000 --- a/lib/index.js +++ /dev/null @@ -1,49 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Test if a value is an array of probabilities that sum to one. -* -* @module @stdlib/assert-is-unity-probability-array -* -* @example -* var isUnityProbabilityArray = require( '@stdlib/assert-is-unity-probability-array' ); -* -* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] ); -* // returns true -* -* bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) ); -* // returns true -* -* bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] ); -* // returns false -* -* bool = isUnityProbabilityArray( [ 3.14, 0.0 ] ); -* // returns false -*/ - -// 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 d0bda40..0000000 --- a/lib/main.js +++ /dev/null @@ -1,90 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -var isArray = require( '@stdlib/assert-is-array' ); -var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var absdiff = require( '@stdlib/math-base-utils-absolute-difference' ); -var FLOAT64_SQRT_EPS = require( '@stdlib/constants-float64-sqrt-eps' ); - - -// MAIN // - -/** -* Tests if a value is an array of probabilities that sum to one. -* -* @param {*} v - value to test -* @returns {boolean} boolean indicating if a value is a probability array -* -* @example -* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] ); -* // returns true -* -* @example -* var bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) ); -* // returns true -* -* @example -* var bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] ); -* // returns false -* -* @example -* var bool = isUnityProbabilityArray( [ 3.14, 0.0 ] ); -* // returns false -*/ -function isUnityProbabilityArray( v ) { - var sum; - var i; - if ( isArray( v ) ) { - sum = 0.0; - for ( i = 0; i < v.length; i++ ) { - if ( - !isNumber( v[ i ] ) || - v[ i ] > 1.0 || - v[ i ] < 0.0 - ) { - return false; - } - sum += v[ i ]; - } - return ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS ); - } - if ( isTypedArray( v ) ) { - sum = 0.0; - for ( i = 0; i < v.length; i++ ) { - if ( - v[ i ] > 1.0 || - v[ i ] < 0.0 - ) { - return false; - } - sum += v[ i ]; - } - return ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS ); - } - return false; -} - - -// EXPORTS // - -module.exports = isUnityProbabilityArray; diff --git a/package.json b/package.json index 2375604..9ba851e 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.2", "description": "Test if a value is an array of probabilities that sum to one.", "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" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,47 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-array": "^0.2.2", - "@stdlib/assert-is-number": "^0.2.2", - "@stdlib/assert-is-typed-array": "^0.2.2", - "@stdlib/constants-float64-sqrt-eps": "^0.2.2", - "@stdlib/math-base-utils-absolute-difference": "^0.3.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/array-float32": "^0.2.2", - "@stdlib/array-float64": "^0.2.2", - "@stdlib/array-int16": "^0.2.2", - "@stdlib/array-int32": "^0.2.2", - "@stdlib/array-int8": "^0.2.2", - "@stdlib/array-uint16": "^0.2.2", - "@stdlib/array-uint32": "^0.2.2", - "@stdlib/array-uint8": "^0.2.2", - "@stdlib/array-uint8c": "^0.2.2", - "@stdlib/assert-is-boolean": "^0.2.2", - "@stdlib/buffer-from-array": "^0.2.2", - "@stdlib/math-base-special-pow": "^0.3.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.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdassert", @@ -105,4 +41,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..2282772 --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index a0424fb..0000000 --- a/test/test.js +++ /dev/null @@ -1,106 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Int8Array = require( '@stdlib/array-int8' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Float64Array = require( '@stdlib/array-float64' ); -var array2buffer = require( '@stdlib/buffer-from-array' ); -var isUnityProbabilityArray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof isUnityProbabilityArray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns `true` if provided an array of probabilities that sum to one', function test( t ) { - var values; - var i; - - values = [ - new Int8Array( [ 0, 0, 1 ] ), - new Uint8Array( [ 1, 0, 0 ] ), - new Uint8ClampedArray( [ 0, 1 ] ), - new Int16Array( [ 0, 0, 1, 0 ] ), - new Uint16Array( [ 1 ] ), - new Int32Array( [ 1, 0, 0 ] ), - new Uint32Array( [ 0, 1, 0 ] ), - new Float32Array( [ 0.0, 0.5, 0.5 ] ), - new Float64Array( [ 0.25, 0.25, 0.5 ] ), - [ 0.5, 0.25, 0.25 ] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.strictEqual( isUnityProbabilityArray( values[i] ), true, 'returns true when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function allows a difference in sum within floating-point epsilon', function test( t ) { - var bool = isUnityProbabilityArray( [ 0.1, 0.2, 0.1, 0.1, 0.2, 0.2, 0.1 ] ); - t.strictEqual( bool, true, 'returns true' ); - t.end(); -}); - -tape( 'the function returns `false` if not provided an array of probabilities that sum to one', function test( t ) { - var values; - var i; - - values = [ - '10', - '01', - '0.5', - '5', - 5, - NaN, - null, - void 0, - true, - [], - [ 5, null ], - [ 5, '5' ], - [ 1.0, 3.14 ], - [ -1.0, 1.0, 1.0 ], - [ 0.25, 0.33, 0.5 ], - new Float64Array( [ 0.25, 0.33, 0.5 ] ), - new Float64Array( [ 0.25, 1.33, 0.5 ] ), - new Float64Array( [ 0.25, -0.33, 0.5 ] ), - {}, - function noop() {}, - array2buffer( [ 1, 1, 0 ] ) - ]; - - for ( i = 0; i < values.length; i++ ) { - t.strictEqual( isUnityProbabilityArray( values[i] ), false, 'returns false when provided '+values[i] ); - } - t.end(); -}); From 5e53fd1f2353e7e52dc6da40a38c726d2e5a4e90 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 3 Aug 2024 21:52:16 +0000 Subject: [PATCH 104/133] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 2385bbd..2375604 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,8 @@ "@stdlib/assert-is-number": "^0.2.2", "@stdlib/assert-is-typed-array": "^0.2.2", "@stdlib/constants-float64-sqrt-eps": "^0.2.2", - "@stdlib/math-base-utils-absolute-difference": "^0.3.2" + "@stdlib/math-base-utils-absolute-difference": "^0.3.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2" }, "devDependencies": { "@stdlib/array-float32": "^0.2.2", @@ -104,4 +105,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From fe94488e7f78224b0943679a06be16bcbe6307af Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 4 Aug 2024 01:07:27 +0000 Subject: [PATCH 105/133] Remove files --- index.d.ts | 48 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4895 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index 63a123d..0000000 --- a/index.d.ts +++ /dev/null @@ -1,48 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/** -* Tests if a value is an array of probabilities that sum to one. -* -* @param v - value to test -* @returns boolean indicating if a value is a probability array -* -* @example -* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] ); -* // returns true -* -* @example -* var bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) ); -* // returns true -* -* @example -* var bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] ); -* // returns false -* -* @example -* var bool = isUnityProbabilityArray( [ 3.14, 0.0 ] ); -* // returns false -*/ -declare function isUnityProbabilityArray( v: any ): v is ArrayLike; - - -// EXPORTS // - -export = isUnityProbabilityArray; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 08d3bcb..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-typed-array@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array@v0.2.2-esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-number@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/math-base-utils-absolute-difference@v0.3.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/constants-float64-sqrt-eps@v0.2.2-esm/index.mjs";function n(n){var d,m;if(t(n)){for(d=0,m=0;m1||n[m]<0)return!1;d+=n[m]}return r(d,1)<=i}if(s(n)){for(d=0,m=0;m1||n[m]<0)return!1;d+=n[m]}return r(d,1)<=i}return!1}export{n as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 08904b0..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isTypedArray from '@stdlib/assert-is-typed-array';\nimport isArray from '@stdlib/assert-is-array';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport absdiff from '@stdlib/math-base-utils-absolute-difference';\nimport FLOAT64_SQRT_EPS from '@stdlib/constants-float64-sqrt-eps';\n\n\n// MAIN //\n\n/**\n* Tests if a value is an array of probabilities that sum to one.\n*\n* @param {*} v - value to test\n* @returns {boolean} boolean indicating if a value is a probability array\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] );\n* // returns true\n*\n* @example\n* var bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) );\n* // returns true\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] );\n* // returns false\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 3.14, 0.0 ] );\n* // returns false\n*/\nfunction isUnityProbabilityArray( v ) {\n\tvar sum;\n\tvar i;\n\tif ( isArray( v ) ) {\n\t\tsum = 0.0;\n\t\tfor ( i = 0; i < v.length; i++ ) {\n\t\t\tif (\n\t\t\t\t!isNumber( v[ i ] ) ||\n\t\t\t\tv[ i ] > 1.0 ||\n\t\t\t\tv[ i ] < 0.0\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tsum += v[ i ];\n\t\t}\n\t\treturn ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS );\n\t}\n\tif ( isTypedArray( v ) ) {\n\t\tsum = 0.0;\n\t\tfor ( i = 0; i < v.length; i++ ) {\n\t\t\tif (\n\t\t\t\tv[ i ] > 1.0 ||\n\t\t\t\tv[ i ] < 0.0\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tsum += v[ i ];\n\t\t}\n\t\treturn ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS );\n\t}\n\treturn false;\n}\n\n\n// EXPORTS //\n\nexport default isUnityProbabilityArray;\n"],"names":["isUnityProbabilityArray","v","sum","i","isArray","length","isNumber","absdiff","FLOAT64_SQRT_EPS","isTypedArray"],"mappings":";;ufAqDA,SAASA,EAAyBC,GACjC,IAAIC,EACAC,EACJ,GAAKC,EAASH,GAAM,CAEnB,IADAC,EAAM,EACAC,EAAI,EAAGA,EAAIF,EAAEI,OAAQF,IAAM,CAChC,IACEG,EAAUL,EAAGE,KACdF,EAAGE,GAAM,GACTF,EAAGE,GAAM,EAET,OAAO,EAERD,GAAOD,EAAGE,EACV,CACD,OAASI,EAASL,EAAK,IAASM,CAChC,CACD,GAAKC,EAAcR,GAAM,CAExB,IADAC,EAAM,EACAC,EAAI,EAAGA,EAAIF,EAAEI,OAAQF,IAAM,CAChC,GACCF,EAAGE,GAAM,GACTF,EAAGE,GAAM,EAET,OAAO,EAERD,GAAOD,EAAGE,EACV,CACD,OAASI,EAASL,EAAK,IAASM,CAChC,CACD,OAAO,CACR"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 2282772..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From e6d4edbb6915d9cb33c0905cdcee0db66fde313a Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 4 Aug 2024 01:07:40 +0000 Subject: [PATCH 106/133] 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 | 164 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 43 +- SECURITY.md | 5 - benchmark/benchmark.js | 103 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 29 - docs/types/test.ts | 34 - examples/index.js | 48 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 49 - lib/main.js | 90 - package.json | 70 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 106 - 43 files changed, 4867 insertions(+), 4001 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 delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/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 c0b5e9e..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-08-03T20:14:18.553Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 75a4c32..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/assert/is-unity-probability-array) 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 5119885..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/assert/is-unity-probability-array) 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 3b386b0..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: '49 1 * * 1' - - # 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 + + ```
@@ -178,7 +169,7 @@ bool = isUnityProbabilityArray( null ); ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -245,9 +236,9 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/assert/is-probability]: https://github.com/stdlib-js/assert-is-probability +[@stdlib/assert/is-probability]: https://github.com/stdlib-js/assert-is-probability/tree/esm -[@stdlib/assert/is-probability-array]: https://github.com/stdlib-js/assert-is-probability-array +[@stdlib/assert/is-probability-array]: https://github.com/stdlib-js/assert-is-probability-array/tree/esm diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 510a5ed..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,103 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var isUnityProbabilityArray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x; - var i; - - x = []; - for ( i = 0; i < len; i++ ) { - x.push( 1.0/len ); - } - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: we are testing the worst case scenario where a function must scan the entire array before finding a failing value. - x[ len-1 ] = i * 3.14; - bool = isUnityProbabilityArray( x ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( isBoolean( bool ) ) { - b.pass( 'benchmark finished' ); - } else { - b.fail( 'should return a boolean' ); - } - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':len='+len, f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index 5a6810d..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/assert/is-unity-probability-array" -%% click B href "https://github.com/stdlib-js/assert-is-unity-probability-array/tree/main" -%% click C href "https://github.com/stdlib-js/assert-is-unity-probability-array/tree/production" -%% click D href "https://github.com/stdlib-js/assert-is-unity-probability-array/tree/esm" -%% click E href "https://github.com/stdlib-js/assert-is-unity-probability-array/tree/deno" -%% click F href "https://github.com/stdlib-js/assert-is-unity-probability-array/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/assert/is-unity-probability-array -[production-url]: https://github.com/stdlib-js/assert-is-unity-probability-array/tree/production -[deno-url]: https://github.com/stdlib-js/assert-is-unity-probability-array/tree/deno -[deno-readme]: https://github.com/stdlib-js/assert-is-unity-probability-array/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/assert-is-unity-probability-array/tree/umd -[umd-readme]: https://github.com/stdlib-js/assert-is-unity-probability-array/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/assert-is-unity-probability-array/tree/esm -[esm-readme]: https://github.com/stdlib-js/assert-is-unity-probability-array/blob/esm/README.md \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index c77d01e..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import isUnityProbabilityArray from '../docs/types/index'; -export = isUnityProbabilityArray; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 70d7801..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var f=function(r,i){return function(){return i||r((i={exports:{}}).exports,i),i.exports}};var u=f(function(m,s){ -var n=require('@stdlib/assert-is-typed-array/dist'),l=require('@stdlib/assert-is-array/dist'),o=require('@stdlib/assert-is-number/dist').isPrimitive,a=require('@stdlib/math-base-utils-absolute-difference/dist'),t=require('@stdlib/constants-float64-sqrt-eps/dist');function q(r){var i,e;if(l(r)){for(i=0,e=0;e1||r[e]<0)return!1;i+=r[e]}return a(i,1)<=t}if(n(r)){for(i=0,e=0;e1||r[e]<0)return!1;i+=r[e]}return a(i,1)<=t}return!1}s.exports=q -});var y=u();module.exports=y; -/** @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 387d5ad..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) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isTypedArray = require( '@stdlib/assert-is-typed-array' );\nvar isArray = require( '@stdlib/assert-is-array' );\nvar isNumber = require( '@stdlib/assert-is-number' ).isPrimitive;\nvar absdiff = require( '@stdlib/math-base-utils-absolute-difference' );\nvar FLOAT64_SQRT_EPS = require( '@stdlib/constants-float64-sqrt-eps' );\n\n\n// MAIN //\n\n/**\n* Tests if a value is an array of probabilities that sum to one.\n*\n* @param {*} v - value to test\n* @returns {boolean} boolean indicating if a value is a probability array\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] );\n* // returns true\n*\n* @example\n* var bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) );\n* // returns true\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] );\n* // returns false\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 3.14, 0.0 ] );\n* // returns false\n*/\nfunction isUnityProbabilityArray( v ) {\n\tvar sum;\n\tvar i;\n\tif ( isArray( v ) ) {\n\t\tsum = 0.0;\n\t\tfor ( i = 0; i < v.length; i++ ) {\n\t\t\tif (\n\t\t\t\t!isNumber( v[ i ] ) ||\n\t\t\t\tv[ i ] > 1.0 ||\n\t\t\t\tv[ i ] < 0.0\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tsum += v[ i ];\n\t\t}\n\t\treturn ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS );\n\t}\n\tif ( isTypedArray( v ) ) {\n\t\tsum = 0.0;\n\t\tfor ( i = 0; i < v.length; i++ ) {\n\t\t\tif (\n\t\t\t\tv[ i ] > 1.0 ||\n\t\t\t\tv[ i ] < 0.0\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tsum += v[ i ];\n\t\t}\n\t\treturn ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS );\n\t}\n\treturn false;\n}\n\n\n// EXPORTS //\n\nmodule.exports = isUnityProbabilityArray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Test if a value is an array of probabilities that sum to one.\n*\n* @module @stdlib/assert-is-unity-probability-array\n*\n* @example\n* var isUnityProbabilityArray = require( '@stdlib/assert-is-unity-probability-array' );\n*\n* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] );\n* // returns true\n*\n* bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) );\n* // returns true\n*\n* bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] );\n* // returns false\n*\n* bool = isUnityProbabilityArray( [ 3.14, 0.0 ] );\n* // returns false\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,EAAe,QAAS,+BAAgC,EACxDC,EAAU,QAAS,yBAA0B,EAC7CC,EAAW,QAAS,0BAA2B,EAAE,YACjDC,EAAU,QAAS,6CAA8C,EACjEC,EAAmB,QAAS,oCAAqC,EA2BrE,SAASC,EAAyBC,EAAI,CACrC,IAAIC,EACAC,EACJ,GAAKP,EAASK,CAAE,EAAI,CAEnB,IADAC,EAAM,EACAC,EAAI,EAAGA,EAAIF,EAAE,OAAQE,IAAM,CAChC,GACC,CAACN,EAAUI,EAAGE,CAAE,CAAE,GAClBF,EAAGE,CAAE,EAAI,GACTF,EAAGE,CAAE,EAAI,EAET,MAAO,GAERD,GAAOD,EAAGE,CAAE,CACb,CACA,OAASL,EAASI,EAAK,CAAI,GAAKH,CACjC,CACA,GAAKJ,EAAcM,CAAE,EAAI,CAExB,IADAC,EAAM,EACAC,EAAI,EAAGA,EAAIF,EAAE,OAAQE,IAAM,CAChC,GACCF,EAAGE,CAAE,EAAI,GACTF,EAAGE,CAAE,EAAI,EAET,MAAO,GAERD,GAAOD,EAAGE,CAAE,CACb,CACA,OAASL,EAASI,EAAK,CAAI,GAAKH,CACjC,CACA,MAAO,EACR,CAKAL,EAAO,QAAUM,IC9CjB,IAAII,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isTypedArray", "isArray", "isNumber", "absdiff", "FLOAT64_SQRT_EPS", "isUnityProbabilityArray", "v", "sum", "i", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index a2414be..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,29 +0,0 @@ - -{{alias}}( value ) - Tests if a value is an array of probabilities that sum to one. - - Parameters - ---------- - value: any - Value to test. - - Returns - ------- - bool: boolean - Boolean indicating whether value is an array of probabilities that sum - to one. - - Examples - -------- - > var bool = {{alias}}( [ 0.25, 0.5, 0.25 ] ) - true - > bool = {{alias}}( new {{alias:@stdlib/array/uint8}}( [ 0, 1 ] ) ) - true - > bool = {{alias}}( [ 0.4, 0.4, 0.4 ] ) - false - > bool = {{alias}}( [ 3.14, 0.0 ] ) - false - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 6b41658..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,34 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import isUnityProbabilityArray = require( './index' ); - - -// TESTS // - -// The function returns a boolean... -{ - isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] ); // $ExpectType boolean - isUnityProbabilityArray( [ 2, 3 ] ); // $ExpectType boolean -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - isUnityProbabilityArray(); // $ExpectError - isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ], 123 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index b0b6bbc..0000000 --- a/examples/index.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var Uint8Array = require( '@stdlib/array-uint8' ); -var isUnityProbabilityArray = require( './../lib' ); - -var arr = [ 0.0, 1.0 ]; -console.log( isUnityProbabilityArray( arr ) ); -// => true - -arr = [ 0.5, 0.25, 0.25 ]; -console.log( isUnityProbabilityArray( arr ) ); -// => true - -arr = new Uint8Array( [ 0, 0, 1, 0 ] ); -console.log( isUnityProbabilityArray( arr ) ); -// => true - -arr = [ 0.4, 0.4, 0.4 ]; -console.log( isUnityProbabilityArray( arr ) ); -// => false - -arr = [ 3.14, -1.0 ]; -console.log( isUnityProbabilityArray( arr ) ); -// => false - -console.log( isUnityProbabilityArray( [] ) ); -// => false - -console.log( isUnityProbabilityArray( null ) ); -// => false diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..08d3bcb --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-typed-array@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array@v0.2.2-esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-number@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/math-base-utils-absolute-difference@v0.3.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/constants-float64-sqrt-eps@v0.2.2-esm/index.mjs";function n(n){var d,m;if(t(n)){for(d=0,m=0;m1||n[m]<0)return!1;d+=n[m]}return r(d,1)<=i}if(s(n)){for(d=0,m=0;m1||n[m]<0)return!1;d+=n[m]}return r(d,1)<=i}return!1}export{n as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..08904b0 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isTypedArray from '@stdlib/assert-is-typed-array';\nimport isArray from '@stdlib/assert-is-array';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport absdiff from '@stdlib/math-base-utils-absolute-difference';\nimport FLOAT64_SQRT_EPS from '@stdlib/constants-float64-sqrt-eps';\n\n\n// MAIN //\n\n/**\n* Tests if a value is an array of probabilities that sum to one.\n*\n* @param {*} v - value to test\n* @returns {boolean} boolean indicating if a value is a probability array\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] );\n* // returns true\n*\n* @example\n* var bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) );\n* // returns true\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] );\n* // returns false\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 3.14, 0.0 ] );\n* // returns false\n*/\nfunction isUnityProbabilityArray( v ) {\n\tvar sum;\n\tvar i;\n\tif ( isArray( v ) ) {\n\t\tsum = 0.0;\n\t\tfor ( i = 0; i < v.length; i++ ) {\n\t\t\tif (\n\t\t\t\t!isNumber( v[ i ] ) ||\n\t\t\t\tv[ i ] > 1.0 ||\n\t\t\t\tv[ i ] < 0.0\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tsum += v[ i ];\n\t\t}\n\t\treturn ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS );\n\t}\n\tif ( isTypedArray( v ) ) {\n\t\tsum = 0.0;\n\t\tfor ( i = 0; i < v.length; i++ ) {\n\t\t\tif (\n\t\t\t\tv[ i ] > 1.0 ||\n\t\t\t\tv[ i ] < 0.0\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tsum += v[ i ];\n\t\t}\n\t\treturn ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS );\n\t}\n\treturn false;\n}\n\n\n// EXPORTS //\n\nexport default isUnityProbabilityArray;\n"],"names":["isUnityProbabilityArray","v","sum","i","isArray","length","isNumber","absdiff","FLOAT64_SQRT_EPS","isTypedArray"],"mappings":";;ufAqDA,SAASA,EAAyBC,GACjC,IAAIC,EACAC,EACJ,GAAKC,EAASH,GAAM,CAEnB,IADAC,EAAM,EACAC,EAAI,EAAGA,EAAIF,EAAEI,OAAQF,IAAM,CAChC,IACEG,EAAUL,EAAGE,KACdF,EAAGE,GAAM,GACTF,EAAGE,GAAM,EAET,OAAO,EAERD,GAAOD,EAAGE,EACV,CACD,OAASI,EAASL,EAAK,IAASM,CAChC,CACD,GAAKC,EAAcR,GAAM,CAExB,IADAC,EAAM,EACAC,EAAI,EAAGA,EAAIF,EAAEI,OAAQF,IAAM,CAChC,GACCF,EAAGE,GAAM,GACTF,EAAGE,GAAM,EAET,OAAO,EAERD,GAAOD,EAAGE,EACV,CACD,OAASI,EAASL,EAAK,IAASM,CAChC,CACD,OAAO,CACR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 13a67d1..0000000 --- a/lib/index.js +++ /dev/null @@ -1,49 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Test if a value is an array of probabilities that sum to one. -* -* @module @stdlib/assert-is-unity-probability-array -* -* @example -* var isUnityProbabilityArray = require( '@stdlib/assert-is-unity-probability-array' ); -* -* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] ); -* // returns true -* -* bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) ); -* // returns true -* -* bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] ); -* // returns false -* -* bool = isUnityProbabilityArray( [ 3.14, 0.0 ] ); -* // returns false -*/ - -// 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 d0bda40..0000000 --- a/lib/main.js +++ /dev/null @@ -1,90 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -var isArray = require( '@stdlib/assert-is-array' ); -var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var absdiff = require( '@stdlib/math-base-utils-absolute-difference' ); -var FLOAT64_SQRT_EPS = require( '@stdlib/constants-float64-sqrt-eps' ); - - -// MAIN // - -/** -* Tests if a value is an array of probabilities that sum to one. -* -* @param {*} v - value to test -* @returns {boolean} boolean indicating if a value is a probability array -* -* @example -* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] ); -* // returns true -* -* @example -* var bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) ); -* // returns true -* -* @example -* var bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] ); -* // returns false -* -* @example -* var bool = isUnityProbabilityArray( [ 3.14, 0.0 ] ); -* // returns false -*/ -function isUnityProbabilityArray( v ) { - var sum; - var i; - if ( isArray( v ) ) { - sum = 0.0; - for ( i = 0; i < v.length; i++ ) { - if ( - !isNumber( v[ i ] ) || - v[ i ] > 1.0 || - v[ i ] < 0.0 - ) { - return false; - } - sum += v[ i ]; - } - return ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS ); - } - if ( isTypedArray( v ) ) { - sum = 0.0; - for ( i = 0; i < v.length; i++ ) { - if ( - v[ i ] > 1.0 || - v[ i ] < 0.0 - ) { - return false; - } - sum += v[ i ]; - } - return ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS ); - } - return false; -} - - -// EXPORTS // - -module.exports = isUnityProbabilityArray; diff --git a/package.json b/package.json index 2375604..9ba851e 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.2", "description": "Test if a value is an array of probabilities that sum to one.", "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" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,47 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-array": "^0.2.2", - "@stdlib/assert-is-number": "^0.2.2", - "@stdlib/assert-is-typed-array": "^0.2.2", - "@stdlib/constants-float64-sqrt-eps": "^0.2.2", - "@stdlib/math-base-utils-absolute-difference": "^0.3.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/array-float32": "^0.2.2", - "@stdlib/array-float64": "^0.2.2", - "@stdlib/array-int16": "^0.2.2", - "@stdlib/array-int32": "^0.2.2", - "@stdlib/array-int8": "^0.2.2", - "@stdlib/array-uint16": "^0.2.2", - "@stdlib/array-uint32": "^0.2.2", - "@stdlib/array-uint8": "^0.2.2", - "@stdlib/array-uint8c": "^0.2.2", - "@stdlib/assert-is-boolean": "^0.2.2", - "@stdlib/buffer-from-array": "^0.2.2", - "@stdlib/math-base-special-pow": "^0.3.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.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdassert", @@ -105,4 +41,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..2282772 --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index a0424fb..0000000 --- a/test/test.js +++ /dev/null @@ -1,106 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Int8Array = require( '@stdlib/array-int8' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Float64Array = require( '@stdlib/array-float64' ); -var array2buffer = require( '@stdlib/buffer-from-array' ); -var isUnityProbabilityArray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof isUnityProbabilityArray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns `true` if provided an array of probabilities that sum to one', function test( t ) { - var values; - var i; - - values = [ - new Int8Array( [ 0, 0, 1 ] ), - new Uint8Array( [ 1, 0, 0 ] ), - new Uint8ClampedArray( [ 0, 1 ] ), - new Int16Array( [ 0, 0, 1, 0 ] ), - new Uint16Array( [ 1 ] ), - new Int32Array( [ 1, 0, 0 ] ), - new Uint32Array( [ 0, 1, 0 ] ), - new Float32Array( [ 0.0, 0.5, 0.5 ] ), - new Float64Array( [ 0.25, 0.25, 0.5 ] ), - [ 0.5, 0.25, 0.25 ] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.strictEqual( isUnityProbabilityArray( values[i] ), true, 'returns true when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function allows a difference in sum within floating-point epsilon', function test( t ) { - var bool = isUnityProbabilityArray( [ 0.1, 0.2, 0.1, 0.1, 0.2, 0.2, 0.1 ] ); - t.strictEqual( bool, true, 'returns true' ); - t.end(); -}); - -tape( 'the function returns `false` if not provided an array of probabilities that sum to one', function test( t ) { - var values; - var i; - - values = [ - '10', - '01', - '0.5', - '5', - 5, - NaN, - null, - void 0, - true, - [], - [ 5, null ], - [ 5, '5' ], - [ 1.0, 3.14 ], - [ -1.0, 1.0, 1.0 ], - [ 0.25, 0.33, 0.5 ], - new Float64Array( [ 0.25, 0.33, 0.5 ] ), - new Float64Array( [ 0.25, 1.33, 0.5 ] ), - new Float64Array( [ 0.25, -0.33, 0.5 ] ), - {}, - function noop() {}, - array2buffer( [ 1, 1, 0 ] ) - ]; - - for ( i = 0; i < values.length; i++ ) { - t.strictEqual( isUnityProbabilityArray( values[i] ), false, 'returns false when provided '+values[i] ); - } - t.end(); -}); From 271649c5e5ab3700759cb7c5990f4534846e1124 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Sep 2024 06:57:26 +0000 Subject: [PATCH 107/133] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 2385bbd..2375604 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,8 @@ "@stdlib/assert-is-number": "^0.2.2", "@stdlib/assert-is-typed-array": "^0.2.2", "@stdlib/constants-float64-sqrt-eps": "^0.2.2", - "@stdlib/math-base-utils-absolute-difference": "^0.3.2" + "@stdlib/math-base-utils-absolute-difference": "^0.3.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2" }, "devDependencies": { "@stdlib/array-float32": "^0.2.2", @@ -104,4 +105,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 2167f5c81479bcc975e0e9f1a8b88ad040dab9dc Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Sep 2024 11:11:25 +0000 Subject: [PATCH 108/133] Remove files --- index.d.ts | 48 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4895 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index 63a123d..0000000 --- a/index.d.ts +++ /dev/null @@ -1,48 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/** -* Tests if a value is an array of probabilities that sum to one. -* -* @param v - value to test -* @returns boolean indicating if a value is a probability array -* -* @example -* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] ); -* // returns true -* -* @example -* var bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) ); -* // returns true -* -* @example -* var bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] ); -* // returns false -* -* @example -* var bool = isUnityProbabilityArray( [ 3.14, 0.0 ] ); -* // returns false -*/ -declare function isUnityProbabilityArray( v: any ): v is ArrayLike; - - -// EXPORTS // - -export = isUnityProbabilityArray; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 08d3bcb..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-typed-array@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array@v0.2.2-esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-number@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/math-base-utils-absolute-difference@v0.3.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/constants-float64-sqrt-eps@v0.2.2-esm/index.mjs";function n(n){var d,m;if(t(n)){for(d=0,m=0;m1||n[m]<0)return!1;d+=n[m]}return r(d,1)<=i}if(s(n)){for(d=0,m=0;m1||n[m]<0)return!1;d+=n[m]}return r(d,1)<=i}return!1}export{n as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 08904b0..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isTypedArray from '@stdlib/assert-is-typed-array';\nimport isArray from '@stdlib/assert-is-array';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport absdiff from '@stdlib/math-base-utils-absolute-difference';\nimport FLOAT64_SQRT_EPS from '@stdlib/constants-float64-sqrt-eps';\n\n\n// MAIN //\n\n/**\n* Tests if a value is an array of probabilities that sum to one.\n*\n* @param {*} v - value to test\n* @returns {boolean} boolean indicating if a value is a probability array\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] );\n* // returns true\n*\n* @example\n* var bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) );\n* // returns true\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] );\n* // returns false\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 3.14, 0.0 ] );\n* // returns false\n*/\nfunction isUnityProbabilityArray( v ) {\n\tvar sum;\n\tvar i;\n\tif ( isArray( v ) ) {\n\t\tsum = 0.0;\n\t\tfor ( i = 0; i < v.length; i++ ) {\n\t\t\tif (\n\t\t\t\t!isNumber( v[ i ] ) ||\n\t\t\t\tv[ i ] > 1.0 ||\n\t\t\t\tv[ i ] < 0.0\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tsum += v[ i ];\n\t\t}\n\t\treturn ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS );\n\t}\n\tif ( isTypedArray( v ) ) {\n\t\tsum = 0.0;\n\t\tfor ( i = 0; i < v.length; i++ ) {\n\t\t\tif (\n\t\t\t\tv[ i ] > 1.0 ||\n\t\t\t\tv[ i ] < 0.0\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tsum += v[ i ];\n\t\t}\n\t\treturn ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS );\n\t}\n\treturn false;\n}\n\n\n// EXPORTS //\n\nexport default isUnityProbabilityArray;\n"],"names":["isUnityProbabilityArray","v","sum","i","isArray","length","isNumber","absdiff","FLOAT64_SQRT_EPS","isTypedArray"],"mappings":";;ufAqDA,SAASA,EAAyBC,GACjC,IAAIC,EACAC,EACJ,GAAKC,EAASH,GAAM,CAEnB,IADAC,EAAM,EACAC,EAAI,EAAGA,EAAIF,EAAEI,OAAQF,IAAM,CAChC,IACEG,EAAUL,EAAGE,KACdF,EAAGE,GAAM,GACTF,EAAGE,GAAM,EAET,OAAO,EAERD,GAAOD,EAAGE,EACV,CACD,OAASI,EAASL,EAAK,IAASM,CAChC,CACD,GAAKC,EAAcR,GAAM,CAExB,IADAC,EAAM,EACAC,EAAI,EAAGA,EAAIF,EAAEI,OAAQF,IAAM,CAChC,GACCF,EAAGE,GAAM,GACTF,EAAGE,GAAM,EAET,OAAO,EAERD,GAAOD,EAAGE,EACV,CACD,OAASI,EAASL,EAAK,IAASM,CAChC,CACD,OAAO,CACR"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 2282772..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 664cfb439945f718f3956b67dbfa93222fae432e Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Sep 2024 11:11:38 +0000 Subject: [PATCH 109/133] 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 | 163 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 43 +- SECURITY.md | 5 - benchmark/benchmark.js | 103 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 29 - docs/types/test.ts | 34 - examples/index.js | 48 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 49 - lib/main.js | 90 - package.json | 70 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 106 - 43 files changed, 4867 insertions(+), 4000 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 delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/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 ff93483..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-09-01T05:07:24.621Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 75a4c32..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/assert/is-unity-probability-array) 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 5119885..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/assert/is-unity-probability-array) 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 3b386b0..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: '49 1 * * 1' - - # 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 + + ```
@@ -178,7 +169,7 @@ bool = isUnityProbabilityArray( null ); ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -245,9 +236,9 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/assert/is-probability]: https://github.com/stdlib-js/assert-is-probability +[@stdlib/assert/is-probability]: https://github.com/stdlib-js/assert-is-probability/tree/esm -[@stdlib/assert/is-probability-array]: https://github.com/stdlib-js/assert-is-probability-array +[@stdlib/assert/is-probability-array]: https://github.com/stdlib-js/assert-is-probability-array/tree/esm diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 510a5ed..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,103 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var isUnityProbabilityArray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x; - var i; - - x = []; - for ( i = 0; i < len; i++ ) { - x.push( 1.0/len ); - } - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: we are testing the worst case scenario where a function must scan the entire array before finding a failing value. - x[ len-1 ] = i * 3.14; - bool = isUnityProbabilityArray( x ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( isBoolean( bool ) ) { - b.pass( 'benchmark finished' ); - } else { - b.fail( 'should return a boolean' ); - } - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':len='+len, f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index 5a6810d..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/assert/is-unity-probability-array" -%% click B href "https://github.com/stdlib-js/assert-is-unity-probability-array/tree/main" -%% click C href "https://github.com/stdlib-js/assert-is-unity-probability-array/tree/production" -%% click D href "https://github.com/stdlib-js/assert-is-unity-probability-array/tree/esm" -%% click E href "https://github.com/stdlib-js/assert-is-unity-probability-array/tree/deno" -%% click F href "https://github.com/stdlib-js/assert-is-unity-probability-array/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/assert/is-unity-probability-array -[production-url]: https://github.com/stdlib-js/assert-is-unity-probability-array/tree/production -[deno-url]: https://github.com/stdlib-js/assert-is-unity-probability-array/tree/deno -[deno-readme]: https://github.com/stdlib-js/assert-is-unity-probability-array/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/assert-is-unity-probability-array/tree/umd -[umd-readme]: https://github.com/stdlib-js/assert-is-unity-probability-array/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/assert-is-unity-probability-array/tree/esm -[esm-readme]: https://github.com/stdlib-js/assert-is-unity-probability-array/blob/esm/README.md \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index c77d01e..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import isUnityProbabilityArray from '../docs/types/index'; -export = isUnityProbabilityArray; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 70d7801..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var f=function(r,i){return function(){return i||r((i={exports:{}}).exports,i),i.exports}};var u=f(function(m,s){ -var n=require('@stdlib/assert-is-typed-array/dist'),l=require('@stdlib/assert-is-array/dist'),o=require('@stdlib/assert-is-number/dist').isPrimitive,a=require('@stdlib/math-base-utils-absolute-difference/dist'),t=require('@stdlib/constants-float64-sqrt-eps/dist');function q(r){var i,e;if(l(r)){for(i=0,e=0;e1||r[e]<0)return!1;i+=r[e]}return a(i,1)<=t}if(n(r)){for(i=0,e=0;e1||r[e]<0)return!1;i+=r[e]}return a(i,1)<=t}return!1}s.exports=q -});var y=u();module.exports=y; -/** @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 387d5ad..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) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isTypedArray = require( '@stdlib/assert-is-typed-array' );\nvar isArray = require( '@stdlib/assert-is-array' );\nvar isNumber = require( '@stdlib/assert-is-number' ).isPrimitive;\nvar absdiff = require( '@stdlib/math-base-utils-absolute-difference' );\nvar FLOAT64_SQRT_EPS = require( '@stdlib/constants-float64-sqrt-eps' );\n\n\n// MAIN //\n\n/**\n* Tests if a value is an array of probabilities that sum to one.\n*\n* @param {*} v - value to test\n* @returns {boolean} boolean indicating if a value is a probability array\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] );\n* // returns true\n*\n* @example\n* var bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) );\n* // returns true\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] );\n* // returns false\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 3.14, 0.0 ] );\n* // returns false\n*/\nfunction isUnityProbabilityArray( v ) {\n\tvar sum;\n\tvar i;\n\tif ( isArray( v ) ) {\n\t\tsum = 0.0;\n\t\tfor ( i = 0; i < v.length; i++ ) {\n\t\t\tif (\n\t\t\t\t!isNumber( v[ i ] ) ||\n\t\t\t\tv[ i ] > 1.0 ||\n\t\t\t\tv[ i ] < 0.0\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tsum += v[ i ];\n\t\t}\n\t\treturn ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS );\n\t}\n\tif ( isTypedArray( v ) ) {\n\t\tsum = 0.0;\n\t\tfor ( i = 0; i < v.length; i++ ) {\n\t\t\tif (\n\t\t\t\tv[ i ] > 1.0 ||\n\t\t\t\tv[ i ] < 0.0\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tsum += v[ i ];\n\t\t}\n\t\treturn ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS );\n\t}\n\treturn false;\n}\n\n\n// EXPORTS //\n\nmodule.exports = isUnityProbabilityArray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Test if a value is an array of probabilities that sum to one.\n*\n* @module @stdlib/assert-is-unity-probability-array\n*\n* @example\n* var isUnityProbabilityArray = require( '@stdlib/assert-is-unity-probability-array' );\n*\n* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] );\n* // returns true\n*\n* bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) );\n* // returns true\n*\n* bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] );\n* // returns false\n*\n* bool = isUnityProbabilityArray( [ 3.14, 0.0 ] );\n* // returns false\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,EAAe,QAAS,+BAAgC,EACxDC,EAAU,QAAS,yBAA0B,EAC7CC,EAAW,QAAS,0BAA2B,EAAE,YACjDC,EAAU,QAAS,6CAA8C,EACjEC,EAAmB,QAAS,oCAAqC,EA2BrE,SAASC,EAAyBC,EAAI,CACrC,IAAIC,EACAC,EACJ,GAAKP,EAASK,CAAE,EAAI,CAEnB,IADAC,EAAM,EACAC,EAAI,EAAGA,EAAIF,EAAE,OAAQE,IAAM,CAChC,GACC,CAACN,EAAUI,EAAGE,CAAE,CAAE,GAClBF,EAAGE,CAAE,EAAI,GACTF,EAAGE,CAAE,EAAI,EAET,MAAO,GAERD,GAAOD,EAAGE,CAAE,CACb,CACA,OAASL,EAASI,EAAK,CAAI,GAAKH,CACjC,CACA,GAAKJ,EAAcM,CAAE,EAAI,CAExB,IADAC,EAAM,EACAC,EAAI,EAAGA,EAAIF,EAAE,OAAQE,IAAM,CAChC,GACCF,EAAGE,CAAE,EAAI,GACTF,EAAGE,CAAE,EAAI,EAET,MAAO,GAERD,GAAOD,EAAGE,CAAE,CACb,CACA,OAASL,EAASI,EAAK,CAAI,GAAKH,CACjC,CACA,MAAO,EACR,CAKAL,EAAO,QAAUM,IC9CjB,IAAII,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isTypedArray", "isArray", "isNumber", "absdiff", "FLOAT64_SQRT_EPS", "isUnityProbabilityArray", "v", "sum", "i", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index a2414be..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,29 +0,0 @@ - -{{alias}}( value ) - Tests if a value is an array of probabilities that sum to one. - - Parameters - ---------- - value: any - Value to test. - - Returns - ------- - bool: boolean - Boolean indicating whether value is an array of probabilities that sum - to one. - - Examples - -------- - > var bool = {{alias}}( [ 0.25, 0.5, 0.25 ] ) - true - > bool = {{alias}}( new {{alias:@stdlib/array/uint8}}( [ 0, 1 ] ) ) - true - > bool = {{alias}}( [ 0.4, 0.4, 0.4 ] ) - false - > bool = {{alias}}( [ 3.14, 0.0 ] ) - false - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 6b41658..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,34 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import isUnityProbabilityArray = require( './index' ); - - -// TESTS // - -// The function returns a boolean... -{ - isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] ); // $ExpectType boolean - isUnityProbabilityArray( [ 2, 3 ] ); // $ExpectType boolean -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - isUnityProbabilityArray(); // $ExpectError - isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ], 123 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index b0b6bbc..0000000 --- a/examples/index.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var Uint8Array = require( '@stdlib/array-uint8' ); -var isUnityProbabilityArray = require( './../lib' ); - -var arr = [ 0.0, 1.0 ]; -console.log( isUnityProbabilityArray( arr ) ); -// => true - -arr = [ 0.5, 0.25, 0.25 ]; -console.log( isUnityProbabilityArray( arr ) ); -// => true - -arr = new Uint8Array( [ 0, 0, 1, 0 ] ); -console.log( isUnityProbabilityArray( arr ) ); -// => true - -arr = [ 0.4, 0.4, 0.4 ]; -console.log( isUnityProbabilityArray( arr ) ); -// => false - -arr = [ 3.14, -1.0 ]; -console.log( isUnityProbabilityArray( arr ) ); -// => false - -console.log( isUnityProbabilityArray( [] ) ); -// => false - -console.log( isUnityProbabilityArray( null ) ); -// => false diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..08d3bcb --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-typed-array@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array@v0.2.2-esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-number@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/math-base-utils-absolute-difference@v0.3.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/constants-float64-sqrt-eps@v0.2.2-esm/index.mjs";function n(n){var d,m;if(t(n)){for(d=0,m=0;m1||n[m]<0)return!1;d+=n[m]}return r(d,1)<=i}if(s(n)){for(d=0,m=0;m1||n[m]<0)return!1;d+=n[m]}return r(d,1)<=i}return!1}export{n as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..08904b0 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isTypedArray from '@stdlib/assert-is-typed-array';\nimport isArray from '@stdlib/assert-is-array';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport absdiff from '@stdlib/math-base-utils-absolute-difference';\nimport FLOAT64_SQRT_EPS from '@stdlib/constants-float64-sqrt-eps';\n\n\n// MAIN //\n\n/**\n* Tests if a value is an array of probabilities that sum to one.\n*\n* @param {*} v - value to test\n* @returns {boolean} boolean indicating if a value is a probability array\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] );\n* // returns true\n*\n* @example\n* var bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) );\n* // returns true\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] );\n* // returns false\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 3.14, 0.0 ] );\n* // returns false\n*/\nfunction isUnityProbabilityArray( v ) {\n\tvar sum;\n\tvar i;\n\tif ( isArray( v ) ) {\n\t\tsum = 0.0;\n\t\tfor ( i = 0; i < v.length; i++ ) {\n\t\t\tif (\n\t\t\t\t!isNumber( v[ i ] ) ||\n\t\t\t\tv[ i ] > 1.0 ||\n\t\t\t\tv[ i ] < 0.0\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tsum += v[ i ];\n\t\t}\n\t\treturn ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS );\n\t}\n\tif ( isTypedArray( v ) ) {\n\t\tsum = 0.0;\n\t\tfor ( i = 0; i < v.length; i++ ) {\n\t\t\tif (\n\t\t\t\tv[ i ] > 1.0 ||\n\t\t\t\tv[ i ] < 0.0\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tsum += v[ i ];\n\t\t}\n\t\treturn ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS );\n\t}\n\treturn false;\n}\n\n\n// EXPORTS //\n\nexport default isUnityProbabilityArray;\n"],"names":["isUnityProbabilityArray","v","sum","i","isArray","length","isNumber","absdiff","FLOAT64_SQRT_EPS","isTypedArray"],"mappings":";;ufAqDA,SAASA,EAAyBC,GACjC,IAAIC,EACAC,EACJ,GAAKC,EAASH,GAAM,CAEnB,IADAC,EAAM,EACAC,EAAI,EAAGA,EAAIF,EAAEI,OAAQF,IAAM,CAChC,IACEG,EAAUL,EAAGE,KACdF,EAAGE,GAAM,GACTF,EAAGE,GAAM,EAET,OAAO,EAERD,GAAOD,EAAGE,EACV,CACD,OAASI,EAASL,EAAK,IAASM,CAChC,CACD,GAAKC,EAAcR,GAAM,CAExB,IADAC,EAAM,EACAC,EAAI,EAAGA,EAAIF,EAAEI,OAAQF,IAAM,CAChC,GACCF,EAAGE,GAAM,GACTF,EAAGE,GAAM,EAET,OAAO,EAERD,GAAOD,EAAGE,EACV,CACD,OAASI,EAASL,EAAK,IAASM,CAChC,CACD,OAAO,CACR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 13a67d1..0000000 --- a/lib/index.js +++ /dev/null @@ -1,49 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Test if a value is an array of probabilities that sum to one. -* -* @module @stdlib/assert-is-unity-probability-array -* -* @example -* var isUnityProbabilityArray = require( '@stdlib/assert-is-unity-probability-array' ); -* -* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] ); -* // returns true -* -* bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) ); -* // returns true -* -* bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] ); -* // returns false -* -* bool = isUnityProbabilityArray( [ 3.14, 0.0 ] ); -* // returns false -*/ - -// 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 d0bda40..0000000 --- a/lib/main.js +++ /dev/null @@ -1,90 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -var isArray = require( '@stdlib/assert-is-array' ); -var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var absdiff = require( '@stdlib/math-base-utils-absolute-difference' ); -var FLOAT64_SQRT_EPS = require( '@stdlib/constants-float64-sqrt-eps' ); - - -// MAIN // - -/** -* Tests if a value is an array of probabilities that sum to one. -* -* @param {*} v - value to test -* @returns {boolean} boolean indicating if a value is a probability array -* -* @example -* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] ); -* // returns true -* -* @example -* var bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) ); -* // returns true -* -* @example -* var bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] ); -* // returns false -* -* @example -* var bool = isUnityProbabilityArray( [ 3.14, 0.0 ] ); -* // returns false -*/ -function isUnityProbabilityArray( v ) { - var sum; - var i; - if ( isArray( v ) ) { - sum = 0.0; - for ( i = 0; i < v.length; i++ ) { - if ( - !isNumber( v[ i ] ) || - v[ i ] > 1.0 || - v[ i ] < 0.0 - ) { - return false; - } - sum += v[ i ]; - } - return ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS ); - } - if ( isTypedArray( v ) ) { - sum = 0.0; - for ( i = 0; i < v.length; i++ ) { - if ( - v[ i ] > 1.0 || - v[ i ] < 0.0 - ) { - return false; - } - sum += v[ i ]; - } - return ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS ); - } - return false; -} - - -// EXPORTS // - -module.exports = isUnityProbabilityArray; diff --git a/package.json b/package.json index 2375604..9ba851e 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.2", "description": "Test if a value is an array of probabilities that sum to one.", "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" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,47 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-array": "^0.2.2", - "@stdlib/assert-is-number": "^0.2.2", - "@stdlib/assert-is-typed-array": "^0.2.2", - "@stdlib/constants-float64-sqrt-eps": "^0.2.2", - "@stdlib/math-base-utils-absolute-difference": "^0.3.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/array-float32": "^0.2.2", - "@stdlib/array-float64": "^0.2.2", - "@stdlib/array-int16": "^0.2.2", - "@stdlib/array-int32": "^0.2.2", - "@stdlib/array-int8": "^0.2.2", - "@stdlib/array-uint16": "^0.2.2", - "@stdlib/array-uint32": "^0.2.2", - "@stdlib/array-uint8": "^0.2.2", - "@stdlib/array-uint8c": "^0.2.2", - "@stdlib/assert-is-boolean": "^0.2.2", - "@stdlib/buffer-from-array": "^0.2.2", - "@stdlib/math-base-special-pow": "^0.3.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.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdassert", @@ -105,4 +41,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..2282772 --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index a0424fb..0000000 --- a/test/test.js +++ /dev/null @@ -1,106 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Int8Array = require( '@stdlib/array-int8' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Float64Array = require( '@stdlib/array-float64' ); -var array2buffer = require( '@stdlib/buffer-from-array' ); -var isUnityProbabilityArray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof isUnityProbabilityArray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns `true` if provided an array of probabilities that sum to one', function test( t ) { - var values; - var i; - - values = [ - new Int8Array( [ 0, 0, 1 ] ), - new Uint8Array( [ 1, 0, 0 ] ), - new Uint8ClampedArray( [ 0, 1 ] ), - new Int16Array( [ 0, 0, 1, 0 ] ), - new Uint16Array( [ 1 ] ), - new Int32Array( [ 1, 0, 0 ] ), - new Uint32Array( [ 0, 1, 0 ] ), - new Float32Array( [ 0.0, 0.5, 0.5 ] ), - new Float64Array( [ 0.25, 0.25, 0.5 ] ), - [ 0.5, 0.25, 0.25 ] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.strictEqual( isUnityProbabilityArray( values[i] ), true, 'returns true when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function allows a difference in sum within floating-point epsilon', function test( t ) { - var bool = isUnityProbabilityArray( [ 0.1, 0.2, 0.1, 0.1, 0.2, 0.2, 0.1 ] ); - t.strictEqual( bool, true, 'returns true' ); - t.end(); -}); - -tape( 'the function returns `false` if not provided an array of probabilities that sum to one', function test( t ) { - var values; - var i; - - values = [ - '10', - '01', - '0.5', - '5', - 5, - NaN, - null, - void 0, - true, - [], - [ 5, null ], - [ 5, '5' ], - [ 1.0, 3.14 ], - [ -1.0, 1.0, 1.0 ], - [ 0.25, 0.33, 0.5 ], - new Float64Array( [ 0.25, 0.33, 0.5 ] ), - new Float64Array( [ 0.25, 1.33, 0.5 ] ), - new Float64Array( [ 0.25, -0.33, 0.5 ] ), - {}, - function noop() {}, - array2buffer( [ 1, 1, 0 ] ) - ]; - - for ( i = 0; i < values.length; i++ ) { - t.strictEqual( isUnityProbabilityArray( values[i] ), false, 'returns false when provided '+values[i] ); - } - t.end(); -}); From 5a3b97979a323d3b05298ec2868b3d7e8b7f9b2a Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 1 Oct 2024 07:15:16 +0000 Subject: [PATCH 110/133] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 2385bbd..2375604 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,8 @@ "@stdlib/assert-is-number": "^0.2.2", "@stdlib/assert-is-typed-array": "^0.2.2", "@stdlib/constants-float64-sqrt-eps": "^0.2.2", - "@stdlib/math-base-utils-absolute-difference": "^0.3.2" + "@stdlib/math-base-utils-absolute-difference": "^0.3.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2" }, "devDependencies": { "@stdlib/array-float32": "^0.2.2", @@ -104,4 +105,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From ed12ae9f0ac19873be3c60af0126875714ad70f2 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 1 Oct 2024 11:49:06 +0000 Subject: [PATCH 111/133] Remove files --- index.d.ts | 48 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4895 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index 63a123d..0000000 --- a/index.d.ts +++ /dev/null @@ -1,48 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/** -* Tests if a value is an array of probabilities that sum to one. -* -* @param v - value to test -* @returns boolean indicating if a value is a probability array -* -* @example -* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] ); -* // returns true -* -* @example -* var bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) ); -* // returns true -* -* @example -* var bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] ); -* // returns false -* -* @example -* var bool = isUnityProbabilityArray( [ 3.14, 0.0 ] ); -* // returns false -*/ -declare function isUnityProbabilityArray( v: any ): v is ArrayLike; - - -// EXPORTS // - -export = isUnityProbabilityArray; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 08d3bcb..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-typed-array@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array@v0.2.2-esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-number@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/math-base-utils-absolute-difference@v0.3.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/constants-float64-sqrt-eps@v0.2.2-esm/index.mjs";function n(n){var d,m;if(t(n)){for(d=0,m=0;m1||n[m]<0)return!1;d+=n[m]}return r(d,1)<=i}if(s(n)){for(d=0,m=0;m1||n[m]<0)return!1;d+=n[m]}return r(d,1)<=i}return!1}export{n as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 08904b0..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isTypedArray from '@stdlib/assert-is-typed-array';\nimport isArray from '@stdlib/assert-is-array';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport absdiff from '@stdlib/math-base-utils-absolute-difference';\nimport FLOAT64_SQRT_EPS from '@stdlib/constants-float64-sqrt-eps';\n\n\n// MAIN //\n\n/**\n* Tests if a value is an array of probabilities that sum to one.\n*\n* @param {*} v - value to test\n* @returns {boolean} boolean indicating if a value is a probability array\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] );\n* // returns true\n*\n* @example\n* var bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) );\n* // returns true\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] );\n* // returns false\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 3.14, 0.0 ] );\n* // returns false\n*/\nfunction isUnityProbabilityArray( v ) {\n\tvar sum;\n\tvar i;\n\tif ( isArray( v ) ) {\n\t\tsum = 0.0;\n\t\tfor ( i = 0; i < v.length; i++ ) {\n\t\t\tif (\n\t\t\t\t!isNumber( v[ i ] ) ||\n\t\t\t\tv[ i ] > 1.0 ||\n\t\t\t\tv[ i ] < 0.0\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tsum += v[ i ];\n\t\t}\n\t\treturn ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS );\n\t}\n\tif ( isTypedArray( v ) ) {\n\t\tsum = 0.0;\n\t\tfor ( i = 0; i < v.length; i++ ) {\n\t\t\tif (\n\t\t\t\tv[ i ] > 1.0 ||\n\t\t\t\tv[ i ] < 0.0\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tsum += v[ i ];\n\t\t}\n\t\treturn ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS );\n\t}\n\treturn false;\n}\n\n\n// EXPORTS //\n\nexport default isUnityProbabilityArray;\n"],"names":["isUnityProbabilityArray","v","sum","i","isArray","length","isNumber","absdiff","FLOAT64_SQRT_EPS","isTypedArray"],"mappings":";;ufAqDA,SAASA,EAAyBC,GACjC,IAAIC,EACAC,EACJ,GAAKC,EAASH,GAAM,CAEnB,IADAC,EAAM,EACAC,EAAI,EAAGA,EAAIF,EAAEI,OAAQF,IAAM,CAChC,IACEG,EAAUL,EAAGE,KACdF,EAAGE,GAAM,GACTF,EAAGE,GAAM,EAET,OAAO,EAERD,GAAOD,EAAGE,EACV,CACD,OAASI,EAASL,EAAK,IAASM,CAChC,CACD,GAAKC,EAAcR,GAAM,CAExB,IADAC,EAAM,EACAC,EAAI,EAAGA,EAAIF,EAAEI,OAAQF,IAAM,CAChC,GACCF,EAAGE,GAAM,GACTF,EAAGE,GAAM,EAET,OAAO,EAERD,GAAOD,EAAGE,EACV,CACD,OAASI,EAASL,EAAK,IAASM,CAChC,CACD,OAAO,CACR"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 2282772..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 091f361193fbc9a096ef6816d1200f787d5f84bc Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 1 Oct 2024 11:49:26 +0000 Subject: [PATCH 112/133] 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 | 163 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 43 +- SECURITY.md | 5 - benchmark/benchmark.js | 103 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 29 - docs/types/test.ts | 34 - examples/index.js | 48 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 49 - lib/main.js | 90 - package.json | 70 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 106 - 43 files changed, 4867 insertions(+), 4000 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 delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/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 30fce16..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-10-01T05:19:06.570Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 75a4c32..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/assert/is-unity-probability-array) 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 5119885..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/assert/is-unity-probability-array) 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 3b386b0..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: '49 1 * * 1' - - # 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 + + ```
@@ -178,7 +169,7 @@ bool = isUnityProbabilityArray( null ); ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -245,9 +236,9 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/assert/is-probability]: https://github.com/stdlib-js/assert-is-probability +[@stdlib/assert/is-probability]: https://github.com/stdlib-js/assert-is-probability/tree/esm -[@stdlib/assert/is-probability-array]: https://github.com/stdlib-js/assert-is-probability-array +[@stdlib/assert/is-probability-array]: https://github.com/stdlib-js/assert-is-probability-array/tree/esm diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 510a5ed..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,103 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var isUnityProbabilityArray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x; - var i; - - x = []; - for ( i = 0; i < len; i++ ) { - x.push( 1.0/len ); - } - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: we are testing the worst case scenario where a function must scan the entire array before finding a failing value. - x[ len-1 ] = i * 3.14; - bool = isUnityProbabilityArray( x ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( isBoolean( bool ) ) { - b.pass( 'benchmark finished' ); - } else { - b.fail( 'should return a boolean' ); - } - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':len='+len, f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index 5a6810d..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/assert/is-unity-probability-array" -%% click B href "https://github.com/stdlib-js/assert-is-unity-probability-array/tree/main" -%% click C href "https://github.com/stdlib-js/assert-is-unity-probability-array/tree/production" -%% click D href "https://github.com/stdlib-js/assert-is-unity-probability-array/tree/esm" -%% click E href "https://github.com/stdlib-js/assert-is-unity-probability-array/tree/deno" -%% click F href "https://github.com/stdlib-js/assert-is-unity-probability-array/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/assert/is-unity-probability-array -[production-url]: https://github.com/stdlib-js/assert-is-unity-probability-array/tree/production -[deno-url]: https://github.com/stdlib-js/assert-is-unity-probability-array/tree/deno -[deno-readme]: https://github.com/stdlib-js/assert-is-unity-probability-array/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/assert-is-unity-probability-array/tree/umd -[umd-readme]: https://github.com/stdlib-js/assert-is-unity-probability-array/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/assert-is-unity-probability-array/tree/esm -[esm-readme]: https://github.com/stdlib-js/assert-is-unity-probability-array/blob/esm/README.md \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index c77d01e..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import isUnityProbabilityArray from '../docs/types/index'; -export = isUnityProbabilityArray; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 70d7801..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var f=function(r,i){return function(){return i||r((i={exports:{}}).exports,i),i.exports}};var u=f(function(m,s){ -var n=require('@stdlib/assert-is-typed-array/dist'),l=require('@stdlib/assert-is-array/dist'),o=require('@stdlib/assert-is-number/dist').isPrimitive,a=require('@stdlib/math-base-utils-absolute-difference/dist'),t=require('@stdlib/constants-float64-sqrt-eps/dist');function q(r){var i,e;if(l(r)){for(i=0,e=0;e1||r[e]<0)return!1;i+=r[e]}return a(i,1)<=t}if(n(r)){for(i=0,e=0;e1||r[e]<0)return!1;i+=r[e]}return a(i,1)<=t}return!1}s.exports=q -});var y=u();module.exports=y; -/** @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 387d5ad..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) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isTypedArray = require( '@stdlib/assert-is-typed-array' );\nvar isArray = require( '@stdlib/assert-is-array' );\nvar isNumber = require( '@stdlib/assert-is-number' ).isPrimitive;\nvar absdiff = require( '@stdlib/math-base-utils-absolute-difference' );\nvar FLOAT64_SQRT_EPS = require( '@stdlib/constants-float64-sqrt-eps' );\n\n\n// MAIN //\n\n/**\n* Tests if a value is an array of probabilities that sum to one.\n*\n* @param {*} v - value to test\n* @returns {boolean} boolean indicating if a value is a probability array\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] );\n* // returns true\n*\n* @example\n* var bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) );\n* // returns true\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] );\n* // returns false\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 3.14, 0.0 ] );\n* // returns false\n*/\nfunction isUnityProbabilityArray( v ) {\n\tvar sum;\n\tvar i;\n\tif ( isArray( v ) ) {\n\t\tsum = 0.0;\n\t\tfor ( i = 0; i < v.length; i++ ) {\n\t\t\tif (\n\t\t\t\t!isNumber( v[ i ] ) ||\n\t\t\t\tv[ i ] > 1.0 ||\n\t\t\t\tv[ i ] < 0.0\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tsum += v[ i ];\n\t\t}\n\t\treturn ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS );\n\t}\n\tif ( isTypedArray( v ) ) {\n\t\tsum = 0.0;\n\t\tfor ( i = 0; i < v.length; i++ ) {\n\t\t\tif (\n\t\t\t\tv[ i ] > 1.0 ||\n\t\t\t\tv[ i ] < 0.0\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tsum += v[ i ];\n\t\t}\n\t\treturn ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS );\n\t}\n\treturn false;\n}\n\n\n// EXPORTS //\n\nmodule.exports = isUnityProbabilityArray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Test if a value is an array of probabilities that sum to one.\n*\n* @module @stdlib/assert-is-unity-probability-array\n*\n* @example\n* var isUnityProbabilityArray = require( '@stdlib/assert-is-unity-probability-array' );\n*\n* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] );\n* // returns true\n*\n* bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) );\n* // returns true\n*\n* bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] );\n* // returns false\n*\n* bool = isUnityProbabilityArray( [ 3.14, 0.0 ] );\n* // returns false\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,EAAe,QAAS,+BAAgC,EACxDC,EAAU,QAAS,yBAA0B,EAC7CC,EAAW,QAAS,0BAA2B,EAAE,YACjDC,EAAU,QAAS,6CAA8C,EACjEC,EAAmB,QAAS,oCAAqC,EA2BrE,SAASC,EAAyBC,EAAI,CACrC,IAAIC,EACAC,EACJ,GAAKP,EAASK,CAAE,EAAI,CAEnB,IADAC,EAAM,EACAC,EAAI,EAAGA,EAAIF,EAAE,OAAQE,IAAM,CAChC,GACC,CAACN,EAAUI,EAAGE,CAAE,CAAE,GAClBF,EAAGE,CAAE,EAAI,GACTF,EAAGE,CAAE,EAAI,EAET,MAAO,GAERD,GAAOD,EAAGE,CAAE,CACb,CACA,OAASL,EAASI,EAAK,CAAI,GAAKH,CACjC,CACA,GAAKJ,EAAcM,CAAE,EAAI,CAExB,IADAC,EAAM,EACAC,EAAI,EAAGA,EAAIF,EAAE,OAAQE,IAAM,CAChC,GACCF,EAAGE,CAAE,EAAI,GACTF,EAAGE,CAAE,EAAI,EAET,MAAO,GAERD,GAAOD,EAAGE,CAAE,CACb,CACA,OAASL,EAASI,EAAK,CAAI,GAAKH,CACjC,CACA,MAAO,EACR,CAKAL,EAAO,QAAUM,IC9CjB,IAAII,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isTypedArray", "isArray", "isNumber", "absdiff", "FLOAT64_SQRT_EPS", "isUnityProbabilityArray", "v", "sum", "i", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index a2414be..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,29 +0,0 @@ - -{{alias}}( value ) - Tests if a value is an array of probabilities that sum to one. - - Parameters - ---------- - value: any - Value to test. - - Returns - ------- - bool: boolean - Boolean indicating whether value is an array of probabilities that sum - to one. - - Examples - -------- - > var bool = {{alias}}( [ 0.25, 0.5, 0.25 ] ) - true - > bool = {{alias}}( new {{alias:@stdlib/array/uint8}}( [ 0, 1 ] ) ) - true - > bool = {{alias}}( [ 0.4, 0.4, 0.4 ] ) - false - > bool = {{alias}}( [ 3.14, 0.0 ] ) - false - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 6b41658..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,34 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import isUnityProbabilityArray = require( './index' ); - - -// TESTS // - -// The function returns a boolean... -{ - isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] ); // $ExpectType boolean - isUnityProbabilityArray( [ 2, 3 ] ); // $ExpectType boolean -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - isUnityProbabilityArray(); // $ExpectError - isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ], 123 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index b0b6bbc..0000000 --- a/examples/index.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var Uint8Array = require( '@stdlib/array-uint8' ); -var isUnityProbabilityArray = require( './../lib' ); - -var arr = [ 0.0, 1.0 ]; -console.log( isUnityProbabilityArray( arr ) ); -// => true - -arr = [ 0.5, 0.25, 0.25 ]; -console.log( isUnityProbabilityArray( arr ) ); -// => true - -arr = new Uint8Array( [ 0, 0, 1, 0 ] ); -console.log( isUnityProbabilityArray( arr ) ); -// => true - -arr = [ 0.4, 0.4, 0.4 ]; -console.log( isUnityProbabilityArray( arr ) ); -// => false - -arr = [ 3.14, -1.0 ]; -console.log( isUnityProbabilityArray( arr ) ); -// => false - -console.log( isUnityProbabilityArray( [] ) ); -// => false - -console.log( isUnityProbabilityArray( null ) ); -// => false diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..08d3bcb --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-typed-array@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array@v0.2.2-esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-number@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/math-base-utils-absolute-difference@v0.3.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/constants-float64-sqrt-eps@v0.2.2-esm/index.mjs";function n(n){var d,m;if(t(n)){for(d=0,m=0;m1||n[m]<0)return!1;d+=n[m]}return r(d,1)<=i}if(s(n)){for(d=0,m=0;m1||n[m]<0)return!1;d+=n[m]}return r(d,1)<=i}return!1}export{n as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..08904b0 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isTypedArray from '@stdlib/assert-is-typed-array';\nimport isArray from '@stdlib/assert-is-array';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport absdiff from '@stdlib/math-base-utils-absolute-difference';\nimport FLOAT64_SQRT_EPS from '@stdlib/constants-float64-sqrt-eps';\n\n\n// MAIN //\n\n/**\n* Tests if a value is an array of probabilities that sum to one.\n*\n* @param {*} v - value to test\n* @returns {boolean} boolean indicating if a value is a probability array\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] );\n* // returns true\n*\n* @example\n* var bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) );\n* // returns true\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] );\n* // returns false\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 3.14, 0.0 ] );\n* // returns false\n*/\nfunction isUnityProbabilityArray( v ) {\n\tvar sum;\n\tvar i;\n\tif ( isArray( v ) ) {\n\t\tsum = 0.0;\n\t\tfor ( i = 0; i < v.length; i++ ) {\n\t\t\tif (\n\t\t\t\t!isNumber( v[ i ] ) ||\n\t\t\t\tv[ i ] > 1.0 ||\n\t\t\t\tv[ i ] < 0.0\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tsum += v[ i ];\n\t\t}\n\t\treturn ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS );\n\t}\n\tif ( isTypedArray( v ) ) {\n\t\tsum = 0.0;\n\t\tfor ( i = 0; i < v.length; i++ ) {\n\t\t\tif (\n\t\t\t\tv[ i ] > 1.0 ||\n\t\t\t\tv[ i ] < 0.0\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tsum += v[ i ];\n\t\t}\n\t\treturn ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS );\n\t}\n\treturn false;\n}\n\n\n// EXPORTS //\n\nexport default isUnityProbabilityArray;\n"],"names":["isUnityProbabilityArray","v","sum","i","isArray","length","isNumber","absdiff","FLOAT64_SQRT_EPS","isTypedArray"],"mappings":";;ufAqDA,SAASA,EAAyBC,GACjC,IAAIC,EACAC,EACJ,GAAKC,EAASH,GAAM,CAEnB,IADAC,EAAM,EACAC,EAAI,EAAGA,EAAIF,EAAEI,OAAQF,IAAM,CAChC,IACEG,EAAUL,EAAGE,KACdF,EAAGE,GAAM,GACTF,EAAGE,GAAM,EAET,OAAO,EAERD,GAAOD,EAAGE,EACV,CACD,OAASI,EAASL,EAAK,IAASM,CAChC,CACD,GAAKC,EAAcR,GAAM,CAExB,IADAC,EAAM,EACAC,EAAI,EAAGA,EAAIF,EAAEI,OAAQF,IAAM,CAChC,GACCF,EAAGE,GAAM,GACTF,EAAGE,GAAM,EAET,OAAO,EAERD,GAAOD,EAAGE,EACV,CACD,OAASI,EAASL,EAAK,IAASM,CAChC,CACD,OAAO,CACR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 13a67d1..0000000 --- a/lib/index.js +++ /dev/null @@ -1,49 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Test if a value is an array of probabilities that sum to one. -* -* @module @stdlib/assert-is-unity-probability-array -* -* @example -* var isUnityProbabilityArray = require( '@stdlib/assert-is-unity-probability-array' ); -* -* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] ); -* // returns true -* -* bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) ); -* // returns true -* -* bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] ); -* // returns false -* -* bool = isUnityProbabilityArray( [ 3.14, 0.0 ] ); -* // returns false -*/ - -// 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 d0bda40..0000000 --- a/lib/main.js +++ /dev/null @@ -1,90 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -var isArray = require( '@stdlib/assert-is-array' ); -var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var absdiff = require( '@stdlib/math-base-utils-absolute-difference' ); -var FLOAT64_SQRT_EPS = require( '@stdlib/constants-float64-sqrt-eps' ); - - -// MAIN // - -/** -* Tests if a value is an array of probabilities that sum to one. -* -* @param {*} v - value to test -* @returns {boolean} boolean indicating if a value is a probability array -* -* @example -* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] ); -* // returns true -* -* @example -* var bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) ); -* // returns true -* -* @example -* var bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] ); -* // returns false -* -* @example -* var bool = isUnityProbabilityArray( [ 3.14, 0.0 ] ); -* // returns false -*/ -function isUnityProbabilityArray( v ) { - var sum; - var i; - if ( isArray( v ) ) { - sum = 0.0; - for ( i = 0; i < v.length; i++ ) { - if ( - !isNumber( v[ i ] ) || - v[ i ] > 1.0 || - v[ i ] < 0.0 - ) { - return false; - } - sum += v[ i ]; - } - return ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS ); - } - if ( isTypedArray( v ) ) { - sum = 0.0; - for ( i = 0; i < v.length; i++ ) { - if ( - v[ i ] > 1.0 || - v[ i ] < 0.0 - ) { - return false; - } - sum += v[ i ]; - } - return ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS ); - } - return false; -} - - -// EXPORTS // - -module.exports = isUnityProbabilityArray; diff --git a/package.json b/package.json index 2375604..9ba851e 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.2", "description": "Test if a value is an array of probabilities that sum to one.", "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" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,47 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-array": "^0.2.2", - "@stdlib/assert-is-number": "^0.2.2", - "@stdlib/assert-is-typed-array": "^0.2.2", - "@stdlib/constants-float64-sqrt-eps": "^0.2.2", - "@stdlib/math-base-utils-absolute-difference": "^0.3.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/array-float32": "^0.2.2", - "@stdlib/array-float64": "^0.2.2", - "@stdlib/array-int16": "^0.2.2", - "@stdlib/array-int32": "^0.2.2", - "@stdlib/array-int8": "^0.2.2", - "@stdlib/array-uint16": "^0.2.2", - "@stdlib/array-uint32": "^0.2.2", - "@stdlib/array-uint8": "^0.2.2", - "@stdlib/array-uint8c": "^0.2.2", - "@stdlib/assert-is-boolean": "^0.2.2", - "@stdlib/buffer-from-array": "^0.2.2", - "@stdlib/math-base-special-pow": "^0.3.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.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdassert", @@ -105,4 +41,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..2282772 --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index a0424fb..0000000 --- a/test/test.js +++ /dev/null @@ -1,106 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Int8Array = require( '@stdlib/array-int8' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Float64Array = require( '@stdlib/array-float64' ); -var array2buffer = require( '@stdlib/buffer-from-array' ); -var isUnityProbabilityArray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof isUnityProbabilityArray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns `true` if provided an array of probabilities that sum to one', function test( t ) { - var values; - var i; - - values = [ - new Int8Array( [ 0, 0, 1 ] ), - new Uint8Array( [ 1, 0, 0 ] ), - new Uint8ClampedArray( [ 0, 1 ] ), - new Int16Array( [ 0, 0, 1, 0 ] ), - new Uint16Array( [ 1 ] ), - new Int32Array( [ 1, 0, 0 ] ), - new Uint32Array( [ 0, 1, 0 ] ), - new Float32Array( [ 0.0, 0.5, 0.5 ] ), - new Float64Array( [ 0.25, 0.25, 0.5 ] ), - [ 0.5, 0.25, 0.25 ] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.strictEqual( isUnityProbabilityArray( values[i] ), true, 'returns true when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function allows a difference in sum within floating-point epsilon', function test( t ) { - var bool = isUnityProbabilityArray( [ 0.1, 0.2, 0.1, 0.1, 0.2, 0.2, 0.1 ] ); - t.strictEqual( bool, true, 'returns true' ); - t.end(); -}); - -tape( 'the function returns `false` if not provided an array of probabilities that sum to one', function test( t ) { - var values; - var i; - - values = [ - '10', - '01', - '0.5', - '5', - 5, - NaN, - null, - void 0, - true, - [], - [ 5, null ], - [ 5, '5' ], - [ 1.0, 3.14 ], - [ -1.0, 1.0, 1.0 ], - [ 0.25, 0.33, 0.5 ], - new Float64Array( [ 0.25, 0.33, 0.5 ] ), - new Float64Array( [ 0.25, 1.33, 0.5 ] ), - new Float64Array( [ 0.25, -0.33, 0.5 ] ), - {}, - function noop() {}, - array2buffer( [ 1, 1, 0 ] ) - ]; - - for ( i = 0; i < values.length; i++ ) { - t.strictEqual( isUnityProbabilityArray( values[i] ), false, 'returns false when provided '+values[i] ); - } - t.end(); -}); From 550e5189e62e631c0a8483e7d5decf2a4cecd849 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Nov 2024 07:08:21 +0000 Subject: [PATCH 113/133] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 2385bbd..2375604 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,8 @@ "@stdlib/assert-is-number": "^0.2.2", "@stdlib/assert-is-typed-array": "^0.2.2", "@stdlib/constants-float64-sqrt-eps": "^0.2.2", - "@stdlib/math-base-utils-absolute-difference": "^0.3.2" + "@stdlib/math-base-utils-absolute-difference": "^0.3.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2" }, "devDependencies": { "@stdlib/array-float32": "^0.2.2", @@ -104,4 +105,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 887e1bb9c62adb478d2aa1109186ed88f054f860 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Nov 2024 11:03:38 +0000 Subject: [PATCH 114/133] Remove files --- index.d.ts | 48 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4895 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index 63a123d..0000000 --- a/index.d.ts +++ /dev/null @@ -1,48 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/** -* Tests if a value is an array of probabilities that sum to one. -* -* @param v - value to test -* @returns boolean indicating if a value is a probability array -* -* @example -* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] ); -* // returns true -* -* @example -* var bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) ); -* // returns true -* -* @example -* var bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] ); -* // returns false -* -* @example -* var bool = isUnityProbabilityArray( [ 3.14, 0.0 ] ); -* // returns false -*/ -declare function isUnityProbabilityArray( v: any ): v is ArrayLike; - - -// EXPORTS // - -export = isUnityProbabilityArray; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 08d3bcb..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-typed-array@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array@v0.2.2-esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-number@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/math-base-utils-absolute-difference@v0.3.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/constants-float64-sqrt-eps@v0.2.2-esm/index.mjs";function n(n){var d,m;if(t(n)){for(d=0,m=0;m1||n[m]<0)return!1;d+=n[m]}return r(d,1)<=i}if(s(n)){for(d=0,m=0;m1||n[m]<0)return!1;d+=n[m]}return r(d,1)<=i}return!1}export{n as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 08904b0..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isTypedArray from '@stdlib/assert-is-typed-array';\nimport isArray from '@stdlib/assert-is-array';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport absdiff from '@stdlib/math-base-utils-absolute-difference';\nimport FLOAT64_SQRT_EPS from '@stdlib/constants-float64-sqrt-eps';\n\n\n// MAIN //\n\n/**\n* Tests if a value is an array of probabilities that sum to one.\n*\n* @param {*} v - value to test\n* @returns {boolean} boolean indicating if a value is a probability array\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] );\n* // returns true\n*\n* @example\n* var bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) );\n* // returns true\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] );\n* // returns false\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 3.14, 0.0 ] );\n* // returns false\n*/\nfunction isUnityProbabilityArray( v ) {\n\tvar sum;\n\tvar i;\n\tif ( isArray( v ) ) {\n\t\tsum = 0.0;\n\t\tfor ( i = 0; i < v.length; i++ ) {\n\t\t\tif (\n\t\t\t\t!isNumber( v[ i ] ) ||\n\t\t\t\tv[ i ] > 1.0 ||\n\t\t\t\tv[ i ] < 0.0\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tsum += v[ i ];\n\t\t}\n\t\treturn ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS );\n\t}\n\tif ( isTypedArray( v ) ) {\n\t\tsum = 0.0;\n\t\tfor ( i = 0; i < v.length; i++ ) {\n\t\t\tif (\n\t\t\t\tv[ i ] > 1.0 ||\n\t\t\t\tv[ i ] < 0.0\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tsum += v[ i ];\n\t\t}\n\t\treturn ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS );\n\t}\n\treturn false;\n}\n\n\n// EXPORTS //\n\nexport default isUnityProbabilityArray;\n"],"names":["isUnityProbabilityArray","v","sum","i","isArray","length","isNumber","absdiff","FLOAT64_SQRT_EPS","isTypedArray"],"mappings":";;ufAqDA,SAASA,EAAyBC,GACjC,IAAIC,EACAC,EACJ,GAAKC,EAASH,GAAM,CAEnB,IADAC,EAAM,EACAC,EAAI,EAAGA,EAAIF,EAAEI,OAAQF,IAAM,CAChC,IACEG,EAAUL,EAAGE,KACdF,EAAGE,GAAM,GACTF,EAAGE,GAAM,EAET,OAAO,EAERD,GAAOD,EAAGE,EACV,CACD,OAASI,EAASL,EAAK,IAASM,CAChC,CACD,GAAKC,EAAcR,GAAM,CAExB,IADAC,EAAM,EACAC,EAAI,EAAGA,EAAIF,EAAEI,OAAQF,IAAM,CAChC,GACCF,EAAGE,GAAM,GACTF,EAAGE,GAAM,EAET,OAAO,EAERD,GAAOD,EAAGE,EACV,CACD,OAASI,EAASL,EAAK,IAASM,CAChC,CACD,OAAO,CACR"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 2282772..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 25cae722bb2e75486627b6c43514b5ecbdd43761 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Nov 2024 11:03:52 +0000 Subject: [PATCH 115/133] 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 | 163 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 43 +- SECURITY.md | 5 - benchmark/benchmark.js | 103 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 29 - docs/types/test.ts | 34 - examples/index.js | 48 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 49 - lib/main.js | 90 - package.json | 70 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 106 - 43 files changed, 4867 insertions(+), 4000 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 delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/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 4bc51b2..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-11-01T05:23:04.019Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 75a4c32..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/assert/is-unity-probability-array) 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 5119885..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/assert/is-unity-probability-array) 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 3b386b0..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: '49 1 * * 1' - - # 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 + + ```
@@ -178,7 +169,7 @@ bool = isUnityProbabilityArray( null ); ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -245,9 +236,9 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/assert/is-probability]: https://github.com/stdlib-js/assert-is-probability +[@stdlib/assert/is-probability]: https://github.com/stdlib-js/assert-is-probability/tree/esm -[@stdlib/assert/is-probability-array]: https://github.com/stdlib-js/assert-is-probability-array +[@stdlib/assert/is-probability-array]: https://github.com/stdlib-js/assert-is-probability-array/tree/esm diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 510a5ed..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,103 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var isUnityProbabilityArray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x; - var i; - - x = []; - for ( i = 0; i < len; i++ ) { - x.push( 1.0/len ); - } - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: we are testing the worst case scenario where a function must scan the entire array before finding a failing value. - x[ len-1 ] = i * 3.14; - bool = isUnityProbabilityArray( x ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( isBoolean( bool ) ) { - b.pass( 'benchmark finished' ); - } else { - b.fail( 'should return a boolean' ); - } - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':len='+len, f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index 5a6810d..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/assert/is-unity-probability-array" -%% click B href "https://github.com/stdlib-js/assert-is-unity-probability-array/tree/main" -%% click C href "https://github.com/stdlib-js/assert-is-unity-probability-array/tree/production" -%% click D href "https://github.com/stdlib-js/assert-is-unity-probability-array/tree/esm" -%% click E href "https://github.com/stdlib-js/assert-is-unity-probability-array/tree/deno" -%% click F href "https://github.com/stdlib-js/assert-is-unity-probability-array/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/assert/is-unity-probability-array -[production-url]: https://github.com/stdlib-js/assert-is-unity-probability-array/tree/production -[deno-url]: https://github.com/stdlib-js/assert-is-unity-probability-array/tree/deno -[deno-readme]: https://github.com/stdlib-js/assert-is-unity-probability-array/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/assert-is-unity-probability-array/tree/umd -[umd-readme]: https://github.com/stdlib-js/assert-is-unity-probability-array/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/assert-is-unity-probability-array/tree/esm -[esm-readme]: https://github.com/stdlib-js/assert-is-unity-probability-array/blob/esm/README.md \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index c77d01e..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import isUnityProbabilityArray from '../docs/types/index'; -export = isUnityProbabilityArray; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 70d7801..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var f=function(r,i){return function(){return i||r((i={exports:{}}).exports,i),i.exports}};var u=f(function(m,s){ -var n=require('@stdlib/assert-is-typed-array/dist'),l=require('@stdlib/assert-is-array/dist'),o=require('@stdlib/assert-is-number/dist').isPrimitive,a=require('@stdlib/math-base-utils-absolute-difference/dist'),t=require('@stdlib/constants-float64-sqrt-eps/dist');function q(r){var i,e;if(l(r)){for(i=0,e=0;e1||r[e]<0)return!1;i+=r[e]}return a(i,1)<=t}if(n(r)){for(i=0,e=0;e1||r[e]<0)return!1;i+=r[e]}return a(i,1)<=t}return!1}s.exports=q -});var y=u();module.exports=y; -/** @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 387d5ad..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) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isTypedArray = require( '@stdlib/assert-is-typed-array' );\nvar isArray = require( '@stdlib/assert-is-array' );\nvar isNumber = require( '@stdlib/assert-is-number' ).isPrimitive;\nvar absdiff = require( '@stdlib/math-base-utils-absolute-difference' );\nvar FLOAT64_SQRT_EPS = require( '@stdlib/constants-float64-sqrt-eps' );\n\n\n// MAIN //\n\n/**\n* Tests if a value is an array of probabilities that sum to one.\n*\n* @param {*} v - value to test\n* @returns {boolean} boolean indicating if a value is a probability array\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] );\n* // returns true\n*\n* @example\n* var bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) );\n* // returns true\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] );\n* // returns false\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 3.14, 0.0 ] );\n* // returns false\n*/\nfunction isUnityProbabilityArray( v ) {\n\tvar sum;\n\tvar i;\n\tif ( isArray( v ) ) {\n\t\tsum = 0.0;\n\t\tfor ( i = 0; i < v.length; i++ ) {\n\t\t\tif (\n\t\t\t\t!isNumber( v[ i ] ) ||\n\t\t\t\tv[ i ] > 1.0 ||\n\t\t\t\tv[ i ] < 0.0\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tsum += v[ i ];\n\t\t}\n\t\treturn ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS );\n\t}\n\tif ( isTypedArray( v ) ) {\n\t\tsum = 0.0;\n\t\tfor ( i = 0; i < v.length; i++ ) {\n\t\t\tif (\n\t\t\t\tv[ i ] > 1.0 ||\n\t\t\t\tv[ i ] < 0.0\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tsum += v[ i ];\n\t\t}\n\t\treturn ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS );\n\t}\n\treturn false;\n}\n\n\n// EXPORTS //\n\nmodule.exports = isUnityProbabilityArray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Test if a value is an array of probabilities that sum to one.\n*\n* @module @stdlib/assert-is-unity-probability-array\n*\n* @example\n* var isUnityProbabilityArray = require( '@stdlib/assert-is-unity-probability-array' );\n*\n* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] );\n* // returns true\n*\n* bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) );\n* // returns true\n*\n* bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] );\n* // returns false\n*\n* bool = isUnityProbabilityArray( [ 3.14, 0.0 ] );\n* // returns false\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,EAAe,QAAS,+BAAgC,EACxDC,EAAU,QAAS,yBAA0B,EAC7CC,EAAW,QAAS,0BAA2B,EAAE,YACjDC,EAAU,QAAS,6CAA8C,EACjEC,EAAmB,QAAS,oCAAqC,EA2BrE,SAASC,EAAyBC,EAAI,CACrC,IAAIC,EACAC,EACJ,GAAKP,EAASK,CAAE,EAAI,CAEnB,IADAC,EAAM,EACAC,EAAI,EAAGA,EAAIF,EAAE,OAAQE,IAAM,CAChC,GACC,CAACN,EAAUI,EAAGE,CAAE,CAAE,GAClBF,EAAGE,CAAE,EAAI,GACTF,EAAGE,CAAE,EAAI,EAET,MAAO,GAERD,GAAOD,EAAGE,CAAE,CACb,CACA,OAASL,EAASI,EAAK,CAAI,GAAKH,CACjC,CACA,GAAKJ,EAAcM,CAAE,EAAI,CAExB,IADAC,EAAM,EACAC,EAAI,EAAGA,EAAIF,EAAE,OAAQE,IAAM,CAChC,GACCF,EAAGE,CAAE,EAAI,GACTF,EAAGE,CAAE,EAAI,EAET,MAAO,GAERD,GAAOD,EAAGE,CAAE,CACb,CACA,OAASL,EAASI,EAAK,CAAI,GAAKH,CACjC,CACA,MAAO,EACR,CAKAL,EAAO,QAAUM,IC9CjB,IAAII,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isTypedArray", "isArray", "isNumber", "absdiff", "FLOAT64_SQRT_EPS", "isUnityProbabilityArray", "v", "sum", "i", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index a2414be..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,29 +0,0 @@ - -{{alias}}( value ) - Tests if a value is an array of probabilities that sum to one. - - Parameters - ---------- - value: any - Value to test. - - Returns - ------- - bool: boolean - Boolean indicating whether value is an array of probabilities that sum - to one. - - Examples - -------- - > var bool = {{alias}}( [ 0.25, 0.5, 0.25 ] ) - true - > bool = {{alias}}( new {{alias:@stdlib/array/uint8}}( [ 0, 1 ] ) ) - true - > bool = {{alias}}( [ 0.4, 0.4, 0.4 ] ) - false - > bool = {{alias}}( [ 3.14, 0.0 ] ) - false - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 6b41658..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,34 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import isUnityProbabilityArray = require( './index' ); - - -// TESTS // - -// The function returns a boolean... -{ - isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] ); // $ExpectType boolean - isUnityProbabilityArray( [ 2, 3 ] ); // $ExpectType boolean -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - isUnityProbabilityArray(); // $ExpectError - isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ], 123 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index b0b6bbc..0000000 --- a/examples/index.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var Uint8Array = require( '@stdlib/array-uint8' ); -var isUnityProbabilityArray = require( './../lib' ); - -var arr = [ 0.0, 1.0 ]; -console.log( isUnityProbabilityArray( arr ) ); -// => true - -arr = [ 0.5, 0.25, 0.25 ]; -console.log( isUnityProbabilityArray( arr ) ); -// => true - -arr = new Uint8Array( [ 0, 0, 1, 0 ] ); -console.log( isUnityProbabilityArray( arr ) ); -// => true - -arr = [ 0.4, 0.4, 0.4 ]; -console.log( isUnityProbabilityArray( arr ) ); -// => false - -arr = [ 3.14, -1.0 ]; -console.log( isUnityProbabilityArray( arr ) ); -// => false - -console.log( isUnityProbabilityArray( [] ) ); -// => false - -console.log( isUnityProbabilityArray( null ) ); -// => false diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..08d3bcb --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-typed-array@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array@v0.2.2-esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-number@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/math-base-utils-absolute-difference@v0.3.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/constants-float64-sqrt-eps@v0.2.2-esm/index.mjs";function n(n){var d,m;if(t(n)){for(d=0,m=0;m1||n[m]<0)return!1;d+=n[m]}return r(d,1)<=i}if(s(n)){for(d=0,m=0;m1||n[m]<0)return!1;d+=n[m]}return r(d,1)<=i}return!1}export{n as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..08904b0 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isTypedArray from '@stdlib/assert-is-typed-array';\nimport isArray from '@stdlib/assert-is-array';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport absdiff from '@stdlib/math-base-utils-absolute-difference';\nimport FLOAT64_SQRT_EPS from '@stdlib/constants-float64-sqrt-eps';\n\n\n// MAIN //\n\n/**\n* Tests if a value is an array of probabilities that sum to one.\n*\n* @param {*} v - value to test\n* @returns {boolean} boolean indicating if a value is a probability array\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] );\n* // returns true\n*\n* @example\n* var bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) );\n* // returns true\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] );\n* // returns false\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 3.14, 0.0 ] );\n* // returns false\n*/\nfunction isUnityProbabilityArray( v ) {\n\tvar sum;\n\tvar i;\n\tif ( isArray( v ) ) {\n\t\tsum = 0.0;\n\t\tfor ( i = 0; i < v.length; i++ ) {\n\t\t\tif (\n\t\t\t\t!isNumber( v[ i ] ) ||\n\t\t\t\tv[ i ] > 1.0 ||\n\t\t\t\tv[ i ] < 0.0\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tsum += v[ i ];\n\t\t}\n\t\treturn ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS );\n\t}\n\tif ( isTypedArray( v ) ) {\n\t\tsum = 0.0;\n\t\tfor ( i = 0; i < v.length; i++ ) {\n\t\t\tif (\n\t\t\t\tv[ i ] > 1.0 ||\n\t\t\t\tv[ i ] < 0.0\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tsum += v[ i ];\n\t\t}\n\t\treturn ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS );\n\t}\n\treturn false;\n}\n\n\n// EXPORTS //\n\nexport default isUnityProbabilityArray;\n"],"names":["isUnityProbabilityArray","v","sum","i","isArray","length","isNumber","absdiff","FLOAT64_SQRT_EPS","isTypedArray"],"mappings":";;ufAqDA,SAASA,EAAyBC,GACjC,IAAIC,EACAC,EACJ,GAAKC,EAASH,GAAM,CAEnB,IADAC,EAAM,EACAC,EAAI,EAAGA,EAAIF,EAAEI,OAAQF,IAAM,CAChC,IACEG,EAAUL,EAAGE,KACdF,EAAGE,GAAM,GACTF,EAAGE,GAAM,EAET,OAAO,EAERD,GAAOD,EAAGE,EACV,CACD,OAASI,EAASL,EAAK,IAASM,CAChC,CACD,GAAKC,EAAcR,GAAM,CAExB,IADAC,EAAM,EACAC,EAAI,EAAGA,EAAIF,EAAEI,OAAQF,IAAM,CAChC,GACCF,EAAGE,GAAM,GACTF,EAAGE,GAAM,EAET,OAAO,EAERD,GAAOD,EAAGE,EACV,CACD,OAASI,EAASL,EAAK,IAASM,CAChC,CACD,OAAO,CACR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 13a67d1..0000000 --- a/lib/index.js +++ /dev/null @@ -1,49 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Test if a value is an array of probabilities that sum to one. -* -* @module @stdlib/assert-is-unity-probability-array -* -* @example -* var isUnityProbabilityArray = require( '@stdlib/assert-is-unity-probability-array' ); -* -* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] ); -* // returns true -* -* bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) ); -* // returns true -* -* bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] ); -* // returns false -* -* bool = isUnityProbabilityArray( [ 3.14, 0.0 ] ); -* // returns false -*/ - -// 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 d0bda40..0000000 --- a/lib/main.js +++ /dev/null @@ -1,90 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -var isArray = require( '@stdlib/assert-is-array' ); -var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var absdiff = require( '@stdlib/math-base-utils-absolute-difference' ); -var FLOAT64_SQRT_EPS = require( '@stdlib/constants-float64-sqrt-eps' ); - - -// MAIN // - -/** -* Tests if a value is an array of probabilities that sum to one. -* -* @param {*} v - value to test -* @returns {boolean} boolean indicating if a value is a probability array -* -* @example -* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] ); -* // returns true -* -* @example -* var bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) ); -* // returns true -* -* @example -* var bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] ); -* // returns false -* -* @example -* var bool = isUnityProbabilityArray( [ 3.14, 0.0 ] ); -* // returns false -*/ -function isUnityProbabilityArray( v ) { - var sum; - var i; - if ( isArray( v ) ) { - sum = 0.0; - for ( i = 0; i < v.length; i++ ) { - if ( - !isNumber( v[ i ] ) || - v[ i ] > 1.0 || - v[ i ] < 0.0 - ) { - return false; - } - sum += v[ i ]; - } - return ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS ); - } - if ( isTypedArray( v ) ) { - sum = 0.0; - for ( i = 0; i < v.length; i++ ) { - if ( - v[ i ] > 1.0 || - v[ i ] < 0.0 - ) { - return false; - } - sum += v[ i ]; - } - return ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS ); - } - return false; -} - - -// EXPORTS // - -module.exports = isUnityProbabilityArray; diff --git a/package.json b/package.json index 2375604..9ba851e 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.2", "description": "Test if a value is an array of probabilities that sum to one.", "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" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,47 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-array": "^0.2.2", - "@stdlib/assert-is-number": "^0.2.2", - "@stdlib/assert-is-typed-array": "^0.2.2", - "@stdlib/constants-float64-sqrt-eps": "^0.2.2", - "@stdlib/math-base-utils-absolute-difference": "^0.3.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/array-float32": "^0.2.2", - "@stdlib/array-float64": "^0.2.2", - "@stdlib/array-int16": "^0.2.2", - "@stdlib/array-int32": "^0.2.2", - "@stdlib/array-int8": "^0.2.2", - "@stdlib/array-uint16": "^0.2.2", - "@stdlib/array-uint32": "^0.2.2", - "@stdlib/array-uint8": "^0.2.2", - "@stdlib/array-uint8c": "^0.2.2", - "@stdlib/assert-is-boolean": "^0.2.2", - "@stdlib/buffer-from-array": "^0.2.2", - "@stdlib/math-base-special-pow": "^0.3.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.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdassert", @@ -105,4 +41,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..2282772 --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index a0424fb..0000000 --- a/test/test.js +++ /dev/null @@ -1,106 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Int8Array = require( '@stdlib/array-int8' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Float64Array = require( '@stdlib/array-float64' ); -var array2buffer = require( '@stdlib/buffer-from-array' ); -var isUnityProbabilityArray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof isUnityProbabilityArray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns `true` if provided an array of probabilities that sum to one', function test( t ) { - var values; - var i; - - values = [ - new Int8Array( [ 0, 0, 1 ] ), - new Uint8Array( [ 1, 0, 0 ] ), - new Uint8ClampedArray( [ 0, 1 ] ), - new Int16Array( [ 0, 0, 1, 0 ] ), - new Uint16Array( [ 1 ] ), - new Int32Array( [ 1, 0, 0 ] ), - new Uint32Array( [ 0, 1, 0 ] ), - new Float32Array( [ 0.0, 0.5, 0.5 ] ), - new Float64Array( [ 0.25, 0.25, 0.5 ] ), - [ 0.5, 0.25, 0.25 ] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.strictEqual( isUnityProbabilityArray( values[i] ), true, 'returns true when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function allows a difference in sum within floating-point epsilon', function test( t ) { - var bool = isUnityProbabilityArray( [ 0.1, 0.2, 0.1, 0.1, 0.2, 0.2, 0.1 ] ); - t.strictEqual( bool, true, 'returns true' ); - t.end(); -}); - -tape( 'the function returns `false` if not provided an array of probabilities that sum to one', function test( t ) { - var values; - var i; - - values = [ - '10', - '01', - '0.5', - '5', - 5, - NaN, - null, - void 0, - true, - [], - [ 5, null ], - [ 5, '5' ], - [ 1.0, 3.14 ], - [ -1.0, 1.0, 1.0 ], - [ 0.25, 0.33, 0.5 ], - new Float64Array( [ 0.25, 0.33, 0.5 ] ), - new Float64Array( [ 0.25, 1.33, 0.5 ] ), - new Float64Array( [ 0.25, -0.33, 0.5 ] ), - {}, - function noop() {}, - array2buffer( [ 1, 1, 0 ] ) - ]; - - for ( i = 0; i < values.length; i++ ) { - t.strictEqual( isUnityProbabilityArray( values[i] ), false, 'returns false when provided '+values[i] ); - } - t.end(); -}); From 65cd89ff2481e8bd4afcd659b110d006ae6965e2 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Dec 2024 07:22:52 +0000 Subject: [PATCH 116/133] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 2385bbd..2375604 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,8 @@ "@stdlib/assert-is-number": "^0.2.2", "@stdlib/assert-is-typed-array": "^0.2.2", "@stdlib/constants-float64-sqrt-eps": "^0.2.2", - "@stdlib/math-base-utils-absolute-difference": "^0.3.2" + "@stdlib/math-base-utils-absolute-difference": "^0.3.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2" }, "devDependencies": { "@stdlib/array-float32": "^0.2.2", @@ -104,4 +105,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 6d9d52af54198a91bfcabbac993c56e5c3e71786 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Dec 2024 11:17:53 +0000 Subject: [PATCH 117/133] Remove files --- index.d.ts | 48 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4895 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index 63a123d..0000000 --- a/index.d.ts +++ /dev/null @@ -1,48 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/** -* Tests if a value is an array of probabilities that sum to one. -* -* @param v - value to test -* @returns boolean indicating if a value is a probability array -* -* @example -* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] ); -* // returns true -* -* @example -* var bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) ); -* // returns true -* -* @example -* var bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] ); -* // returns false -* -* @example -* var bool = isUnityProbabilityArray( [ 3.14, 0.0 ] ); -* // returns false -*/ -declare function isUnityProbabilityArray( v: any ): v is ArrayLike; - - -// EXPORTS // - -export = isUnityProbabilityArray; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 08d3bcb..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-typed-array@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array@v0.2.2-esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-number@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/math-base-utils-absolute-difference@v0.3.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/constants-float64-sqrt-eps@v0.2.2-esm/index.mjs";function n(n){var d,m;if(t(n)){for(d=0,m=0;m1||n[m]<0)return!1;d+=n[m]}return r(d,1)<=i}if(s(n)){for(d=0,m=0;m1||n[m]<0)return!1;d+=n[m]}return r(d,1)<=i}return!1}export{n as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 08904b0..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isTypedArray from '@stdlib/assert-is-typed-array';\nimport isArray from '@stdlib/assert-is-array';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport absdiff from '@stdlib/math-base-utils-absolute-difference';\nimport FLOAT64_SQRT_EPS from '@stdlib/constants-float64-sqrt-eps';\n\n\n// MAIN //\n\n/**\n* Tests if a value is an array of probabilities that sum to one.\n*\n* @param {*} v - value to test\n* @returns {boolean} boolean indicating if a value is a probability array\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] );\n* // returns true\n*\n* @example\n* var bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) );\n* // returns true\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] );\n* // returns false\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 3.14, 0.0 ] );\n* // returns false\n*/\nfunction isUnityProbabilityArray( v ) {\n\tvar sum;\n\tvar i;\n\tif ( isArray( v ) ) {\n\t\tsum = 0.0;\n\t\tfor ( i = 0; i < v.length; i++ ) {\n\t\t\tif (\n\t\t\t\t!isNumber( v[ i ] ) ||\n\t\t\t\tv[ i ] > 1.0 ||\n\t\t\t\tv[ i ] < 0.0\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tsum += v[ i ];\n\t\t}\n\t\treturn ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS );\n\t}\n\tif ( isTypedArray( v ) ) {\n\t\tsum = 0.0;\n\t\tfor ( i = 0; i < v.length; i++ ) {\n\t\t\tif (\n\t\t\t\tv[ i ] > 1.0 ||\n\t\t\t\tv[ i ] < 0.0\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tsum += v[ i ];\n\t\t}\n\t\treturn ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS );\n\t}\n\treturn false;\n}\n\n\n// EXPORTS //\n\nexport default isUnityProbabilityArray;\n"],"names":["isUnityProbabilityArray","v","sum","i","isArray","length","isNumber","absdiff","FLOAT64_SQRT_EPS","isTypedArray"],"mappings":";;ufAqDA,SAASA,EAAyBC,GACjC,IAAIC,EACAC,EACJ,GAAKC,EAASH,GAAM,CAEnB,IADAC,EAAM,EACAC,EAAI,EAAGA,EAAIF,EAAEI,OAAQF,IAAM,CAChC,IACEG,EAAUL,EAAGE,KACdF,EAAGE,GAAM,GACTF,EAAGE,GAAM,EAET,OAAO,EAERD,GAAOD,EAAGE,EACV,CACD,OAASI,EAASL,EAAK,IAASM,CAChC,CACD,GAAKC,EAAcR,GAAM,CAExB,IADAC,EAAM,EACAC,EAAI,EAAGA,EAAIF,EAAEI,OAAQF,IAAM,CAChC,GACCF,EAAGE,GAAM,GACTF,EAAGE,GAAM,EAET,OAAO,EAERD,GAAOD,EAAGE,EACV,CACD,OAASI,EAASL,EAAK,IAASM,CAChC,CACD,OAAO,CACR"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 2282772..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From e803c599689b04a3db8786d7f1757395542935f8 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Dec 2024 11:18:07 +0000 Subject: [PATCH 118/133] 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 | 163 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 43 +- SECURITY.md | 5 - benchmark/benchmark.js | 103 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 29 - docs/types/test.ts | 34 - examples/index.js | 48 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 49 - lib/main.js | 90 - package.json | 70 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 106 - 44 files changed, 4867 insertions(+), 4105 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 delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/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 bf066bb..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-12-01T05:30:53.801Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 75a4c32..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/assert/is-unity-probability-array) 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 5119885..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/assert/is-unity-probability-array) 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 3b386b0..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: '49 1 * * 1' - - # 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 + + ```
@@ -178,7 +169,7 @@ bool = isUnityProbabilityArray( null ); ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -245,9 +236,9 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/assert/is-probability]: https://github.com/stdlib-js/assert-is-probability +[@stdlib/assert/is-probability]: https://github.com/stdlib-js/assert-is-probability/tree/esm -[@stdlib/assert/is-probability-array]: https://github.com/stdlib-js/assert-is-probability-array +[@stdlib/assert/is-probability-array]: https://github.com/stdlib-js/assert-is-probability-array/tree/esm diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 510a5ed..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,103 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var isUnityProbabilityArray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x; - var i; - - x = []; - for ( i = 0; i < len; i++ ) { - x.push( 1.0/len ); - } - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: we are testing the worst case scenario where a function must scan the entire array before finding a failing value. - x[ len-1 ] = i * 3.14; - bool = isUnityProbabilityArray( x ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( isBoolean( bool ) ) { - b.pass( 'benchmark finished' ); - } else { - b.fail( 'should return a boolean' ); - } - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':len='+len, f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index 5a6810d..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/assert/is-unity-probability-array" -%% click B href "https://github.com/stdlib-js/assert-is-unity-probability-array/tree/main" -%% click C href "https://github.com/stdlib-js/assert-is-unity-probability-array/tree/production" -%% click D href "https://github.com/stdlib-js/assert-is-unity-probability-array/tree/esm" -%% click E href "https://github.com/stdlib-js/assert-is-unity-probability-array/tree/deno" -%% click F href "https://github.com/stdlib-js/assert-is-unity-probability-array/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/assert/is-unity-probability-array -[production-url]: https://github.com/stdlib-js/assert-is-unity-probability-array/tree/production -[deno-url]: https://github.com/stdlib-js/assert-is-unity-probability-array/tree/deno -[deno-readme]: https://github.com/stdlib-js/assert-is-unity-probability-array/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/assert-is-unity-probability-array/tree/umd -[umd-readme]: https://github.com/stdlib-js/assert-is-unity-probability-array/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/assert-is-unity-probability-array/tree/esm -[esm-readme]: https://github.com/stdlib-js/assert-is-unity-probability-array/blob/esm/README.md \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index c77d01e..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import isUnityProbabilityArray from '../docs/types/index'; -export = isUnityProbabilityArray; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 70d7801..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var f=function(r,i){return function(){return i||r((i={exports:{}}).exports,i),i.exports}};var u=f(function(m,s){ -var n=require('@stdlib/assert-is-typed-array/dist'),l=require('@stdlib/assert-is-array/dist'),o=require('@stdlib/assert-is-number/dist').isPrimitive,a=require('@stdlib/math-base-utils-absolute-difference/dist'),t=require('@stdlib/constants-float64-sqrt-eps/dist');function q(r){var i,e;if(l(r)){for(i=0,e=0;e1||r[e]<0)return!1;i+=r[e]}return a(i,1)<=t}if(n(r)){for(i=0,e=0;e1||r[e]<0)return!1;i+=r[e]}return a(i,1)<=t}return!1}s.exports=q -});var y=u();module.exports=y; -/** @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 387d5ad..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) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isTypedArray = require( '@stdlib/assert-is-typed-array' );\nvar isArray = require( '@stdlib/assert-is-array' );\nvar isNumber = require( '@stdlib/assert-is-number' ).isPrimitive;\nvar absdiff = require( '@stdlib/math-base-utils-absolute-difference' );\nvar FLOAT64_SQRT_EPS = require( '@stdlib/constants-float64-sqrt-eps' );\n\n\n// MAIN //\n\n/**\n* Tests if a value is an array of probabilities that sum to one.\n*\n* @param {*} v - value to test\n* @returns {boolean} boolean indicating if a value is a probability array\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] );\n* // returns true\n*\n* @example\n* var bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) );\n* // returns true\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] );\n* // returns false\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 3.14, 0.0 ] );\n* // returns false\n*/\nfunction isUnityProbabilityArray( v ) {\n\tvar sum;\n\tvar i;\n\tif ( isArray( v ) ) {\n\t\tsum = 0.0;\n\t\tfor ( i = 0; i < v.length; i++ ) {\n\t\t\tif (\n\t\t\t\t!isNumber( v[ i ] ) ||\n\t\t\t\tv[ i ] > 1.0 ||\n\t\t\t\tv[ i ] < 0.0\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tsum += v[ i ];\n\t\t}\n\t\treturn ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS );\n\t}\n\tif ( isTypedArray( v ) ) {\n\t\tsum = 0.0;\n\t\tfor ( i = 0; i < v.length; i++ ) {\n\t\t\tif (\n\t\t\t\tv[ i ] > 1.0 ||\n\t\t\t\tv[ i ] < 0.0\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tsum += v[ i ];\n\t\t}\n\t\treturn ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS );\n\t}\n\treturn false;\n}\n\n\n// EXPORTS //\n\nmodule.exports = isUnityProbabilityArray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Test if a value is an array of probabilities that sum to one.\n*\n* @module @stdlib/assert-is-unity-probability-array\n*\n* @example\n* var isUnityProbabilityArray = require( '@stdlib/assert-is-unity-probability-array' );\n*\n* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] );\n* // returns true\n*\n* bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) );\n* // returns true\n*\n* bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] );\n* // returns false\n*\n* bool = isUnityProbabilityArray( [ 3.14, 0.0 ] );\n* // returns false\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,EAAe,QAAS,+BAAgC,EACxDC,EAAU,QAAS,yBAA0B,EAC7CC,EAAW,QAAS,0BAA2B,EAAE,YACjDC,EAAU,QAAS,6CAA8C,EACjEC,EAAmB,QAAS,oCAAqC,EA2BrE,SAASC,EAAyBC,EAAI,CACrC,IAAIC,EACAC,EACJ,GAAKP,EAASK,CAAE,EAAI,CAEnB,IADAC,EAAM,EACAC,EAAI,EAAGA,EAAIF,EAAE,OAAQE,IAAM,CAChC,GACC,CAACN,EAAUI,EAAGE,CAAE,CAAE,GAClBF,EAAGE,CAAE,EAAI,GACTF,EAAGE,CAAE,EAAI,EAET,MAAO,GAERD,GAAOD,EAAGE,CAAE,CACb,CACA,OAASL,EAASI,EAAK,CAAI,GAAKH,CACjC,CACA,GAAKJ,EAAcM,CAAE,EAAI,CAExB,IADAC,EAAM,EACAC,EAAI,EAAGA,EAAIF,EAAE,OAAQE,IAAM,CAChC,GACCF,EAAGE,CAAE,EAAI,GACTF,EAAGE,CAAE,EAAI,EAET,MAAO,GAERD,GAAOD,EAAGE,CAAE,CACb,CACA,OAASL,EAASI,EAAK,CAAI,GAAKH,CACjC,CACA,MAAO,EACR,CAKAL,EAAO,QAAUM,IC9CjB,IAAII,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isTypedArray", "isArray", "isNumber", "absdiff", "FLOAT64_SQRT_EPS", "isUnityProbabilityArray", "v", "sum", "i", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index a2414be..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,29 +0,0 @@ - -{{alias}}( value ) - Tests if a value is an array of probabilities that sum to one. - - Parameters - ---------- - value: any - Value to test. - - Returns - ------- - bool: boolean - Boolean indicating whether value is an array of probabilities that sum - to one. - - Examples - -------- - > var bool = {{alias}}( [ 0.25, 0.5, 0.25 ] ) - true - > bool = {{alias}}( new {{alias:@stdlib/array/uint8}}( [ 0, 1 ] ) ) - true - > bool = {{alias}}( [ 0.4, 0.4, 0.4 ] ) - false - > bool = {{alias}}( [ 3.14, 0.0 ] ) - false - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 6b41658..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,34 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import isUnityProbabilityArray = require( './index' ); - - -// TESTS // - -// The function returns a boolean... -{ - isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] ); // $ExpectType boolean - isUnityProbabilityArray( [ 2, 3 ] ); // $ExpectType boolean -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - isUnityProbabilityArray(); // $ExpectError - isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ], 123 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index b0b6bbc..0000000 --- a/examples/index.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var Uint8Array = require( '@stdlib/array-uint8' ); -var isUnityProbabilityArray = require( './../lib' ); - -var arr = [ 0.0, 1.0 ]; -console.log( isUnityProbabilityArray( arr ) ); -// => true - -arr = [ 0.5, 0.25, 0.25 ]; -console.log( isUnityProbabilityArray( arr ) ); -// => true - -arr = new Uint8Array( [ 0, 0, 1, 0 ] ); -console.log( isUnityProbabilityArray( arr ) ); -// => true - -arr = [ 0.4, 0.4, 0.4 ]; -console.log( isUnityProbabilityArray( arr ) ); -// => false - -arr = [ 3.14, -1.0 ]; -console.log( isUnityProbabilityArray( arr ) ); -// => false - -console.log( isUnityProbabilityArray( [] ) ); -// => false - -console.log( isUnityProbabilityArray( null ) ); -// => false diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..08d3bcb --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-typed-array@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array@v0.2.2-esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-number@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/math-base-utils-absolute-difference@v0.3.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/constants-float64-sqrt-eps@v0.2.2-esm/index.mjs";function n(n){var d,m;if(t(n)){for(d=0,m=0;m1||n[m]<0)return!1;d+=n[m]}return r(d,1)<=i}if(s(n)){for(d=0,m=0;m1||n[m]<0)return!1;d+=n[m]}return r(d,1)<=i}return!1}export{n as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..08904b0 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isTypedArray from '@stdlib/assert-is-typed-array';\nimport isArray from '@stdlib/assert-is-array';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport absdiff from '@stdlib/math-base-utils-absolute-difference';\nimport FLOAT64_SQRT_EPS from '@stdlib/constants-float64-sqrt-eps';\n\n\n// MAIN //\n\n/**\n* Tests if a value is an array of probabilities that sum to one.\n*\n* @param {*} v - value to test\n* @returns {boolean} boolean indicating if a value is a probability array\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] );\n* // returns true\n*\n* @example\n* var bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) );\n* // returns true\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] );\n* // returns false\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 3.14, 0.0 ] );\n* // returns false\n*/\nfunction isUnityProbabilityArray( v ) {\n\tvar sum;\n\tvar i;\n\tif ( isArray( v ) ) {\n\t\tsum = 0.0;\n\t\tfor ( i = 0; i < v.length; i++ ) {\n\t\t\tif (\n\t\t\t\t!isNumber( v[ i ] ) ||\n\t\t\t\tv[ i ] > 1.0 ||\n\t\t\t\tv[ i ] < 0.0\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tsum += v[ i ];\n\t\t}\n\t\treturn ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS );\n\t}\n\tif ( isTypedArray( v ) ) {\n\t\tsum = 0.0;\n\t\tfor ( i = 0; i < v.length; i++ ) {\n\t\t\tif (\n\t\t\t\tv[ i ] > 1.0 ||\n\t\t\t\tv[ i ] < 0.0\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tsum += v[ i ];\n\t\t}\n\t\treturn ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS );\n\t}\n\treturn false;\n}\n\n\n// EXPORTS //\n\nexport default isUnityProbabilityArray;\n"],"names":["isUnityProbabilityArray","v","sum","i","isArray","length","isNumber","absdiff","FLOAT64_SQRT_EPS","isTypedArray"],"mappings":";;ufAqDA,SAASA,EAAyBC,GACjC,IAAIC,EACAC,EACJ,GAAKC,EAASH,GAAM,CAEnB,IADAC,EAAM,EACAC,EAAI,EAAGA,EAAIF,EAAEI,OAAQF,IAAM,CAChC,IACEG,EAAUL,EAAGE,KACdF,EAAGE,GAAM,GACTF,EAAGE,GAAM,EAET,OAAO,EAERD,GAAOD,EAAGE,EACV,CACD,OAASI,EAASL,EAAK,IAASM,CAChC,CACD,GAAKC,EAAcR,GAAM,CAExB,IADAC,EAAM,EACAC,EAAI,EAAGA,EAAIF,EAAEI,OAAQF,IAAM,CAChC,GACCF,EAAGE,GAAM,GACTF,EAAGE,GAAM,EAET,OAAO,EAERD,GAAOD,EAAGE,EACV,CACD,OAASI,EAASL,EAAK,IAASM,CAChC,CACD,OAAO,CACR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 13a67d1..0000000 --- a/lib/index.js +++ /dev/null @@ -1,49 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Test if a value is an array of probabilities that sum to one. -* -* @module @stdlib/assert-is-unity-probability-array -* -* @example -* var isUnityProbabilityArray = require( '@stdlib/assert-is-unity-probability-array' ); -* -* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] ); -* // returns true -* -* bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) ); -* // returns true -* -* bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] ); -* // returns false -* -* bool = isUnityProbabilityArray( [ 3.14, 0.0 ] ); -* // returns false -*/ - -// 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 d0bda40..0000000 --- a/lib/main.js +++ /dev/null @@ -1,90 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -var isArray = require( '@stdlib/assert-is-array' ); -var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var absdiff = require( '@stdlib/math-base-utils-absolute-difference' ); -var FLOAT64_SQRT_EPS = require( '@stdlib/constants-float64-sqrt-eps' ); - - -// MAIN // - -/** -* Tests if a value is an array of probabilities that sum to one. -* -* @param {*} v - value to test -* @returns {boolean} boolean indicating if a value is a probability array -* -* @example -* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] ); -* // returns true -* -* @example -* var bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) ); -* // returns true -* -* @example -* var bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] ); -* // returns false -* -* @example -* var bool = isUnityProbabilityArray( [ 3.14, 0.0 ] ); -* // returns false -*/ -function isUnityProbabilityArray( v ) { - var sum; - var i; - if ( isArray( v ) ) { - sum = 0.0; - for ( i = 0; i < v.length; i++ ) { - if ( - !isNumber( v[ i ] ) || - v[ i ] > 1.0 || - v[ i ] < 0.0 - ) { - return false; - } - sum += v[ i ]; - } - return ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS ); - } - if ( isTypedArray( v ) ) { - sum = 0.0; - for ( i = 0; i < v.length; i++ ) { - if ( - v[ i ] > 1.0 || - v[ i ] < 0.0 - ) { - return false; - } - sum += v[ i ]; - } - return ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS ); - } - return false; -} - - -// EXPORTS // - -module.exports = isUnityProbabilityArray; diff --git a/package.json b/package.json index 2375604..9ba851e 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.2", "description": "Test if a value is an array of probabilities that sum to one.", "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" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,47 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-array": "^0.2.2", - "@stdlib/assert-is-number": "^0.2.2", - "@stdlib/assert-is-typed-array": "^0.2.2", - "@stdlib/constants-float64-sqrt-eps": "^0.2.2", - "@stdlib/math-base-utils-absolute-difference": "^0.3.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/array-float32": "^0.2.2", - "@stdlib/array-float64": "^0.2.2", - "@stdlib/array-int16": "^0.2.2", - "@stdlib/array-int32": "^0.2.2", - "@stdlib/array-int8": "^0.2.2", - "@stdlib/array-uint16": "^0.2.2", - "@stdlib/array-uint32": "^0.2.2", - "@stdlib/array-uint8": "^0.2.2", - "@stdlib/array-uint8c": "^0.2.2", - "@stdlib/assert-is-boolean": "^0.2.2", - "@stdlib/buffer-from-array": "^0.2.2", - "@stdlib/math-base-special-pow": "^0.3.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.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdassert", @@ -105,4 +41,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..2282772 --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index a0424fb..0000000 --- a/test/test.js +++ /dev/null @@ -1,106 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Int8Array = require( '@stdlib/array-int8' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Float64Array = require( '@stdlib/array-float64' ); -var array2buffer = require( '@stdlib/buffer-from-array' ); -var isUnityProbabilityArray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof isUnityProbabilityArray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns `true` if provided an array of probabilities that sum to one', function test( t ) { - var values; - var i; - - values = [ - new Int8Array( [ 0, 0, 1 ] ), - new Uint8Array( [ 1, 0, 0 ] ), - new Uint8ClampedArray( [ 0, 1 ] ), - new Int16Array( [ 0, 0, 1, 0 ] ), - new Uint16Array( [ 1 ] ), - new Int32Array( [ 1, 0, 0 ] ), - new Uint32Array( [ 0, 1, 0 ] ), - new Float32Array( [ 0.0, 0.5, 0.5 ] ), - new Float64Array( [ 0.25, 0.25, 0.5 ] ), - [ 0.5, 0.25, 0.25 ] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.strictEqual( isUnityProbabilityArray( values[i] ), true, 'returns true when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function allows a difference in sum within floating-point epsilon', function test( t ) { - var bool = isUnityProbabilityArray( [ 0.1, 0.2, 0.1, 0.1, 0.2, 0.2, 0.1 ] ); - t.strictEqual( bool, true, 'returns true' ); - t.end(); -}); - -tape( 'the function returns `false` if not provided an array of probabilities that sum to one', function test( t ) { - var values; - var i; - - values = [ - '10', - '01', - '0.5', - '5', - 5, - NaN, - null, - void 0, - true, - [], - [ 5, null ], - [ 5, '5' ], - [ 1.0, 3.14 ], - [ -1.0, 1.0, 1.0 ], - [ 0.25, 0.33, 0.5 ], - new Float64Array( [ 0.25, 0.33, 0.5 ] ), - new Float64Array( [ 0.25, 1.33, 0.5 ] ), - new Float64Array( [ 0.25, -0.33, 0.5 ] ), - {}, - function noop() {}, - array2buffer( [ 1, 1, 0 ] ) - ]; - - for ( i = 0; i < values.length; i++ ) { - t.strictEqual( isUnityProbabilityArray( values[i] ), false, 'returns false when provided '+values[i] ); - } - t.end(); -}); From dbda8e4133563a03c0a0906aa83340c12a79391c Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 23 Dec 2024 01:30:52 +0000 Subject: [PATCH 119/133] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 2385bbd..2375604 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,8 @@ "@stdlib/assert-is-number": "^0.2.2", "@stdlib/assert-is-typed-array": "^0.2.2", "@stdlib/constants-float64-sqrt-eps": "^0.2.2", - "@stdlib/math-base-utils-absolute-difference": "^0.3.2" + "@stdlib/math-base-utils-absolute-difference": "^0.3.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2" }, "devDependencies": { "@stdlib/array-float32": "^0.2.2", @@ -104,4 +105,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 217f3ea67b8a51d0bcd3128349de70867772ea82 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 23 Dec 2024 01:37:22 +0000 Subject: [PATCH 120/133] Remove files --- index.d.ts | 48 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4895 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index 63a123d..0000000 --- a/index.d.ts +++ /dev/null @@ -1,48 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/** -* Tests if a value is an array of probabilities that sum to one. -* -* @param v - value to test -* @returns boolean indicating if a value is a probability array -* -* @example -* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] ); -* // returns true -* -* @example -* var bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) ); -* // returns true -* -* @example -* var bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] ); -* // returns false -* -* @example -* var bool = isUnityProbabilityArray( [ 3.14, 0.0 ] ); -* // returns false -*/ -declare function isUnityProbabilityArray( v: any ): v is ArrayLike; - - -// EXPORTS // - -export = isUnityProbabilityArray; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 08d3bcb..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-typed-array@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array@v0.2.2-esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-number@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/math-base-utils-absolute-difference@v0.3.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/constants-float64-sqrt-eps@v0.2.2-esm/index.mjs";function n(n){var d,m;if(t(n)){for(d=0,m=0;m1||n[m]<0)return!1;d+=n[m]}return r(d,1)<=i}if(s(n)){for(d=0,m=0;m1||n[m]<0)return!1;d+=n[m]}return r(d,1)<=i}return!1}export{n as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 08904b0..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isTypedArray from '@stdlib/assert-is-typed-array';\nimport isArray from '@stdlib/assert-is-array';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport absdiff from '@stdlib/math-base-utils-absolute-difference';\nimport FLOAT64_SQRT_EPS from '@stdlib/constants-float64-sqrt-eps';\n\n\n// MAIN //\n\n/**\n* Tests if a value is an array of probabilities that sum to one.\n*\n* @param {*} v - value to test\n* @returns {boolean} boolean indicating if a value is a probability array\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] );\n* // returns true\n*\n* @example\n* var bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) );\n* // returns true\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] );\n* // returns false\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 3.14, 0.0 ] );\n* // returns false\n*/\nfunction isUnityProbabilityArray( v ) {\n\tvar sum;\n\tvar i;\n\tif ( isArray( v ) ) {\n\t\tsum = 0.0;\n\t\tfor ( i = 0; i < v.length; i++ ) {\n\t\t\tif (\n\t\t\t\t!isNumber( v[ i ] ) ||\n\t\t\t\tv[ i ] > 1.0 ||\n\t\t\t\tv[ i ] < 0.0\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tsum += v[ i ];\n\t\t}\n\t\treturn ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS );\n\t}\n\tif ( isTypedArray( v ) ) {\n\t\tsum = 0.0;\n\t\tfor ( i = 0; i < v.length; i++ ) {\n\t\t\tif (\n\t\t\t\tv[ i ] > 1.0 ||\n\t\t\t\tv[ i ] < 0.0\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tsum += v[ i ];\n\t\t}\n\t\treturn ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS );\n\t}\n\treturn false;\n}\n\n\n// EXPORTS //\n\nexport default isUnityProbabilityArray;\n"],"names":["isUnityProbabilityArray","v","sum","i","isArray","length","isNumber","absdiff","FLOAT64_SQRT_EPS","isTypedArray"],"mappings":";;ufAqDA,SAASA,EAAyBC,GACjC,IAAIC,EACAC,EACJ,GAAKC,EAASH,GAAM,CAEnB,IADAC,EAAM,EACAC,EAAI,EAAGA,EAAIF,EAAEI,OAAQF,IAAM,CAChC,IACEG,EAAUL,EAAGE,KACdF,EAAGE,GAAM,GACTF,EAAGE,GAAM,EAET,OAAO,EAERD,GAAOD,EAAGE,EACV,CACD,OAASI,EAASL,EAAK,IAASM,CAChC,CACD,GAAKC,EAAcR,GAAM,CAExB,IADAC,EAAM,EACAC,EAAI,EAAGA,EAAIF,EAAEI,OAAQF,IAAM,CAChC,GACCF,EAAGE,GAAM,GACTF,EAAGE,GAAM,EAET,OAAO,EAERD,GAAOD,EAAGE,EACV,CACD,OAASI,EAASL,EAAK,IAASM,CAChC,CACD,OAAO,CACR"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 2282772..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From ab7c22d39516676af051b079b3410f19f8ea1dd7 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 23 Dec 2024 01:37:36 +0000 Subject: [PATCH 121/133] 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 | 163 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 43 +- SECURITY.md | 5 - benchmark/benchmark.js | 103 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 29 - docs/types/test.ts | 34 - examples/index.js | 48 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 49 - lib/main.js | 90 - package.json | 70 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 106 - 44 files changed, 4867 insertions(+), 4105 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 delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 0779e8a..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true # Note: this disables using two spaces to force a hard line break, which is permitted in Markdown. As we don't typically follow that practice (TMK), we should be safe to automatically trim. - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 386d96c..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-12-23T01:30:00.317Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 75a4c32..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/assert/is-unity-probability-array) 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 5119885..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/assert/is-unity-probability-array) 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 3b386b0..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: '49 1 * * 1' - - # 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 + + ```
@@ -178,7 +169,7 @@ bool = isUnityProbabilityArray( null ); ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -245,9 +236,9 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/assert/is-probability]: https://github.com/stdlib-js/assert-is-probability +[@stdlib/assert/is-probability]: https://github.com/stdlib-js/assert-is-probability/tree/esm -[@stdlib/assert/is-probability-array]: https://github.com/stdlib-js/assert-is-probability-array +[@stdlib/assert/is-probability-array]: https://github.com/stdlib-js/assert-is-probability-array/tree/esm diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 510a5ed..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,103 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var isUnityProbabilityArray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x; - var i; - - x = []; - for ( i = 0; i < len; i++ ) { - x.push( 1.0/len ); - } - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: we are testing the worst case scenario where a function must scan the entire array before finding a failing value. - x[ len-1 ] = i * 3.14; - bool = isUnityProbabilityArray( x ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( isBoolean( bool ) ) { - b.pass( 'benchmark finished' ); - } else { - b.fail( 'should return a boolean' ); - } - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':len='+len, f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index 5a6810d..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/assert/is-unity-probability-array" -%% click B href "https://github.com/stdlib-js/assert-is-unity-probability-array/tree/main" -%% click C href "https://github.com/stdlib-js/assert-is-unity-probability-array/tree/production" -%% click D href "https://github.com/stdlib-js/assert-is-unity-probability-array/tree/esm" -%% click E href "https://github.com/stdlib-js/assert-is-unity-probability-array/tree/deno" -%% click F href "https://github.com/stdlib-js/assert-is-unity-probability-array/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/assert/is-unity-probability-array -[production-url]: https://github.com/stdlib-js/assert-is-unity-probability-array/tree/production -[deno-url]: https://github.com/stdlib-js/assert-is-unity-probability-array/tree/deno -[deno-readme]: https://github.com/stdlib-js/assert-is-unity-probability-array/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/assert-is-unity-probability-array/tree/umd -[umd-readme]: https://github.com/stdlib-js/assert-is-unity-probability-array/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/assert-is-unity-probability-array/tree/esm -[esm-readme]: https://github.com/stdlib-js/assert-is-unity-probability-array/blob/esm/README.md \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index c77d01e..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import isUnityProbabilityArray from '../docs/types/index'; -export = isUnityProbabilityArray; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 70d7801..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var f=function(r,i){return function(){return i||r((i={exports:{}}).exports,i),i.exports}};var u=f(function(m,s){ -var n=require('@stdlib/assert-is-typed-array/dist'),l=require('@stdlib/assert-is-array/dist'),o=require('@stdlib/assert-is-number/dist').isPrimitive,a=require('@stdlib/math-base-utils-absolute-difference/dist'),t=require('@stdlib/constants-float64-sqrt-eps/dist');function q(r){var i,e;if(l(r)){for(i=0,e=0;e1||r[e]<0)return!1;i+=r[e]}return a(i,1)<=t}if(n(r)){for(i=0,e=0;e1||r[e]<0)return!1;i+=r[e]}return a(i,1)<=t}return!1}s.exports=q -});var y=u();module.exports=y; -/** @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 387d5ad..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) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isTypedArray = require( '@stdlib/assert-is-typed-array' );\nvar isArray = require( '@stdlib/assert-is-array' );\nvar isNumber = require( '@stdlib/assert-is-number' ).isPrimitive;\nvar absdiff = require( '@stdlib/math-base-utils-absolute-difference' );\nvar FLOAT64_SQRT_EPS = require( '@stdlib/constants-float64-sqrt-eps' );\n\n\n// MAIN //\n\n/**\n* Tests if a value is an array of probabilities that sum to one.\n*\n* @param {*} v - value to test\n* @returns {boolean} boolean indicating if a value is a probability array\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] );\n* // returns true\n*\n* @example\n* var bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) );\n* // returns true\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] );\n* // returns false\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 3.14, 0.0 ] );\n* // returns false\n*/\nfunction isUnityProbabilityArray( v ) {\n\tvar sum;\n\tvar i;\n\tif ( isArray( v ) ) {\n\t\tsum = 0.0;\n\t\tfor ( i = 0; i < v.length; i++ ) {\n\t\t\tif (\n\t\t\t\t!isNumber( v[ i ] ) ||\n\t\t\t\tv[ i ] > 1.0 ||\n\t\t\t\tv[ i ] < 0.0\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tsum += v[ i ];\n\t\t}\n\t\treturn ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS );\n\t}\n\tif ( isTypedArray( v ) ) {\n\t\tsum = 0.0;\n\t\tfor ( i = 0; i < v.length; i++ ) {\n\t\t\tif (\n\t\t\t\tv[ i ] > 1.0 ||\n\t\t\t\tv[ i ] < 0.0\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tsum += v[ i ];\n\t\t}\n\t\treturn ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS );\n\t}\n\treturn false;\n}\n\n\n// EXPORTS //\n\nmodule.exports = isUnityProbabilityArray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Test if a value is an array of probabilities that sum to one.\n*\n* @module @stdlib/assert-is-unity-probability-array\n*\n* @example\n* var isUnityProbabilityArray = require( '@stdlib/assert-is-unity-probability-array' );\n*\n* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] );\n* // returns true\n*\n* bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) );\n* // returns true\n*\n* bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] );\n* // returns false\n*\n* bool = isUnityProbabilityArray( [ 3.14, 0.0 ] );\n* // returns false\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,EAAe,QAAS,+BAAgC,EACxDC,EAAU,QAAS,yBAA0B,EAC7CC,EAAW,QAAS,0BAA2B,EAAE,YACjDC,EAAU,QAAS,6CAA8C,EACjEC,EAAmB,QAAS,oCAAqC,EA2BrE,SAASC,EAAyBC,EAAI,CACrC,IAAIC,EACAC,EACJ,GAAKP,EAASK,CAAE,EAAI,CAEnB,IADAC,EAAM,EACAC,EAAI,EAAGA,EAAIF,EAAE,OAAQE,IAAM,CAChC,GACC,CAACN,EAAUI,EAAGE,CAAE,CAAE,GAClBF,EAAGE,CAAE,EAAI,GACTF,EAAGE,CAAE,EAAI,EAET,MAAO,GAERD,GAAOD,EAAGE,CAAE,CACb,CACA,OAASL,EAASI,EAAK,CAAI,GAAKH,CACjC,CACA,GAAKJ,EAAcM,CAAE,EAAI,CAExB,IADAC,EAAM,EACAC,EAAI,EAAGA,EAAIF,EAAE,OAAQE,IAAM,CAChC,GACCF,EAAGE,CAAE,EAAI,GACTF,EAAGE,CAAE,EAAI,EAET,MAAO,GAERD,GAAOD,EAAGE,CAAE,CACb,CACA,OAASL,EAASI,EAAK,CAAI,GAAKH,CACjC,CACA,MAAO,EACR,CAKAL,EAAO,QAAUM,IC9CjB,IAAII,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isTypedArray", "isArray", "isNumber", "absdiff", "FLOAT64_SQRT_EPS", "isUnityProbabilityArray", "v", "sum", "i", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index a2414be..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,29 +0,0 @@ - -{{alias}}( value ) - Tests if a value is an array of probabilities that sum to one. - - Parameters - ---------- - value: any - Value to test. - - Returns - ------- - bool: boolean - Boolean indicating whether value is an array of probabilities that sum - to one. - - Examples - -------- - > var bool = {{alias}}( [ 0.25, 0.5, 0.25 ] ) - true - > bool = {{alias}}( new {{alias:@stdlib/array/uint8}}( [ 0, 1 ] ) ) - true - > bool = {{alias}}( [ 0.4, 0.4, 0.4 ] ) - false - > bool = {{alias}}( [ 3.14, 0.0 ] ) - false - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 6b41658..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,34 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import isUnityProbabilityArray = require( './index' ); - - -// TESTS // - -// The function returns a boolean... -{ - isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] ); // $ExpectType boolean - isUnityProbabilityArray( [ 2, 3 ] ); // $ExpectType boolean -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - isUnityProbabilityArray(); // $ExpectError - isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ], 123 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index b0b6bbc..0000000 --- a/examples/index.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var Uint8Array = require( '@stdlib/array-uint8' ); -var isUnityProbabilityArray = require( './../lib' ); - -var arr = [ 0.0, 1.0 ]; -console.log( isUnityProbabilityArray( arr ) ); -// => true - -arr = [ 0.5, 0.25, 0.25 ]; -console.log( isUnityProbabilityArray( arr ) ); -// => true - -arr = new Uint8Array( [ 0, 0, 1, 0 ] ); -console.log( isUnityProbabilityArray( arr ) ); -// => true - -arr = [ 0.4, 0.4, 0.4 ]; -console.log( isUnityProbabilityArray( arr ) ); -// => false - -arr = [ 3.14, -1.0 ]; -console.log( isUnityProbabilityArray( arr ) ); -// => false - -console.log( isUnityProbabilityArray( [] ) ); -// => false - -console.log( isUnityProbabilityArray( null ) ); -// => false diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..08d3bcb --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-typed-array@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array@v0.2.2-esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-number@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/math-base-utils-absolute-difference@v0.3.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/constants-float64-sqrt-eps@v0.2.2-esm/index.mjs";function n(n){var d,m;if(t(n)){for(d=0,m=0;m1||n[m]<0)return!1;d+=n[m]}return r(d,1)<=i}if(s(n)){for(d=0,m=0;m1||n[m]<0)return!1;d+=n[m]}return r(d,1)<=i}return!1}export{n as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..08904b0 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isTypedArray from '@stdlib/assert-is-typed-array';\nimport isArray from '@stdlib/assert-is-array';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport absdiff from '@stdlib/math-base-utils-absolute-difference';\nimport FLOAT64_SQRT_EPS from '@stdlib/constants-float64-sqrt-eps';\n\n\n// MAIN //\n\n/**\n* Tests if a value is an array of probabilities that sum to one.\n*\n* @param {*} v - value to test\n* @returns {boolean} boolean indicating if a value is a probability array\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] );\n* // returns true\n*\n* @example\n* var bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) );\n* // returns true\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] );\n* // returns false\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 3.14, 0.0 ] );\n* // returns false\n*/\nfunction isUnityProbabilityArray( v ) {\n\tvar sum;\n\tvar i;\n\tif ( isArray( v ) ) {\n\t\tsum = 0.0;\n\t\tfor ( i = 0; i < v.length; i++ ) {\n\t\t\tif (\n\t\t\t\t!isNumber( v[ i ] ) ||\n\t\t\t\tv[ i ] > 1.0 ||\n\t\t\t\tv[ i ] < 0.0\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tsum += v[ i ];\n\t\t}\n\t\treturn ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS );\n\t}\n\tif ( isTypedArray( v ) ) {\n\t\tsum = 0.0;\n\t\tfor ( i = 0; i < v.length; i++ ) {\n\t\t\tif (\n\t\t\t\tv[ i ] > 1.0 ||\n\t\t\t\tv[ i ] < 0.0\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tsum += v[ i ];\n\t\t}\n\t\treturn ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS );\n\t}\n\treturn false;\n}\n\n\n// EXPORTS //\n\nexport default isUnityProbabilityArray;\n"],"names":["isUnityProbabilityArray","v","sum","i","isArray","length","isNumber","absdiff","FLOAT64_SQRT_EPS","isTypedArray"],"mappings":";;ufAqDA,SAASA,EAAyBC,GACjC,IAAIC,EACAC,EACJ,GAAKC,EAASH,GAAM,CAEnB,IADAC,EAAM,EACAC,EAAI,EAAGA,EAAIF,EAAEI,OAAQF,IAAM,CAChC,IACEG,EAAUL,EAAGE,KACdF,EAAGE,GAAM,GACTF,EAAGE,GAAM,EAET,OAAO,EAERD,GAAOD,EAAGE,EACV,CACD,OAASI,EAASL,EAAK,IAASM,CAChC,CACD,GAAKC,EAAcR,GAAM,CAExB,IADAC,EAAM,EACAC,EAAI,EAAGA,EAAIF,EAAEI,OAAQF,IAAM,CAChC,GACCF,EAAGE,GAAM,GACTF,EAAGE,GAAM,EAET,OAAO,EAERD,GAAOD,EAAGE,EACV,CACD,OAASI,EAASL,EAAK,IAASM,CAChC,CACD,OAAO,CACR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 13a67d1..0000000 --- a/lib/index.js +++ /dev/null @@ -1,49 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Test if a value is an array of probabilities that sum to one. -* -* @module @stdlib/assert-is-unity-probability-array -* -* @example -* var isUnityProbabilityArray = require( '@stdlib/assert-is-unity-probability-array' ); -* -* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] ); -* // returns true -* -* bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) ); -* // returns true -* -* bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] ); -* // returns false -* -* bool = isUnityProbabilityArray( [ 3.14, 0.0 ] ); -* // returns false -*/ - -// 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 d0bda40..0000000 --- a/lib/main.js +++ /dev/null @@ -1,90 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -var isArray = require( '@stdlib/assert-is-array' ); -var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var absdiff = require( '@stdlib/math-base-utils-absolute-difference' ); -var FLOAT64_SQRT_EPS = require( '@stdlib/constants-float64-sqrt-eps' ); - - -// MAIN // - -/** -* Tests if a value is an array of probabilities that sum to one. -* -* @param {*} v - value to test -* @returns {boolean} boolean indicating if a value is a probability array -* -* @example -* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] ); -* // returns true -* -* @example -* var bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) ); -* // returns true -* -* @example -* var bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] ); -* // returns false -* -* @example -* var bool = isUnityProbabilityArray( [ 3.14, 0.0 ] ); -* // returns false -*/ -function isUnityProbabilityArray( v ) { - var sum; - var i; - if ( isArray( v ) ) { - sum = 0.0; - for ( i = 0; i < v.length; i++ ) { - if ( - !isNumber( v[ i ] ) || - v[ i ] > 1.0 || - v[ i ] < 0.0 - ) { - return false; - } - sum += v[ i ]; - } - return ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS ); - } - if ( isTypedArray( v ) ) { - sum = 0.0; - for ( i = 0; i < v.length; i++ ) { - if ( - v[ i ] > 1.0 || - v[ i ] < 0.0 - ) { - return false; - } - sum += v[ i ]; - } - return ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS ); - } - return false; -} - - -// EXPORTS // - -module.exports = isUnityProbabilityArray; diff --git a/package.json b/package.json index 2375604..9ba851e 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.2", "description": "Test if a value is an array of probabilities that sum to one.", "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" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,47 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-array": "^0.2.2", - "@stdlib/assert-is-number": "^0.2.2", - "@stdlib/assert-is-typed-array": "^0.2.2", - "@stdlib/constants-float64-sqrt-eps": "^0.2.2", - "@stdlib/math-base-utils-absolute-difference": "^0.3.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/array-float32": "^0.2.2", - "@stdlib/array-float64": "^0.2.2", - "@stdlib/array-int16": "^0.2.2", - "@stdlib/array-int32": "^0.2.2", - "@stdlib/array-int8": "^0.2.2", - "@stdlib/array-uint16": "^0.2.2", - "@stdlib/array-uint32": "^0.2.2", - "@stdlib/array-uint8": "^0.2.2", - "@stdlib/array-uint8c": "^0.2.2", - "@stdlib/assert-is-boolean": "^0.2.2", - "@stdlib/buffer-from-array": "^0.2.2", - "@stdlib/math-base-special-pow": "^0.3.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.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdassert", @@ -105,4 +41,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..2282772 --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index a0424fb..0000000 --- a/test/test.js +++ /dev/null @@ -1,106 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Int8Array = require( '@stdlib/array-int8' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Float64Array = require( '@stdlib/array-float64' ); -var array2buffer = require( '@stdlib/buffer-from-array' ); -var isUnityProbabilityArray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof isUnityProbabilityArray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns `true` if provided an array of probabilities that sum to one', function test( t ) { - var values; - var i; - - values = [ - new Int8Array( [ 0, 0, 1 ] ), - new Uint8Array( [ 1, 0, 0 ] ), - new Uint8ClampedArray( [ 0, 1 ] ), - new Int16Array( [ 0, 0, 1, 0 ] ), - new Uint16Array( [ 1 ] ), - new Int32Array( [ 1, 0, 0 ] ), - new Uint32Array( [ 0, 1, 0 ] ), - new Float32Array( [ 0.0, 0.5, 0.5 ] ), - new Float64Array( [ 0.25, 0.25, 0.5 ] ), - [ 0.5, 0.25, 0.25 ] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.strictEqual( isUnityProbabilityArray( values[i] ), true, 'returns true when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function allows a difference in sum within floating-point epsilon', function test( t ) { - var bool = isUnityProbabilityArray( [ 0.1, 0.2, 0.1, 0.1, 0.2, 0.2, 0.1 ] ); - t.strictEqual( bool, true, 'returns true' ); - t.end(); -}); - -tape( 'the function returns `false` if not provided an array of probabilities that sum to one', function test( t ) { - var values; - var i; - - values = [ - '10', - '01', - '0.5', - '5', - 5, - NaN, - null, - void 0, - true, - [], - [ 5, null ], - [ 5, '5' ], - [ 1.0, 3.14 ], - [ -1.0, 1.0, 1.0 ], - [ 0.25, 0.33, 0.5 ], - new Float64Array( [ 0.25, 0.33, 0.5 ] ), - new Float64Array( [ 0.25, 1.33, 0.5 ] ), - new Float64Array( [ 0.25, -0.33, 0.5 ] ), - {}, - function noop() {}, - array2buffer( [ 1, 1, 0 ] ) - ]; - - for ( i = 0; i < values.length; i++ ) { - t.strictEqual( isUnityProbabilityArray( values[i] ), false, 'returns false when provided '+values[i] ); - } - t.end(); -}); From 814b067db7377554dcffa5bd0de7977e571283a8 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 30 Dec 2024 03:10:36 +0000 Subject: [PATCH 122/133] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 2385bbd..2375604 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,8 @@ "@stdlib/assert-is-number": "^0.2.2", "@stdlib/assert-is-typed-array": "^0.2.2", "@stdlib/constants-float64-sqrt-eps": "^0.2.2", - "@stdlib/math-base-utils-absolute-difference": "^0.3.2" + "@stdlib/math-base-utils-absolute-difference": "^0.3.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2" }, "devDependencies": { "@stdlib/array-float32": "^0.2.2", @@ -104,4 +105,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From eb64c187ee7c84ab59113f07a3e0aee3420b3f8e Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 30 Dec 2024 04:24:52 +0000 Subject: [PATCH 123/133] Remove files --- index.d.ts | 48 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4895 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index 63a123d..0000000 --- a/index.d.ts +++ /dev/null @@ -1,48 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/** -* Tests if a value is an array of probabilities that sum to one. -* -* @param v - value to test -* @returns boolean indicating if a value is a probability array -* -* @example -* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] ); -* // returns true -* -* @example -* var bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) ); -* // returns true -* -* @example -* var bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] ); -* // returns false -* -* @example -* var bool = isUnityProbabilityArray( [ 3.14, 0.0 ] ); -* // returns false -*/ -declare function isUnityProbabilityArray( v: any ): v is ArrayLike; - - -// EXPORTS // - -export = isUnityProbabilityArray; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 08d3bcb..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-typed-array@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array@v0.2.2-esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-number@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/math-base-utils-absolute-difference@v0.3.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/constants-float64-sqrt-eps@v0.2.2-esm/index.mjs";function n(n){var d,m;if(t(n)){for(d=0,m=0;m1||n[m]<0)return!1;d+=n[m]}return r(d,1)<=i}if(s(n)){for(d=0,m=0;m1||n[m]<0)return!1;d+=n[m]}return r(d,1)<=i}return!1}export{n as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 08904b0..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isTypedArray from '@stdlib/assert-is-typed-array';\nimport isArray from '@stdlib/assert-is-array';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport absdiff from '@stdlib/math-base-utils-absolute-difference';\nimport FLOAT64_SQRT_EPS from '@stdlib/constants-float64-sqrt-eps';\n\n\n// MAIN //\n\n/**\n* Tests if a value is an array of probabilities that sum to one.\n*\n* @param {*} v - value to test\n* @returns {boolean} boolean indicating if a value is a probability array\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] );\n* // returns true\n*\n* @example\n* var bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) );\n* // returns true\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] );\n* // returns false\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 3.14, 0.0 ] );\n* // returns false\n*/\nfunction isUnityProbabilityArray( v ) {\n\tvar sum;\n\tvar i;\n\tif ( isArray( v ) ) {\n\t\tsum = 0.0;\n\t\tfor ( i = 0; i < v.length; i++ ) {\n\t\t\tif (\n\t\t\t\t!isNumber( v[ i ] ) ||\n\t\t\t\tv[ i ] > 1.0 ||\n\t\t\t\tv[ i ] < 0.0\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tsum += v[ i ];\n\t\t}\n\t\treturn ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS );\n\t}\n\tif ( isTypedArray( v ) ) {\n\t\tsum = 0.0;\n\t\tfor ( i = 0; i < v.length; i++ ) {\n\t\t\tif (\n\t\t\t\tv[ i ] > 1.0 ||\n\t\t\t\tv[ i ] < 0.0\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tsum += v[ i ];\n\t\t}\n\t\treturn ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS );\n\t}\n\treturn false;\n}\n\n\n// EXPORTS //\n\nexport default isUnityProbabilityArray;\n"],"names":["isUnityProbabilityArray","v","sum","i","isArray","length","isNumber","absdiff","FLOAT64_SQRT_EPS","isTypedArray"],"mappings":";;ufAqDA,SAASA,EAAyBC,GACjC,IAAIC,EACAC,EACJ,GAAKC,EAASH,GAAM,CAEnB,IADAC,EAAM,EACAC,EAAI,EAAGA,EAAIF,EAAEI,OAAQF,IAAM,CAChC,IACEG,EAAUL,EAAGE,KACdF,EAAGE,GAAM,GACTF,EAAGE,GAAM,EAET,OAAO,EAERD,GAAOD,EAAGE,EACV,CACD,OAASI,EAASL,EAAK,IAASM,CAChC,CACD,GAAKC,EAAcR,GAAM,CAExB,IADAC,EAAM,EACAC,EAAI,EAAGA,EAAIF,EAAEI,OAAQF,IAAM,CAChC,GACCF,EAAGE,GAAM,GACTF,EAAGE,GAAM,EAET,OAAO,EAERD,GAAOD,EAAGE,EACV,CACD,OAASI,EAASL,EAAK,IAASM,CAChC,CACD,OAAO,CACR"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 2282772..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 0d577a138b212db5060198a3bcaab6f403aaf2ba Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 30 Dec 2024 04:25:07 +0000 Subject: [PATCH 124/133] 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 | 163 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 43 +- SECURITY.md | 5 - benchmark/benchmark.js | 103 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 29 - docs/types/test.ts | 34 - examples/index.js | 48 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 49 - lib/main.js | 90 - package.json | 70 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 106 - 44 files changed, 4867 insertions(+), 4105 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 delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 0779e8a..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true # Note: this disables using two spaces to force a hard line break, which is permitted in Markdown. As we don't typically follow that practice (TMK), we should be safe to automatically trim. - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 9e45c6d..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-12-30T02:45:22.172Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 75a4c32..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/assert/is-unity-probability-array) 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 5119885..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/assert/is-unity-probability-array) 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 3b386b0..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: '49 1 * * 1' - - # 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 + + ```
@@ -178,7 +169,7 @@ bool = isUnityProbabilityArray( null ); ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -245,9 +236,9 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/assert/is-probability]: https://github.com/stdlib-js/assert-is-probability +[@stdlib/assert/is-probability]: https://github.com/stdlib-js/assert-is-probability/tree/esm -[@stdlib/assert/is-probability-array]: https://github.com/stdlib-js/assert-is-probability-array +[@stdlib/assert/is-probability-array]: https://github.com/stdlib-js/assert-is-probability-array/tree/esm diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 510a5ed..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,103 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var isUnityProbabilityArray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x; - var i; - - x = []; - for ( i = 0; i < len; i++ ) { - x.push( 1.0/len ); - } - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: we are testing the worst case scenario where a function must scan the entire array before finding a failing value. - x[ len-1 ] = i * 3.14; - bool = isUnityProbabilityArray( x ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( isBoolean( bool ) ) { - b.pass( 'benchmark finished' ); - } else { - b.fail( 'should return a boolean' ); - } - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':len='+len, f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index 5a6810d..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/assert/is-unity-probability-array" -%% click B href "https://github.com/stdlib-js/assert-is-unity-probability-array/tree/main" -%% click C href "https://github.com/stdlib-js/assert-is-unity-probability-array/tree/production" -%% click D href "https://github.com/stdlib-js/assert-is-unity-probability-array/tree/esm" -%% click E href "https://github.com/stdlib-js/assert-is-unity-probability-array/tree/deno" -%% click F href "https://github.com/stdlib-js/assert-is-unity-probability-array/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/assert/is-unity-probability-array -[production-url]: https://github.com/stdlib-js/assert-is-unity-probability-array/tree/production -[deno-url]: https://github.com/stdlib-js/assert-is-unity-probability-array/tree/deno -[deno-readme]: https://github.com/stdlib-js/assert-is-unity-probability-array/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/assert-is-unity-probability-array/tree/umd -[umd-readme]: https://github.com/stdlib-js/assert-is-unity-probability-array/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/assert-is-unity-probability-array/tree/esm -[esm-readme]: https://github.com/stdlib-js/assert-is-unity-probability-array/blob/esm/README.md \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index c77d01e..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import isUnityProbabilityArray from '../docs/types/index'; -export = isUnityProbabilityArray; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 70d7801..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var f=function(r,i){return function(){return i||r((i={exports:{}}).exports,i),i.exports}};var u=f(function(m,s){ -var n=require('@stdlib/assert-is-typed-array/dist'),l=require('@stdlib/assert-is-array/dist'),o=require('@stdlib/assert-is-number/dist').isPrimitive,a=require('@stdlib/math-base-utils-absolute-difference/dist'),t=require('@stdlib/constants-float64-sqrt-eps/dist');function q(r){var i,e;if(l(r)){for(i=0,e=0;e1||r[e]<0)return!1;i+=r[e]}return a(i,1)<=t}if(n(r)){for(i=0,e=0;e1||r[e]<0)return!1;i+=r[e]}return a(i,1)<=t}return!1}s.exports=q -});var y=u();module.exports=y; -/** @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 387d5ad..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) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isTypedArray = require( '@stdlib/assert-is-typed-array' );\nvar isArray = require( '@stdlib/assert-is-array' );\nvar isNumber = require( '@stdlib/assert-is-number' ).isPrimitive;\nvar absdiff = require( '@stdlib/math-base-utils-absolute-difference' );\nvar FLOAT64_SQRT_EPS = require( '@stdlib/constants-float64-sqrt-eps' );\n\n\n// MAIN //\n\n/**\n* Tests if a value is an array of probabilities that sum to one.\n*\n* @param {*} v - value to test\n* @returns {boolean} boolean indicating if a value is a probability array\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] );\n* // returns true\n*\n* @example\n* var bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) );\n* // returns true\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] );\n* // returns false\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 3.14, 0.0 ] );\n* // returns false\n*/\nfunction isUnityProbabilityArray( v ) {\n\tvar sum;\n\tvar i;\n\tif ( isArray( v ) ) {\n\t\tsum = 0.0;\n\t\tfor ( i = 0; i < v.length; i++ ) {\n\t\t\tif (\n\t\t\t\t!isNumber( v[ i ] ) ||\n\t\t\t\tv[ i ] > 1.0 ||\n\t\t\t\tv[ i ] < 0.0\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tsum += v[ i ];\n\t\t}\n\t\treturn ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS );\n\t}\n\tif ( isTypedArray( v ) ) {\n\t\tsum = 0.0;\n\t\tfor ( i = 0; i < v.length; i++ ) {\n\t\t\tif (\n\t\t\t\tv[ i ] > 1.0 ||\n\t\t\t\tv[ i ] < 0.0\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tsum += v[ i ];\n\t\t}\n\t\treturn ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS );\n\t}\n\treturn false;\n}\n\n\n// EXPORTS //\n\nmodule.exports = isUnityProbabilityArray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Test if a value is an array of probabilities that sum to one.\n*\n* @module @stdlib/assert-is-unity-probability-array\n*\n* @example\n* var isUnityProbabilityArray = require( '@stdlib/assert-is-unity-probability-array' );\n*\n* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] );\n* // returns true\n*\n* bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) );\n* // returns true\n*\n* bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] );\n* // returns false\n*\n* bool = isUnityProbabilityArray( [ 3.14, 0.0 ] );\n* // returns false\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,EAAe,QAAS,+BAAgC,EACxDC,EAAU,QAAS,yBAA0B,EAC7CC,EAAW,QAAS,0BAA2B,EAAE,YACjDC,EAAU,QAAS,6CAA8C,EACjEC,EAAmB,QAAS,oCAAqC,EA2BrE,SAASC,EAAyBC,EAAI,CACrC,IAAIC,EACAC,EACJ,GAAKP,EAASK,CAAE,EAAI,CAEnB,IADAC,EAAM,EACAC,EAAI,EAAGA,EAAIF,EAAE,OAAQE,IAAM,CAChC,GACC,CAACN,EAAUI,EAAGE,CAAE,CAAE,GAClBF,EAAGE,CAAE,EAAI,GACTF,EAAGE,CAAE,EAAI,EAET,MAAO,GAERD,GAAOD,EAAGE,CAAE,CACb,CACA,OAASL,EAASI,EAAK,CAAI,GAAKH,CACjC,CACA,GAAKJ,EAAcM,CAAE,EAAI,CAExB,IADAC,EAAM,EACAC,EAAI,EAAGA,EAAIF,EAAE,OAAQE,IAAM,CAChC,GACCF,EAAGE,CAAE,EAAI,GACTF,EAAGE,CAAE,EAAI,EAET,MAAO,GAERD,GAAOD,EAAGE,CAAE,CACb,CACA,OAASL,EAASI,EAAK,CAAI,GAAKH,CACjC,CACA,MAAO,EACR,CAKAL,EAAO,QAAUM,IC9CjB,IAAII,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isTypedArray", "isArray", "isNumber", "absdiff", "FLOAT64_SQRT_EPS", "isUnityProbabilityArray", "v", "sum", "i", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index a2414be..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,29 +0,0 @@ - -{{alias}}( value ) - Tests if a value is an array of probabilities that sum to one. - - Parameters - ---------- - value: any - Value to test. - - Returns - ------- - bool: boolean - Boolean indicating whether value is an array of probabilities that sum - to one. - - Examples - -------- - > var bool = {{alias}}( [ 0.25, 0.5, 0.25 ] ) - true - > bool = {{alias}}( new {{alias:@stdlib/array/uint8}}( [ 0, 1 ] ) ) - true - > bool = {{alias}}( [ 0.4, 0.4, 0.4 ] ) - false - > bool = {{alias}}( [ 3.14, 0.0 ] ) - false - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 6b41658..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,34 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import isUnityProbabilityArray = require( './index' ); - - -// TESTS // - -// The function returns a boolean... -{ - isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] ); // $ExpectType boolean - isUnityProbabilityArray( [ 2, 3 ] ); // $ExpectType boolean -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - isUnityProbabilityArray(); // $ExpectError - isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ], 123 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index b0b6bbc..0000000 --- a/examples/index.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var Uint8Array = require( '@stdlib/array-uint8' ); -var isUnityProbabilityArray = require( './../lib' ); - -var arr = [ 0.0, 1.0 ]; -console.log( isUnityProbabilityArray( arr ) ); -// => true - -arr = [ 0.5, 0.25, 0.25 ]; -console.log( isUnityProbabilityArray( arr ) ); -// => true - -arr = new Uint8Array( [ 0, 0, 1, 0 ] ); -console.log( isUnityProbabilityArray( arr ) ); -// => true - -arr = [ 0.4, 0.4, 0.4 ]; -console.log( isUnityProbabilityArray( arr ) ); -// => false - -arr = [ 3.14, -1.0 ]; -console.log( isUnityProbabilityArray( arr ) ); -// => false - -console.log( isUnityProbabilityArray( [] ) ); -// => false - -console.log( isUnityProbabilityArray( null ) ); -// => false diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..08d3bcb --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-typed-array@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array@v0.2.2-esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-number@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/math-base-utils-absolute-difference@v0.3.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/constants-float64-sqrt-eps@v0.2.2-esm/index.mjs";function n(n){var d,m;if(t(n)){for(d=0,m=0;m1||n[m]<0)return!1;d+=n[m]}return r(d,1)<=i}if(s(n)){for(d=0,m=0;m1||n[m]<0)return!1;d+=n[m]}return r(d,1)<=i}return!1}export{n as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..08904b0 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isTypedArray from '@stdlib/assert-is-typed-array';\nimport isArray from '@stdlib/assert-is-array';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport absdiff from '@stdlib/math-base-utils-absolute-difference';\nimport FLOAT64_SQRT_EPS from '@stdlib/constants-float64-sqrt-eps';\n\n\n// MAIN //\n\n/**\n* Tests if a value is an array of probabilities that sum to one.\n*\n* @param {*} v - value to test\n* @returns {boolean} boolean indicating if a value is a probability array\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] );\n* // returns true\n*\n* @example\n* var bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) );\n* // returns true\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] );\n* // returns false\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 3.14, 0.0 ] );\n* // returns false\n*/\nfunction isUnityProbabilityArray( v ) {\n\tvar sum;\n\tvar i;\n\tif ( isArray( v ) ) {\n\t\tsum = 0.0;\n\t\tfor ( i = 0; i < v.length; i++ ) {\n\t\t\tif (\n\t\t\t\t!isNumber( v[ i ] ) ||\n\t\t\t\tv[ i ] > 1.0 ||\n\t\t\t\tv[ i ] < 0.0\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tsum += v[ i ];\n\t\t}\n\t\treturn ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS );\n\t}\n\tif ( isTypedArray( v ) ) {\n\t\tsum = 0.0;\n\t\tfor ( i = 0; i < v.length; i++ ) {\n\t\t\tif (\n\t\t\t\tv[ i ] > 1.0 ||\n\t\t\t\tv[ i ] < 0.0\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tsum += v[ i ];\n\t\t}\n\t\treturn ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS );\n\t}\n\treturn false;\n}\n\n\n// EXPORTS //\n\nexport default isUnityProbabilityArray;\n"],"names":["isUnityProbabilityArray","v","sum","i","isArray","length","isNumber","absdiff","FLOAT64_SQRT_EPS","isTypedArray"],"mappings":";;ufAqDA,SAASA,EAAyBC,GACjC,IAAIC,EACAC,EACJ,GAAKC,EAASH,GAAM,CAEnB,IADAC,EAAM,EACAC,EAAI,EAAGA,EAAIF,EAAEI,OAAQF,IAAM,CAChC,IACEG,EAAUL,EAAGE,KACdF,EAAGE,GAAM,GACTF,EAAGE,GAAM,EAET,OAAO,EAERD,GAAOD,EAAGE,EACV,CACD,OAASI,EAASL,EAAK,IAASM,CAChC,CACD,GAAKC,EAAcR,GAAM,CAExB,IADAC,EAAM,EACAC,EAAI,EAAGA,EAAIF,EAAEI,OAAQF,IAAM,CAChC,GACCF,EAAGE,GAAM,GACTF,EAAGE,GAAM,EAET,OAAO,EAERD,GAAOD,EAAGE,EACV,CACD,OAASI,EAASL,EAAK,IAASM,CAChC,CACD,OAAO,CACR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 13a67d1..0000000 --- a/lib/index.js +++ /dev/null @@ -1,49 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Test if a value is an array of probabilities that sum to one. -* -* @module @stdlib/assert-is-unity-probability-array -* -* @example -* var isUnityProbabilityArray = require( '@stdlib/assert-is-unity-probability-array' ); -* -* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] ); -* // returns true -* -* bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) ); -* // returns true -* -* bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] ); -* // returns false -* -* bool = isUnityProbabilityArray( [ 3.14, 0.0 ] ); -* // returns false -*/ - -// 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 d0bda40..0000000 --- a/lib/main.js +++ /dev/null @@ -1,90 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -var isArray = require( '@stdlib/assert-is-array' ); -var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var absdiff = require( '@stdlib/math-base-utils-absolute-difference' ); -var FLOAT64_SQRT_EPS = require( '@stdlib/constants-float64-sqrt-eps' ); - - -// MAIN // - -/** -* Tests if a value is an array of probabilities that sum to one. -* -* @param {*} v - value to test -* @returns {boolean} boolean indicating if a value is a probability array -* -* @example -* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] ); -* // returns true -* -* @example -* var bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) ); -* // returns true -* -* @example -* var bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] ); -* // returns false -* -* @example -* var bool = isUnityProbabilityArray( [ 3.14, 0.0 ] ); -* // returns false -*/ -function isUnityProbabilityArray( v ) { - var sum; - var i; - if ( isArray( v ) ) { - sum = 0.0; - for ( i = 0; i < v.length; i++ ) { - if ( - !isNumber( v[ i ] ) || - v[ i ] > 1.0 || - v[ i ] < 0.0 - ) { - return false; - } - sum += v[ i ]; - } - return ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS ); - } - if ( isTypedArray( v ) ) { - sum = 0.0; - for ( i = 0; i < v.length; i++ ) { - if ( - v[ i ] > 1.0 || - v[ i ] < 0.0 - ) { - return false; - } - sum += v[ i ]; - } - return ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS ); - } - return false; -} - - -// EXPORTS // - -module.exports = isUnityProbabilityArray; diff --git a/package.json b/package.json index 2375604..9ba851e 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.2", "description": "Test if a value is an array of probabilities that sum to one.", "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" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,47 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-array": "^0.2.2", - "@stdlib/assert-is-number": "^0.2.2", - "@stdlib/assert-is-typed-array": "^0.2.2", - "@stdlib/constants-float64-sqrt-eps": "^0.2.2", - "@stdlib/math-base-utils-absolute-difference": "^0.3.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/array-float32": "^0.2.2", - "@stdlib/array-float64": "^0.2.2", - "@stdlib/array-int16": "^0.2.2", - "@stdlib/array-int32": "^0.2.2", - "@stdlib/array-int8": "^0.2.2", - "@stdlib/array-uint16": "^0.2.2", - "@stdlib/array-uint32": "^0.2.2", - "@stdlib/array-uint8": "^0.2.2", - "@stdlib/array-uint8c": "^0.2.2", - "@stdlib/assert-is-boolean": "^0.2.2", - "@stdlib/buffer-from-array": "^0.2.2", - "@stdlib/math-base-special-pow": "^0.3.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.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdassert", @@ -105,4 +41,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..2282772 --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index a0424fb..0000000 --- a/test/test.js +++ /dev/null @@ -1,106 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Int8Array = require( '@stdlib/array-int8' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Float64Array = require( '@stdlib/array-float64' ); -var array2buffer = require( '@stdlib/buffer-from-array' ); -var isUnityProbabilityArray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof isUnityProbabilityArray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns `true` if provided an array of probabilities that sum to one', function test( t ) { - var values; - var i; - - values = [ - new Int8Array( [ 0, 0, 1 ] ), - new Uint8Array( [ 1, 0, 0 ] ), - new Uint8ClampedArray( [ 0, 1 ] ), - new Int16Array( [ 0, 0, 1, 0 ] ), - new Uint16Array( [ 1 ] ), - new Int32Array( [ 1, 0, 0 ] ), - new Uint32Array( [ 0, 1, 0 ] ), - new Float32Array( [ 0.0, 0.5, 0.5 ] ), - new Float64Array( [ 0.25, 0.25, 0.5 ] ), - [ 0.5, 0.25, 0.25 ] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.strictEqual( isUnityProbabilityArray( values[i] ), true, 'returns true when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function allows a difference in sum within floating-point epsilon', function test( t ) { - var bool = isUnityProbabilityArray( [ 0.1, 0.2, 0.1, 0.1, 0.2, 0.2, 0.1 ] ); - t.strictEqual( bool, true, 'returns true' ); - t.end(); -}); - -tape( 'the function returns `false` if not provided an array of probabilities that sum to one', function test( t ) { - var values; - var i; - - values = [ - '10', - '01', - '0.5', - '5', - 5, - NaN, - null, - void 0, - true, - [], - [ 5, null ], - [ 5, '5' ], - [ 1.0, 3.14 ], - [ -1.0, 1.0, 1.0 ], - [ 0.25, 0.33, 0.5 ], - new Float64Array( [ 0.25, 0.33, 0.5 ] ), - new Float64Array( [ 0.25, 1.33, 0.5 ] ), - new Float64Array( [ 0.25, -0.33, 0.5 ] ), - {}, - function noop() {}, - array2buffer( [ 1, 1, 0 ] ) - ]; - - for ( i = 0; i < values.length; i++ ) { - t.strictEqual( isUnityProbabilityArray( values[i] ), false, 'returns false when provided '+values[i] ); - } - t.end(); -}); From db6b8ceec991bd1a0411b7f7b107952517733e76 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 7 Apr 2025 00:58:34 +0000 Subject: [PATCH 125/133] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 2385bbd..2375604 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,8 @@ "@stdlib/assert-is-number": "^0.2.2", "@stdlib/assert-is-typed-array": "^0.2.2", "@stdlib/constants-float64-sqrt-eps": "^0.2.2", - "@stdlib/math-base-utils-absolute-difference": "^0.3.2" + "@stdlib/math-base-utils-absolute-difference": "^0.3.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2" }, "devDependencies": { "@stdlib/array-float32": "^0.2.2", @@ -104,4 +105,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 0db56213fbe9ec3ff2eee3a38263a5269ca03e7c Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 7 Apr 2025 01:04:36 +0000 Subject: [PATCH 126/133] Remove files --- index.d.ts | 48 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4895 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index 63a123d..0000000 --- a/index.d.ts +++ /dev/null @@ -1,48 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/** -* Tests if a value is an array of probabilities that sum to one. -* -* @param v - value to test -* @returns boolean indicating if a value is a probability array -* -* @example -* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] ); -* // returns true -* -* @example -* var bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) ); -* // returns true -* -* @example -* var bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] ); -* // returns false -* -* @example -* var bool = isUnityProbabilityArray( [ 3.14, 0.0 ] ); -* // returns false -*/ -declare function isUnityProbabilityArray( v: any ): v is ArrayLike; - - -// EXPORTS // - -export = isUnityProbabilityArray; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 08d3bcb..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-typed-array@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array@v0.2.2-esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-number@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/math-base-utils-absolute-difference@v0.3.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/constants-float64-sqrt-eps@v0.2.2-esm/index.mjs";function n(n){var d,m;if(t(n)){for(d=0,m=0;m1||n[m]<0)return!1;d+=n[m]}return r(d,1)<=i}if(s(n)){for(d=0,m=0;m1||n[m]<0)return!1;d+=n[m]}return r(d,1)<=i}return!1}export{n as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 08904b0..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isTypedArray from '@stdlib/assert-is-typed-array';\nimport isArray from '@stdlib/assert-is-array';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport absdiff from '@stdlib/math-base-utils-absolute-difference';\nimport FLOAT64_SQRT_EPS from '@stdlib/constants-float64-sqrt-eps';\n\n\n// MAIN //\n\n/**\n* Tests if a value is an array of probabilities that sum to one.\n*\n* @param {*} v - value to test\n* @returns {boolean} boolean indicating if a value is a probability array\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] );\n* // returns true\n*\n* @example\n* var bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) );\n* // returns true\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] );\n* // returns false\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 3.14, 0.0 ] );\n* // returns false\n*/\nfunction isUnityProbabilityArray( v ) {\n\tvar sum;\n\tvar i;\n\tif ( isArray( v ) ) {\n\t\tsum = 0.0;\n\t\tfor ( i = 0; i < v.length; i++ ) {\n\t\t\tif (\n\t\t\t\t!isNumber( v[ i ] ) ||\n\t\t\t\tv[ i ] > 1.0 ||\n\t\t\t\tv[ i ] < 0.0\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tsum += v[ i ];\n\t\t}\n\t\treturn ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS );\n\t}\n\tif ( isTypedArray( v ) ) {\n\t\tsum = 0.0;\n\t\tfor ( i = 0; i < v.length; i++ ) {\n\t\t\tif (\n\t\t\t\tv[ i ] > 1.0 ||\n\t\t\t\tv[ i ] < 0.0\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tsum += v[ i ];\n\t\t}\n\t\treturn ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS );\n\t}\n\treturn false;\n}\n\n\n// EXPORTS //\n\nexport default isUnityProbabilityArray;\n"],"names":["isUnityProbabilityArray","v","sum","i","isArray","length","isNumber","absdiff","FLOAT64_SQRT_EPS","isTypedArray"],"mappings":";;ufAqDA,SAASA,EAAyBC,GACjC,IAAIC,EACAC,EACJ,GAAKC,EAASH,GAAM,CAEnB,IADAC,EAAM,EACAC,EAAI,EAAGA,EAAIF,EAAEI,OAAQF,IAAM,CAChC,IACEG,EAAUL,EAAGE,KACdF,EAAGE,GAAM,GACTF,EAAGE,GAAM,EAET,OAAO,EAERD,GAAOD,EAAGE,EACV,CACD,OAASI,EAASL,EAAK,IAASM,CAChC,CACD,GAAKC,EAAcR,GAAM,CAExB,IADAC,EAAM,EACAC,EAAI,EAAGA,EAAIF,EAAEI,OAAQF,IAAM,CAChC,GACCF,EAAGE,GAAM,GACTF,EAAGE,GAAM,EAET,OAAO,EAERD,GAAOD,EAAGE,EACV,CACD,OAASI,EAASL,EAAK,IAASM,CAChC,CACD,OAAO,CACR"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 2282772..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From a8bd79942be1849874109cd4d989687b7790e440 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 7 Apr 2025 01:04:53 +0000 Subject: [PATCH 127/133] 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 | 194 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 163 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 43 +- SECURITY.md | 5 - benchmark/benchmark.js | 103 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 29 - docs/types/test.ts | 34 - examples/index.js | 48 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 49 - lib/main.js | 90 - package.json | 70 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 106 - 44 files changed, 4867 insertions(+), 4108 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 delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/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 633cc06..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2025-04-07T00:53:27.707Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index fd83738..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/assert/is-unity-probability-array) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/contributing/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index e4f10fe..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index b5291db..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA - uses: styfle/cancel-workflow-action@85880fa0301c86cca9da44039ee3bb12d3bedbfa # v0.12.1 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index 5119885..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/assert/is-unity-probability-array) 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 3b386b0..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: '49 1 * * 1' - - # 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 + + ```
@@ -178,7 +169,7 @@ bool = isUnityProbabilityArray( null ); ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -245,9 +236,9 @@ Copyright © 2016-2025. The Stdlib [Authors][stdlib-authors]. -[@stdlib/assert/is-probability]: https://github.com/stdlib-js/assert-is-probability +[@stdlib/assert/is-probability]: https://github.com/stdlib-js/assert-is-probability/tree/esm -[@stdlib/assert/is-probability-array]: https://github.com/stdlib-js/assert-is-probability-array +[@stdlib/assert/is-probability-array]: https://github.com/stdlib-js/assert-is-probability-array/tree/esm diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 510a5ed..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,103 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var isUnityProbabilityArray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x; - var i; - - x = []; - for ( i = 0; i < len; i++ ) { - x.push( 1.0/len ); - } - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: we are testing the worst case scenario where a function must scan the entire array before finding a failing value. - x[ len-1 ] = i * 3.14; - bool = isUnityProbabilityArray( x ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( isBoolean( bool ) ) { - b.pass( 'benchmark finished' ); - } else { - b.fail( 'should return a boolean' ); - } - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':len='+len, f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index 5a6810d..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/assert/is-unity-probability-array" -%% click B href "https://github.com/stdlib-js/assert-is-unity-probability-array/tree/main" -%% click C href "https://github.com/stdlib-js/assert-is-unity-probability-array/tree/production" -%% click D href "https://github.com/stdlib-js/assert-is-unity-probability-array/tree/esm" -%% click E href "https://github.com/stdlib-js/assert-is-unity-probability-array/tree/deno" -%% click F href "https://github.com/stdlib-js/assert-is-unity-probability-array/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/assert/is-unity-probability-array -[production-url]: https://github.com/stdlib-js/assert-is-unity-probability-array/tree/production -[deno-url]: https://github.com/stdlib-js/assert-is-unity-probability-array/tree/deno -[deno-readme]: https://github.com/stdlib-js/assert-is-unity-probability-array/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/assert-is-unity-probability-array/tree/umd -[umd-readme]: https://github.com/stdlib-js/assert-is-unity-probability-array/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/assert-is-unity-probability-array/tree/esm -[esm-readme]: https://github.com/stdlib-js/assert-is-unity-probability-array/blob/esm/README.md \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index c77d01e..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import isUnityProbabilityArray from '../docs/types/index'; -export = isUnityProbabilityArray; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 70d7801..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var f=function(r,i){return function(){return i||r((i={exports:{}}).exports,i),i.exports}};var u=f(function(m,s){ -var n=require('@stdlib/assert-is-typed-array/dist'),l=require('@stdlib/assert-is-array/dist'),o=require('@stdlib/assert-is-number/dist').isPrimitive,a=require('@stdlib/math-base-utils-absolute-difference/dist'),t=require('@stdlib/constants-float64-sqrt-eps/dist');function q(r){var i,e;if(l(r)){for(i=0,e=0;e1||r[e]<0)return!1;i+=r[e]}return a(i,1)<=t}if(n(r)){for(i=0,e=0;e1||r[e]<0)return!1;i+=r[e]}return a(i,1)<=t}return!1}s.exports=q -});var y=u();module.exports=y; -/** @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 387d5ad..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) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isTypedArray = require( '@stdlib/assert-is-typed-array' );\nvar isArray = require( '@stdlib/assert-is-array' );\nvar isNumber = require( '@stdlib/assert-is-number' ).isPrimitive;\nvar absdiff = require( '@stdlib/math-base-utils-absolute-difference' );\nvar FLOAT64_SQRT_EPS = require( '@stdlib/constants-float64-sqrt-eps' );\n\n\n// MAIN //\n\n/**\n* Tests if a value is an array of probabilities that sum to one.\n*\n* @param {*} v - value to test\n* @returns {boolean} boolean indicating if a value is a probability array\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] );\n* // returns true\n*\n* @example\n* var bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) );\n* // returns true\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] );\n* // returns false\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 3.14, 0.0 ] );\n* // returns false\n*/\nfunction isUnityProbabilityArray( v ) {\n\tvar sum;\n\tvar i;\n\tif ( isArray( v ) ) {\n\t\tsum = 0.0;\n\t\tfor ( i = 0; i < v.length; i++ ) {\n\t\t\tif (\n\t\t\t\t!isNumber( v[ i ] ) ||\n\t\t\t\tv[ i ] > 1.0 ||\n\t\t\t\tv[ i ] < 0.0\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tsum += v[ i ];\n\t\t}\n\t\treturn ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS );\n\t}\n\tif ( isTypedArray( v ) ) {\n\t\tsum = 0.0;\n\t\tfor ( i = 0; i < v.length; i++ ) {\n\t\t\tif (\n\t\t\t\tv[ i ] > 1.0 ||\n\t\t\t\tv[ i ] < 0.0\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tsum += v[ i ];\n\t\t}\n\t\treturn ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS );\n\t}\n\treturn false;\n}\n\n\n// EXPORTS //\n\nmodule.exports = isUnityProbabilityArray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Test if a value is an array of probabilities that sum to one.\n*\n* @module @stdlib/assert-is-unity-probability-array\n*\n* @example\n* var isUnityProbabilityArray = require( '@stdlib/assert-is-unity-probability-array' );\n*\n* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] );\n* // returns true\n*\n* bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) );\n* // returns true\n*\n* bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] );\n* // returns false\n*\n* bool = isUnityProbabilityArray( [ 3.14, 0.0 ] );\n* // returns false\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,EAAe,QAAS,+BAAgC,EACxDC,EAAU,QAAS,yBAA0B,EAC7CC,EAAW,QAAS,0BAA2B,EAAE,YACjDC,EAAU,QAAS,6CAA8C,EACjEC,EAAmB,QAAS,oCAAqC,EA2BrE,SAASC,EAAyBC,EAAI,CACrC,IAAIC,EACAC,EACJ,GAAKP,EAASK,CAAE,EAAI,CAEnB,IADAC,EAAM,EACAC,EAAI,EAAGA,EAAIF,EAAE,OAAQE,IAAM,CAChC,GACC,CAACN,EAAUI,EAAGE,CAAE,CAAE,GAClBF,EAAGE,CAAE,EAAI,GACTF,EAAGE,CAAE,EAAI,EAET,MAAO,GAERD,GAAOD,EAAGE,CAAE,CACb,CACA,OAASL,EAASI,EAAK,CAAI,GAAKH,CACjC,CACA,GAAKJ,EAAcM,CAAE,EAAI,CAExB,IADAC,EAAM,EACAC,EAAI,EAAGA,EAAIF,EAAE,OAAQE,IAAM,CAChC,GACCF,EAAGE,CAAE,EAAI,GACTF,EAAGE,CAAE,EAAI,EAET,MAAO,GAERD,GAAOD,EAAGE,CAAE,CACb,CACA,OAASL,EAASI,EAAK,CAAI,GAAKH,CACjC,CACA,MAAO,EACR,CAKAL,EAAO,QAAUM,IC9CjB,IAAII,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isTypedArray", "isArray", "isNumber", "absdiff", "FLOAT64_SQRT_EPS", "isUnityProbabilityArray", "v", "sum", "i", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index a2414be..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,29 +0,0 @@ - -{{alias}}( value ) - Tests if a value is an array of probabilities that sum to one. - - Parameters - ---------- - value: any - Value to test. - - Returns - ------- - bool: boolean - Boolean indicating whether value is an array of probabilities that sum - to one. - - Examples - -------- - > var bool = {{alias}}( [ 0.25, 0.5, 0.25 ] ) - true - > bool = {{alias}}( new {{alias:@stdlib/array/uint8}}( [ 0, 1 ] ) ) - true - > bool = {{alias}}( [ 0.4, 0.4, 0.4 ] ) - false - > bool = {{alias}}( [ 3.14, 0.0 ] ) - false - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 6b41658..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,34 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import isUnityProbabilityArray = require( './index' ); - - -// TESTS // - -// The function returns a boolean... -{ - isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] ); // $ExpectType boolean - isUnityProbabilityArray( [ 2, 3 ] ); // $ExpectType boolean -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - isUnityProbabilityArray(); // $ExpectError - isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ], 123 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index b0b6bbc..0000000 --- a/examples/index.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var Uint8Array = require( '@stdlib/array-uint8' ); -var isUnityProbabilityArray = require( './../lib' ); - -var arr = [ 0.0, 1.0 ]; -console.log( isUnityProbabilityArray( arr ) ); -// => true - -arr = [ 0.5, 0.25, 0.25 ]; -console.log( isUnityProbabilityArray( arr ) ); -// => true - -arr = new Uint8Array( [ 0, 0, 1, 0 ] ); -console.log( isUnityProbabilityArray( arr ) ); -// => true - -arr = [ 0.4, 0.4, 0.4 ]; -console.log( isUnityProbabilityArray( arr ) ); -// => false - -arr = [ 3.14, -1.0 ]; -console.log( isUnityProbabilityArray( arr ) ); -// => false - -console.log( isUnityProbabilityArray( [] ) ); -// => false - -console.log( isUnityProbabilityArray( null ) ); -// => false diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..efe2531 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2025 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-typed-array@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array@v0.2.2-esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-number@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/math-base-utils-absolute-difference@v0.3.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/constants-float64-sqrt-eps@v0.2.2-esm/index.mjs";function n(n){var d,m;if(t(n)){for(d=0,m=0;m1||n[m]<0)return!1;d+=n[m]}return r(d,1)<=i}if(s(n)){for(d=0,m=0;m1||n[m]<0)return!1;d+=n[m]}return r(d,1)<=i}return!1}export{n as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..08904b0 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isTypedArray from '@stdlib/assert-is-typed-array';\nimport isArray from '@stdlib/assert-is-array';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport absdiff from '@stdlib/math-base-utils-absolute-difference';\nimport FLOAT64_SQRT_EPS from '@stdlib/constants-float64-sqrt-eps';\n\n\n// MAIN //\n\n/**\n* Tests if a value is an array of probabilities that sum to one.\n*\n* @param {*} v - value to test\n* @returns {boolean} boolean indicating if a value is a probability array\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] );\n* // returns true\n*\n* @example\n* var bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) );\n* // returns true\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] );\n* // returns false\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 3.14, 0.0 ] );\n* // returns false\n*/\nfunction isUnityProbabilityArray( v ) {\n\tvar sum;\n\tvar i;\n\tif ( isArray( v ) ) {\n\t\tsum = 0.0;\n\t\tfor ( i = 0; i < v.length; i++ ) {\n\t\t\tif (\n\t\t\t\t!isNumber( v[ i ] ) ||\n\t\t\t\tv[ i ] > 1.0 ||\n\t\t\t\tv[ i ] < 0.0\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tsum += v[ i ];\n\t\t}\n\t\treturn ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS );\n\t}\n\tif ( isTypedArray( v ) ) {\n\t\tsum = 0.0;\n\t\tfor ( i = 0; i < v.length; i++ ) {\n\t\t\tif (\n\t\t\t\tv[ i ] > 1.0 ||\n\t\t\t\tv[ i ] < 0.0\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tsum += v[ i ];\n\t\t}\n\t\treturn ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS );\n\t}\n\treturn false;\n}\n\n\n// EXPORTS //\n\nexport default isUnityProbabilityArray;\n"],"names":["isUnityProbabilityArray","v","sum","i","isArray","length","isNumber","absdiff","FLOAT64_SQRT_EPS","isTypedArray"],"mappings":";;ufAqDA,SAASA,EAAyBC,GACjC,IAAIC,EACAC,EACJ,GAAKC,EAASH,GAAM,CAEnB,IADAC,EAAM,EACAC,EAAI,EAAGA,EAAIF,EAAEI,OAAQF,IAAM,CAChC,IACEG,EAAUL,EAAGE,KACdF,EAAGE,GAAM,GACTF,EAAGE,GAAM,EAET,OAAO,EAERD,GAAOD,EAAGE,EACV,CACD,OAASI,EAASL,EAAK,IAASM,CAChC,CACD,GAAKC,EAAcR,GAAM,CAExB,IADAC,EAAM,EACAC,EAAI,EAAGA,EAAIF,EAAEI,OAAQF,IAAM,CAChC,GACCF,EAAGE,GAAM,GACTF,EAAGE,GAAM,EAET,OAAO,EAERD,GAAOD,EAAGE,EACV,CACD,OAASI,EAASL,EAAK,IAASM,CAChC,CACD,OAAO,CACR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 13a67d1..0000000 --- a/lib/index.js +++ /dev/null @@ -1,49 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Test if a value is an array of probabilities that sum to one. -* -* @module @stdlib/assert-is-unity-probability-array -* -* @example -* var isUnityProbabilityArray = require( '@stdlib/assert-is-unity-probability-array' ); -* -* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] ); -* // returns true -* -* bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) ); -* // returns true -* -* bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] ); -* // returns false -* -* bool = isUnityProbabilityArray( [ 3.14, 0.0 ] ); -* // returns false -*/ - -// 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 d0bda40..0000000 --- a/lib/main.js +++ /dev/null @@ -1,90 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -var isArray = require( '@stdlib/assert-is-array' ); -var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var absdiff = require( '@stdlib/math-base-utils-absolute-difference' ); -var FLOAT64_SQRT_EPS = require( '@stdlib/constants-float64-sqrt-eps' ); - - -// MAIN // - -/** -* Tests if a value is an array of probabilities that sum to one. -* -* @param {*} v - value to test -* @returns {boolean} boolean indicating if a value is a probability array -* -* @example -* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] ); -* // returns true -* -* @example -* var bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) ); -* // returns true -* -* @example -* var bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] ); -* // returns false -* -* @example -* var bool = isUnityProbabilityArray( [ 3.14, 0.0 ] ); -* // returns false -*/ -function isUnityProbabilityArray( v ) { - var sum; - var i; - if ( isArray( v ) ) { - sum = 0.0; - for ( i = 0; i < v.length; i++ ) { - if ( - !isNumber( v[ i ] ) || - v[ i ] > 1.0 || - v[ i ] < 0.0 - ) { - return false; - } - sum += v[ i ]; - } - return ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS ); - } - if ( isTypedArray( v ) ) { - sum = 0.0; - for ( i = 0; i < v.length; i++ ) { - if ( - v[ i ] > 1.0 || - v[ i ] < 0.0 - ) { - return false; - } - sum += v[ i ]; - } - return ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS ); - } - return false; -} - - -// EXPORTS // - -module.exports = isUnityProbabilityArray; diff --git a/package.json b/package.json index 2375604..9ba851e 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.2", "description": "Test if a value is an array of probabilities that sum to one.", "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" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,47 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-array": "^0.2.2", - "@stdlib/assert-is-number": "^0.2.2", - "@stdlib/assert-is-typed-array": "^0.2.2", - "@stdlib/constants-float64-sqrt-eps": "^0.2.2", - "@stdlib/math-base-utils-absolute-difference": "^0.3.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/array-float32": "^0.2.2", - "@stdlib/array-float64": "^0.2.2", - "@stdlib/array-int16": "^0.2.2", - "@stdlib/array-int32": "^0.2.2", - "@stdlib/array-int8": "^0.2.2", - "@stdlib/array-uint16": "^0.2.2", - "@stdlib/array-uint32": "^0.2.2", - "@stdlib/array-uint8": "^0.2.2", - "@stdlib/array-uint8c": "^0.2.2", - "@stdlib/assert-is-boolean": "^0.2.2", - "@stdlib/buffer-from-array": "^0.2.2", - "@stdlib/math-base-special-pow": "^0.3.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.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdassert", @@ -105,4 +41,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..2282772 --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index a0424fb..0000000 --- a/test/test.js +++ /dev/null @@ -1,106 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Int8Array = require( '@stdlib/array-int8' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Float64Array = require( '@stdlib/array-float64' ); -var array2buffer = require( '@stdlib/buffer-from-array' ); -var isUnityProbabilityArray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof isUnityProbabilityArray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns `true` if provided an array of probabilities that sum to one', function test( t ) { - var values; - var i; - - values = [ - new Int8Array( [ 0, 0, 1 ] ), - new Uint8Array( [ 1, 0, 0 ] ), - new Uint8ClampedArray( [ 0, 1 ] ), - new Int16Array( [ 0, 0, 1, 0 ] ), - new Uint16Array( [ 1 ] ), - new Int32Array( [ 1, 0, 0 ] ), - new Uint32Array( [ 0, 1, 0 ] ), - new Float32Array( [ 0.0, 0.5, 0.5 ] ), - new Float64Array( [ 0.25, 0.25, 0.5 ] ), - [ 0.5, 0.25, 0.25 ] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.strictEqual( isUnityProbabilityArray( values[i] ), true, 'returns true when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function allows a difference in sum within floating-point epsilon', function test( t ) { - var bool = isUnityProbabilityArray( [ 0.1, 0.2, 0.1, 0.1, 0.2, 0.2, 0.1 ] ); - t.strictEqual( bool, true, 'returns true' ); - t.end(); -}); - -tape( 'the function returns `false` if not provided an array of probabilities that sum to one', function test( t ) { - var values; - var i; - - values = [ - '10', - '01', - '0.5', - '5', - 5, - NaN, - null, - void 0, - true, - [], - [ 5, null ], - [ 5, '5' ], - [ 1.0, 3.14 ], - [ -1.0, 1.0, 1.0 ], - [ 0.25, 0.33, 0.5 ], - new Float64Array( [ 0.25, 0.33, 0.5 ] ), - new Float64Array( [ 0.25, 1.33, 0.5 ] ), - new Float64Array( [ 0.25, -0.33, 0.5 ] ), - {}, - function noop() {}, - array2buffer( [ 1, 1, 0 ] ) - ]; - - for ( i = 0; i < values.length; i++ ) { - t.strictEqual( isUnityProbabilityArray( values[i] ), false, 'returns false when provided '+values[i] ); - } - t.end(); -}); From 199039d622b76908a466e63c99b5b14a4f18b5aa Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 26 May 2025 01:29:47 +0000 Subject: [PATCH 128/133] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 2385bbd..2375604 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,8 @@ "@stdlib/assert-is-number": "^0.2.2", "@stdlib/assert-is-typed-array": "^0.2.2", "@stdlib/constants-float64-sqrt-eps": "^0.2.2", - "@stdlib/math-base-utils-absolute-difference": "^0.3.2" + "@stdlib/math-base-utils-absolute-difference": "^0.3.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2" }, "devDependencies": { "@stdlib/array-float32": "^0.2.2", @@ -104,4 +105,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 7118dd726ca13104d32b525544c97228a3224fa2 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 26 May 2025 01:34:07 +0000 Subject: [PATCH 129/133] Remove files --- index.d.ts | 48 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4895 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index 63a123d..0000000 --- a/index.d.ts +++ /dev/null @@ -1,48 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/** -* Tests if a value is an array of probabilities that sum to one. -* -* @param v - value to test -* @returns boolean indicating if a value is a probability array -* -* @example -* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] ); -* // returns true -* -* @example -* var bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) ); -* // returns true -* -* @example -* var bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] ); -* // returns false -* -* @example -* var bool = isUnityProbabilityArray( [ 3.14, 0.0 ] ); -* // returns false -*/ -declare function isUnityProbabilityArray( v: any ): v is ArrayLike; - - -// EXPORTS // - -export = isUnityProbabilityArray; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index efe2531..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2025 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-typed-array@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array@v0.2.2-esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-number@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/math-base-utils-absolute-difference@v0.3.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/constants-float64-sqrt-eps@v0.2.2-esm/index.mjs";function n(n){var d,m;if(t(n)){for(d=0,m=0;m1||n[m]<0)return!1;d+=n[m]}return r(d,1)<=i}if(s(n)){for(d=0,m=0;m1||n[m]<0)return!1;d+=n[m]}return r(d,1)<=i}return!1}export{n as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 08904b0..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isTypedArray from '@stdlib/assert-is-typed-array';\nimport isArray from '@stdlib/assert-is-array';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport absdiff from '@stdlib/math-base-utils-absolute-difference';\nimport FLOAT64_SQRT_EPS from '@stdlib/constants-float64-sqrt-eps';\n\n\n// MAIN //\n\n/**\n* Tests if a value is an array of probabilities that sum to one.\n*\n* @param {*} v - value to test\n* @returns {boolean} boolean indicating if a value is a probability array\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] );\n* // returns true\n*\n* @example\n* var bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) );\n* // returns true\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] );\n* // returns false\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 3.14, 0.0 ] );\n* // returns false\n*/\nfunction isUnityProbabilityArray( v ) {\n\tvar sum;\n\tvar i;\n\tif ( isArray( v ) ) {\n\t\tsum = 0.0;\n\t\tfor ( i = 0; i < v.length; i++ ) {\n\t\t\tif (\n\t\t\t\t!isNumber( v[ i ] ) ||\n\t\t\t\tv[ i ] > 1.0 ||\n\t\t\t\tv[ i ] < 0.0\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tsum += v[ i ];\n\t\t}\n\t\treturn ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS );\n\t}\n\tif ( isTypedArray( v ) ) {\n\t\tsum = 0.0;\n\t\tfor ( i = 0; i < v.length; i++ ) {\n\t\t\tif (\n\t\t\t\tv[ i ] > 1.0 ||\n\t\t\t\tv[ i ] < 0.0\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tsum += v[ i ];\n\t\t}\n\t\treturn ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS );\n\t}\n\treturn false;\n}\n\n\n// EXPORTS //\n\nexport default isUnityProbabilityArray;\n"],"names":["isUnityProbabilityArray","v","sum","i","isArray","length","isNumber","absdiff","FLOAT64_SQRT_EPS","isTypedArray"],"mappings":";;ufAqDA,SAASA,EAAyBC,GACjC,IAAIC,EACAC,EACJ,GAAKC,EAASH,GAAM,CAEnB,IADAC,EAAM,EACAC,EAAI,EAAGA,EAAIF,EAAEI,OAAQF,IAAM,CAChC,IACEG,EAAUL,EAAGE,KACdF,EAAGE,GAAM,GACTF,EAAGE,GAAM,EAET,OAAO,EAERD,GAAOD,EAAGE,EACV,CACD,OAASI,EAASL,EAAK,IAASM,CAChC,CACD,GAAKC,EAAcR,GAAM,CAExB,IADAC,EAAM,EACAC,EAAI,EAAGA,EAAIF,EAAEI,OAAQF,IAAM,CAChC,GACCF,EAAGE,GAAM,GACTF,EAAGE,GAAM,EAET,OAAO,EAERD,GAAOD,EAAGE,EACV,CACD,OAASI,EAASL,EAAK,IAASM,CAChC,CACD,OAAO,CACR"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 2282772..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 7813e3d79796b2962d38e7085f970496f47dbb25 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 26 May 2025 01:34:23 +0000 Subject: [PATCH 130/133] 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 | 194 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 163 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 43 +- SECURITY.md | 5 - benchmark/benchmark.js | 103 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 29 - docs/types/test.ts | 34 - examples/index.js | 48 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 49 - lib/main.js | 90 - package.json | 70 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 106 - 44 files changed, 4867 insertions(+), 4108 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 delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/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 dffbd7d..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2025-05-26T01:21:21.828Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index fd83738..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/assert/is-unity-probability-array) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/contributing/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index e4f10fe..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index b5291db..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA - uses: styfle/cancel-workflow-action@85880fa0301c86cca9da44039ee3bb12d3bedbfa # v0.12.1 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index 5119885..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/assert/is-unity-probability-array) 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 3b386b0..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: '49 1 * * 1' - - # 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 + + ```
@@ -178,7 +169,7 @@ bool = isUnityProbabilityArray( null ); ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -245,9 +236,9 @@ Copyright © 2016-2025. The Stdlib [Authors][stdlib-authors]. -[@stdlib/assert/is-probability]: https://github.com/stdlib-js/assert-is-probability +[@stdlib/assert/is-probability]: https://github.com/stdlib-js/assert-is-probability/tree/esm -[@stdlib/assert/is-probability-array]: https://github.com/stdlib-js/assert-is-probability-array +[@stdlib/assert/is-probability-array]: https://github.com/stdlib-js/assert-is-probability-array/tree/esm diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 510a5ed..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,103 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var isUnityProbabilityArray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x; - var i; - - x = []; - for ( i = 0; i < len; i++ ) { - x.push( 1.0/len ); - } - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: we are testing the worst case scenario where a function must scan the entire array before finding a failing value. - x[ len-1 ] = i * 3.14; - bool = isUnityProbabilityArray( x ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( isBoolean( bool ) ) { - b.pass( 'benchmark finished' ); - } else { - b.fail( 'should return a boolean' ); - } - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':len='+len, f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index 5a6810d..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/assert/is-unity-probability-array" -%% click B href "https://github.com/stdlib-js/assert-is-unity-probability-array/tree/main" -%% click C href "https://github.com/stdlib-js/assert-is-unity-probability-array/tree/production" -%% click D href "https://github.com/stdlib-js/assert-is-unity-probability-array/tree/esm" -%% click E href "https://github.com/stdlib-js/assert-is-unity-probability-array/tree/deno" -%% click F href "https://github.com/stdlib-js/assert-is-unity-probability-array/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/assert/is-unity-probability-array -[production-url]: https://github.com/stdlib-js/assert-is-unity-probability-array/tree/production -[deno-url]: https://github.com/stdlib-js/assert-is-unity-probability-array/tree/deno -[deno-readme]: https://github.com/stdlib-js/assert-is-unity-probability-array/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/assert-is-unity-probability-array/tree/umd -[umd-readme]: https://github.com/stdlib-js/assert-is-unity-probability-array/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/assert-is-unity-probability-array/tree/esm -[esm-readme]: https://github.com/stdlib-js/assert-is-unity-probability-array/blob/esm/README.md \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index c77d01e..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import isUnityProbabilityArray from '../docs/types/index'; -export = isUnityProbabilityArray; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 70d7801..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var f=function(r,i){return function(){return i||r((i={exports:{}}).exports,i),i.exports}};var u=f(function(m,s){ -var n=require('@stdlib/assert-is-typed-array/dist'),l=require('@stdlib/assert-is-array/dist'),o=require('@stdlib/assert-is-number/dist').isPrimitive,a=require('@stdlib/math-base-utils-absolute-difference/dist'),t=require('@stdlib/constants-float64-sqrt-eps/dist');function q(r){var i,e;if(l(r)){for(i=0,e=0;e1||r[e]<0)return!1;i+=r[e]}return a(i,1)<=t}if(n(r)){for(i=0,e=0;e1||r[e]<0)return!1;i+=r[e]}return a(i,1)<=t}return!1}s.exports=q -});var y=u();module.exports=y; -/** @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 387d5ad..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) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isTypedArray = require( '@stdlib/assert-is-typed-array' );\nvar isArray = require( '@stdlib/assert-is-array' );\nvar isNumber = require( '@stdlib/assert-is-number' ).isPrimitive;\nvar absdiff = require( '@stdlib/math-base-utils-absolute-difference' );\nvar FLOAT64_SQRT_EPS = require( '@stdlib/constants-float64-sqrt-eps' );\n\n\n// MAIN //\n\n/**\n* Tests if a value is an array of probabilities that sum to one.\n*\n* @param {*} v - value to test\n* @returns {boolean} boolean indicating if a value is a probability array\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] );\n* // returns true\n*\n* @example\n* var bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) );\n* // returns true\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] );\n* // returns false\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 3.14, 0.0 ] );\n* // returns false\n*/\nfunction isUnityProbabilityArray( v ) {\n\tvar sum;\n\tvar i;\n\tif ( isArray( v ) ) {\n\t\tsum = 0.0;\n\t\tfor ( i = 0; i < v.length; i++ ) {\n\t\t\tif (\n\t\t\t\t!isNumber( v[ i ] ) ||\n\t\t\t\tv[ i ] > 1.0 ||\n\t\t\t\tv[ i ] < 0.0\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tsum += v[ i ];\n\t\t}\n\t\treturn ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS );\n\t}\n\tif ( isTypedArray( v ) ) {\n\t\tsum = 0.0;\n\t\tfor ( i = 0; i < v.length; i++ ) {\n\t\t\tif (\n\t\t\t\tv[ i ] > 1.0 ||\n\t\t\t\tv[ i ] < 0.0\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tsum += v[ i ];\n\t\t}\n\t\treturn ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS );\n\t}\n\treturn false;\n}\n\n\n// EXPORTS //\n\nmodule.exports = isUnityProbabilityArray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Test if a value is an array of probabilities that sum to one.\n*\n* @module @stdlib/assert-is-unity-probability-array\n*\n* @example\n* var isUnityProbabilityArray = require( '@stdlib/assert-is-unity-probability-array' );\n*\n* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] );\n* // returns true\n*\n* bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) );\n* // returns true\n*\n* bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] );\n* // returns false\n*\n* bool = isUnityProbabilityArray( [ 3.14, 0.0 ] );\n* // returns false\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,EAAe,QAAS,+BAAgC,EACxDC,EAAU,QAAS,yBAA0B,EAC7CC,EAAW,QAAS,0BAA2B,EAAE,YACjDC,EAAU,QAAS,6CAA8C,EACjEC,EAAmB,QAAS,oCAAqC,EA2BrE,SAASC,EAAyBC,EAAI,CACrC,IAAIC,EACAC,EACJ,GAAKP,EAASK,CAAE,EAAI,CAEnB,IADAC,EAAM,EACAC,EAAI,EAAGA,EAAIF,EAAE,OAAQE,IAAM,CAChC,GACC,CAACN,EAAUI,EAAGE,CAAE,CAAE,GAClBF,EAAGE,CAAE,EAAI,GACTF,EAAGE,CAAE,EAAI,EAET,MAAO,GAERD,GAAOD,EAAGE,CAAE,CACb,CACA,OAASL,EAASI,EAAK,CAAI,GAAKH,CACjC,CACA,GAAKJ,EAAcM,CAAE,EAAI,CAExB,IADAC,EAAM,EACAC,EAAI,EAAGA,EAAIF,EAAE,OAAQE,IAAM,CAChC,GACCF,EAAGE,CAAE,EAAI,GACTF,EAAGE,CAAE,EAAI,EAET,MAAO,GAERD,GAAOD,EAAGE,CAAE,CACb,CACA,OAASL,EAASI,EAAK,CAAI,GAAKH,CACjC,CACA,MAAO,EACR,CAKAL,EAAO,QAAUM,IC9CjB,IAAII,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isTypedArray", "isArray", "isNumber", "absdiff", "FLOAT64_SQRT_EPS", "isUnityProbabilityArray", "v", "sum", "i", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index a2414be..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,29 +0,0 @@ - -{{alias}}( value ) - Tests if a value is an array of probabilities that sum to one. - - Parameters - ---------- - value: any - Value to test. - - Returns - ------- - bool: boolean - Boolean indicating whether value is an array of probabilities that sum - to one. - - Examples - -------- - > var bool = {{alias}}( [ 0.25, 0.5, 0.25 ] ) - true - > bool = {{alias}}( new {{alias:@stdlib/array/uint8}}( [ 0, 1 ] ) ) - true - > bool = {{alias}}( [ 0.4, 0.4, 0.4 ] ) - false - > bool = {{alias}}( [ 3.14, 0.0 ] ) - false - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 6b41658..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,34 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import isUnityProbabilityArray = require( './index' ); - - -// TESTS // - -// The function returns a boolean... -{ - isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] ); // $ExpectType boolean - isUnityProbabilityArray( [ 2, 3 ] ); // $ExpectType boolean -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - isUnityProbabilityArray(); // $ExpectError - isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ], 123 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index b0b6bbc..0000000 --- a/examples/index.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var Uint8Array = require( '@stdlib/array-uint8' ); -var isUnityProbabilityArray = require( './../lib' ); - -var arr = [ 0.0, 1.0 ]; -console.log( isUnityProbabilityArray( arr ) ); -// => true - -arr = [ 0.5, 0.25, 0.25 ]; -console.log( isUnityProbabilityArray( arr ) ); -// => true - -arr = new Uint8Array( [ 0, 0, 1, 0 ] ); -console.log( isUnityProbabilityArray( arr ) ); -// => true - -arr = [ 0.4, 0.4, 0.4 ]; -console.log( isUnityProbabilityArray( arr ) ); -// => false - -arr = [ 3.14, -1.0 ]; -console.log( isUnityProbabilityArray( arr ) ); -// => false - -console.log( isUnityProbabilityArray( [] ) ); -// => false - -console.log( isUnityProbabilityArray( null ) ); -// => false diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..efe2531 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2025 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-typed-array@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array@v0.2.2-esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-number@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/math-base-utils-absolute-difference@v0.3.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/constants-float64-sqrt-eps@v0.2.2-esm/index.mjs";function n(n){var d,m;if(t(n)){for(d=0,m=0;m1||n[m]<0)return!1;d+=n[m]}return r(d,1)<=i}if(s(n)){for(d=0,m=0;m1||n[m]<0)return!1;d+=n[m]}return r(d,1)<=i}return!1}export{n as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..08904b0 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isTypedArray from '@stdlib/assert-is-typed-array';\nimport isArray from '@stdlib/assert-is-array';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport absdiff from '@stdlib/math-base-utils-absolute-difference';\nimport FLOAT64_SQRT_EPS from '@stdlib/constants-float64-sqrt-eps';\n\n\n// MAIN //\n\n/**\n* Tests if a value is an array of probabilities that sum to one.\n*\n* @param {*} v - value to test\n* @returns {boolean} boolean indicating if a value is a probability array\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] );\n* // returns true\n*\n* @example\n* var bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) );\n* // returns true\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] );\n* // returns false\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 3.14, 0.0 ] );\n* // returns false\n*/\nfunction isUnityProbabilityArray( v ) {\n\tvar sum;\n\tvar i;\n\tif ( isArray( v ) ) {\n\t\tsum = 0.0;\n\t\tfor ( i = 0; i < v.length; i++ ) {\n\t\t\tif (\n\t\t\t\t!isNumber( v[ i ] ) ||\n\t\t\t\tv[ i ] > 1.0 ||\n\t\t\t\tv[ i ] < 0.0\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tsum += v[ i ];\n\t\t}\n\t\treturn ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS );\n\t}\n\tif ( isTypedArray( v ) ) {\n\t\tsum = 0.0;\n\t\tfor ( i = 0; i < v.length; i++ ) {\n\t\t\tif (\n\t\t\t\tv[ i ] > 1.0 ||\n\t\t\t\tv[ i ] < 0.0\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tsum += v[ i ];\n\t\t}\n\t\treturn ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS );\n\t}\n\treturn false;\n}\n\n\n// EXPORTS //\n\nexport default isUnityProbabilityArray;\n"],"names":["isUnityProbabilityArray","v","sum","i","isArray","length","isNumber","absdiff","FLOAT64_SQRT_EPS","isTypedArray"],"mappings":";;ufAqDA,SAASA,EAAyBC,GACjC,IAAIC,EACAC,EACJ,GAAKC,EAASH,GAAM,CAEnB,IADAC,EAAM,EACAC,EAAI,EAAGA,EAAIF,EAAEI,OAAQF,IAAM,CAChC,IACEG,EAAUL,EAAGE,KACdF,EAAGE,GAAM,GACTF,EAAGE,GAAM,EAET,OAAO,EAERD,GAAOD,EAAGE,EACV,CACD,OAASI,EAASL,EAAK,IAASM,CAChC,CACD,GAAKC,EAAcR,GAAM,CAExB,IADAC,EAAM,EACAC,EAAI,EAAGA,EAAIF,EAAEI,OAAQF,IAAM,CAChC,GACCF,EAAGE,GAAM,GACTF,EAAGE,GAAM,EAET,OAAO,EAERD,GAAOD,EAAGE,EACV,CACD,OAASI,EAASL,EAAK,IAASM,CAChC,CACD,OAAO,CACR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 13a67d1..0000000 --- a/lib/index.js +++ /dev/null @@ -1,49 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Test if a value is an array of probabilities that sum to one. -* -* @module @stdlib/assert-is-unity-probability-array -* -* @example -* var isUnityProbabilityArray = require( '@stdlib/assert-is-unity-probability-array' ); -* -* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] ); -* // returns true -* -* bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) ); -* // returns true -* -* bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] ); -* // returns false -* -* bool = isUnityProbabilityArray( [ 3.14, 0.0 ] ); -* // returns false -*/ - -// 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 d0bda40..0000000 --- a/lib/main.js +++ /dev/null @@ -1,90 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -var isArray = require( '@stdlib/assert-is-array' ); -var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var absdiff = require( '@stdlib/math-base-utils-absolute-difference' ); -var FLOAT64_SQRT_EPS = require( '@stdlib/constants-float64-sqrt-eps' ); - - -// MAIN // - -/** -* Tests if a value is an array of probabilities that sum to one. -* -* @param {*} v - value to test -* @returns {boolean} boolean indicating if a value is a probability array -* -* @example -* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] ); -* // returns true -* -* @example -* var bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) ); -* // returns true -* -* @example -* var bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] ); -* // returns false -* -* @example -* var bool = isUnityProbabilityArray( [ 3.14, 0.0 ] ); -* // returns false -*/ -function isUnityProbabilityArray( v ) { - var sum; - var i; - if ( isArray( v ) ) { - sum = 0.0; - for ( i = 0; i < v.length; i++ ) { - if ( - !isNumber( v[ i ] ) || - v[ i ] > 1.0 || - v[ i ] < 0.0 - ) { - return false; - } - sum += v[ i ]; - } - return ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS ); - } - if ( isTypedArray( v ) ) { - sum = 0.0; - for ( i = 0; i < v.length; i++ ) { - if ( - v[ i ] > 1.0 || - v[ i ] < 0.0 - ) { - return false; - } - sum += v[ i ]; - } - return ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS ); - } - return false; -} - - -// EXPORTS // - -module.exports = isUnityProbabilityArray; diff --git a/package.json b/package.json index 2375604..9ba851e 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.2", "description": "Test if a value is an array of probabilities that sum to one.", "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" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,47 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-array": "^0.2.2", - "@stdlib/assert-is-number": "^0.2.2", - "@stdlib/assert-is-typed-array": "^0.2.2", - "@stdlib/constants-float64-sqrt-eps": "^0.2.2", - "@stdlib/math-base-utils-absolute-difference": "^0.3.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/array-float32": "^0.2.2", - "@stdlib/array-float64": "^0.2.2", - "@stdlib/array-int16": "^0.2.2", - "@stdlib/array-int32": "^0.2.2", - "@stdlib/array-int8": "^0.2.2", - "@stdlib/array-uint16": "^0.2.2", - "@stdlib/array-uint32": "^0.2.2", - "@stdlib/array-uint8": "^0.2.2", - "@stdlib/array-uint8c": "^0.2.2", - "@stdlib/assert-is-boolean": "^0.2.2", - "@stdlib/buffer-from-array": "^0.2.2", - "@stdlib/math-base-special-pow": "^0.3.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.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdassert", @@ -105,4 +41,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..2282772 --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index a0424fb..0000000 --- a/test/test.js +++ /dev/null @@ -1,106 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Int8Array = require( '@stdlib/array-int8' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Float64Array = require( '@stdlib/array-float64' ); -var array2buffer = require( '@stdlib/buffer-from-array' ); -var isUnityProbabilityArray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof isUnityProbabilityArray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns `true` if provided an array of probabilities that sum to one', function test( t ) { - var values; - var i; - - values = [ - new Int8Array( [ 0, 0, 1 ] ), - new Uint8Array( [ 1, 0, 0 ] ), - new Uint8ClampedArray( [ 0, 1 ] ), - new Int16Array( [ 0, 0, 1, 0 ] ), - new Uint16Array( [ 1 ] ), - new Int32Array( [ 1, 0, 0 ] ), - new Uint32Array( [ 0, 1, 0 ] ), - new Float32Array( [ 0.0, 0.5, 0.5 ] ), - new Float64Array( [ 0.25, 0.25, 0.5 ] ), - [ 0.5, 0.25, 0.25 ] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.strictEqual( isUnityProbabilityArray( values[i] ), true, 'returns true when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function allows a difference in sum within floating-point epsilon', function test( t ) { - var bool = isUnityProbabilityArray( [ 0.1, 0.2, 0.1, 0.1, 0.2, 0.2, 0.1 ] ); - t.strictEqual( bool, true, 'returns true' ); - t.end(); -}); - -tape( 'the function returns `false` if not provided an array of probabilities that sum to one', function test( t ) { - var values; - var i; - - values = [ - '10', - '01', - '0.5', - '5', - 5, - NaN, - null, - void 0, - true, - [], - [ 5, null ], - [ 5, '5' ], - [ 1.0, 3.14 ], - [ -1.0, 1.0, 1.0 ], - [ 0.25, 0.33, 0.5 ], - new Float64Array( [ 0.25, 0.33, 0.5 ] ), - new Float64Array( [ 0.25, 1.33, 0.5 ] ), - new Float64Array( [ 0.25, -0.33, 0.5 ] ), - {}, - function noop() {}, - array2buffer( [ 1, 1, 0 ] ) - ]; - - for ( i = 0; i < values.length; i++ ) { - t.strictEqual( isUnityProbabilityArray( values[i] ), false, 'returns false when provided '+values[i] ); - } - t.end(); -}); From d9a168e6be9a2989b125dd647f2fb11e71b8f153 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 30 Jun 2025 01:16:35 +0000 Subject: [PATCH 131/133] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 2385bbd..2375604 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,8 @@ "@stdlib/assert-is-number": "^0.2.2", "@stdlib/assert-is-typed-array": "^0.2.2", "@stdlib/constants-float64-sqrt-eps": "^0.2.2", - "@stdlib/math-base-utils-absolute-difference": "^0.3.2" + "@stdlib/math-base-utils-absolute-difference": "^0.3.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2" }, "devDependencies": { "@stdlib/array-float32": "^0.2.2", @@ -104,4 +105,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 8b6e99e60b33e43340aa0811342829a73c066419 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 30 Jun 2025 01:43:29 +0000 Subject: [PATCH 132/133] Remove files --- index.d.ts | 48 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4895 deletions(-) delete mode 100644 index.d.ts delete mode 100644 index.mjs delete mode 100644 index.mjs.map delete mode 100644 stats.html diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index 63a123d..0000000 --- a/index.d.ts +++ /dev/null @@ -1,48 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/** -* Tests if a value is an array of probabilities that sum to one. -* -* @param v - value to test -* @returns boolean indicating if a value is a probability array -* -* @example -* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] ); -* // returns true -* -* @example -* var bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) ); -* // returns true -* -* @example -* var bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] ); -* // returns false -* -* @example -* var bool = isUnityProbabilityArray( [ 3.14, 0.0 ] ); -* // returns false -*/ -declare function isUnityProbabilityArray( v: any ): v is ArrayLike; - - -// EXPORTS // - -export = isUnityProbabilityArray; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index efe2531..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2025 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-typed-array@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array@v0.2.2-esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-number@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/math-base-utils-absolute-difference@v0.3.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/constants-float64-sqrt-eps@v0.2.2-esm/index.mjs";function n(n){var d,m;if(t(n)){for(d=0,m=0;m1||n[m]<0)return!1;d+=n[m]}return r(d,1)<=i}if(s(n)){for(d=0,m=0;m1||n[m]<0)return!1;d+=n[m]}return r(d,1)<=i}return!1}export{n as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 08904b0..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isTypedArray from '@stdlib/assert-is-typed-array';\nimport isArray from '@stdlib/assert-is-array';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport absdiff from '@stdlib/math-base-utils-absolute-difference';\nimport FLOAT64_SQRT_EPS from '@stdlib/constants-float64-sqrt-eps';\n\n\n// MAIN //\n\n/**\n* Tests if a value is an array of probabilities that sum to one.\n*\n* @param {*} v - value to test\n* @returns {boolean} boolean indicating if a value is a probability array\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] );\n* // returns true\n*\n* @example\n* var bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) );\n* // returns true\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] );\n* // returns false\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 3.14, 0.0 ] );\n* // returns false\n*/\nfunction isUnityProbabilityArray( v ) {\n\tvar sum;\n\tvar i;\n\tif ( isArray( v ) ) {\n\t\tsum = 0.0;\n\t\tfor ( i = 0; i < v.length; i++ ) {\n\t\t\tif (\n\t\t\t\t!isNumber( v[ i ] ) ||\n\t\t\t\tv[ i ] > 1.0 ||\n\t\t\t\tv[ i ] < 0.0\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tsum += v[ i ];\n\t\t}\n\t\treturn ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS );\n\t}\n\tif ( isTypedArray( v ) ) {\n\t\tsum = 0.0;\n\t\tfor ( i = 0; i < v.length; i++ ) {\n\t\t\tif (\n\t\t\t\tv[ i ] > 1.0 ||\n\t\t\t\tv[ i ] < 0.0\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tsum += v[ i ];\n\t\t}\n\t\treturn ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS );\n\t}\n\treturn false;\n}\n\n\n// EXPORTS //\n\nexport default isUnityProbabilityArray;\n"],"names":["isUnityProbabilityArray","v","sum","i","isArray","length","isNumber","absdiff","FLOAT64_SQRT_EPS","isTypedArray"],"mappings":";;ufAqDA,SAASA,EAAyBC,GACjC,IAAIC,EACAC,EACJ,GAAKC,EAASH,GAAM,CAEnB,IADAC,EAAM,EACAC,EAAI,EAAGA,EAAIF,EAAEI,OAAQF,IAAM,CAChC,IACEG,EAAUL,EAAGE,KACdF,EAAGE,GAAM,GACTF,EAAGE,GAAM,EAET,OAAO,EAERD,GAAOD,EAAGE,EACV,CACD,OAASI,EAASL,EAAK,IAASM,CAChC,CACD,GAAKC,EAAcR,GAAM,CAExB,IADAC,EAAM,EACAC,EAAI,EAAGA,EAAIF,EAAEI,OAAQF,IAAM,CAChC,GACCF,EAAGE,GAAM,GACTF,EAAGE,GAAM,EAET,OAAO,EAERD,GAAOD,EAAGE,EACV,CACD,OAASI,EAASL,EAAK,IAASM,CAChC,CACD,OAAO,CACR"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 2282772..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 0e230aa20e1489feeb411ac314c97d9ad653166a Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 30 Jun 2025 01:43:50 +0000 Subject: [PATCH 133/133] 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 | 194 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 163 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 43 +- SECURITY.md | 5 - benchmark/benchmark.js | 103 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 29 - docs/types/test.ts | 34 - examples/index.js | 48 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 49 - lib/main.js | 90 - package.json | 70 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 106 - 44 files changed, 4867 insertions(+), 4108 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 delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/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 d3c4728..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2025-06-30T01:08:56.527Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index fd83738..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/assert/is-unity-probability-array) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/contributing/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index e4f10fe..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index b5291db..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA - uses: styfle/cancel-workflow-action@85880fa0301c86cca9da44039ee3bb12d3bedbfa # v0.12.1 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index 5119885..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/assert/is-unity-probability-array) 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 3b386b0..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: '49 1 * * 1' - - # 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 + + ```
@@ -178,7 +169,7 @@ bool = isUnityProbabilityArray( null ); ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -245,9 +236,9 @@ Copyright © 2016-2025. The Stdlib [Authors][stdlib-authors]. -[@stdlib/assert/is-probability]: https://github.com/stdlib-js/assert-is-probability +[@stdlib/assert/is-probability]: https://github.com/stdlib-js/assert-is-probability/tree/esm -[@stdlib/assert/is-probability-array]: https://github.com/stdlib-js/assert-is-probability-array +[@stdlib/assert/is-probability-array]: https://github.com/stdlib-js/assert-is-probability-array/tree/esm diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 510a5ed..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,103 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive; -var pkg = require( './../package.json' ).name; -var isUnityProbabilityArray = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} len - array length -* @returns {Function} benchmark function -*/ -function createBenchmark( len ) { - var x; - var i; - - x = []; - for ( i = 0; i < len; i++ ) { - x.push( 1.0/len ); - } - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var bool; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - // Note: we are testing the worst case scenario where a function must scan the entire array before finding a failing value. - x[ len-1 ] = i * 3.14; - bool = isUnityProbabilityArray( x ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( isBoolean( bool ) ) { - b.pass( 'benchmark finished' ); - } else { - b.fail( 'should return a boolean' ); - } - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':len='+len, f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index 5a6810d..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/assert/is-unity-probability-array" -%% click B href "https://github.com/stdlib-js/assert-is-unity-probability-array/tree/main" -%% click C href "https://github.com/stdlib-js/assert-is-unity-probability-array/tree/production" -%% click D href "https://github.com/stdlib-js/assert-is-unity-probability-array/tree/esm" -%% click E href "https://github.com/stdlib-js/assert-is-unity-probability-array/tree/deno" -%% click F href "https://github.com/stdlib-js/assert-is-unity-probability-array/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/assert/is-unity-probability-array -[production-url]: https://github.com/stdlib-js/assert-is-unity-probability-array/tree/production -[deno-url]: https://github.com/stdlib-js/assert-is-unity-probability-array/tree/deno -[deno-readme]: https://github.com/stdlib-js/assert-is-unity-probability-array/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/assert-is-unity-probability-array/tree/umd -[umd-readme]: https://github.com/stdlib-js/assert-is-unity-probability-array/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/assert-is-unity-probability-array/tree/esm -[esm-readme]: https://github.com/stdlib-js/assert-is-unity-probability-array/blob/esm/README.md \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index c77d01e..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import isUnityProbabilityArray from '../docs/types/index'; -export = isUnityProbabilityArray; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 70d7801..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var f=function(r,i){return function(){return i||r((i={exports:{}}).exports,i),i.exports}};var u=f(function(m,s){ -var n=require('@stdlib/assert-is-typed-array/dist'),l=require('@stdlib/assert-is-array/dist'),o=require('@stdlib/assert-is-number/dist').isPrimitive,a=require('@stdlib/math-base-utils-absolute-difference/dist'),t=require('@stdlib/constants-float64-sqrt-eps/dist');function q(r){var i,e;if(l(r)){for(i=0,e=0;e1||r[e]<0)return!1;i+=r[e]}return a(i,1)<=t}if(n(r)){for(i=0,e=0;e1||r[e]<0)return!1;i+=r[e]}return a(i,1)<=t}return!1}s.exports=q -});var y=u();module.exports=y; -/** @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 387d5ad..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) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isTypedArray = require( '@stdlib/assert-is-typed-array' );\nvar isArray = require( '@stdlib/assert-is-array' );\nvar isNumber = require( '@stdlib/assert-is-number' ).isPrimitive;\nvar absdiff = require( '@stdlib/math-base-utils-absolute-difference' );\nvar FLOAT64_SQRT_EPS = require( '@stdlib/constants-float64-sqrt-eps' );\n\n\n// MAIN //\n\n/**\n* Tests if a value is an array of probabilities that sum to one.\n*\n* @param {*} v - value to test\n* @returns {boolean} boolean indicating if a value is a probability array\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] );\n* // returns true\n*\n* @example\n* var bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) );\n* // returns true\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] );\n* // returns false\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 3.14, 0.0 ] );\n* // returns false\n*/\nfunction isUnityProbabilityArray( v ) {\n\tvar sum;\n\tvar i;\n\tif ( isArray( v ) ) {\n\t\tsum = 0.0;\n\t\tfor ( i = 0; i < v.length; i++ ) {\n\t\t\tif (\n\t\t\t\t!isNumber( v[ i ] ) ||\n\t\t\t\tv[ i ] > 1.0 ||\n\t\t\t\tv[ i ] < 0.0\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tsum += v[ i ];\n\t\t}\n\t\treturn ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS );\n\t}\n\tif ( isTypedArray( v ) ) {\n\t\tsum = 0.0;\n\t\tfor ( i = 0; i < v.length; i++ ) {\n\t\t\tif (\n\t\t\t\tv[ i ] > 1.0 ||\n\t\t\t\tv[ i ] < 0.0\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tsum += v[ i ];\n\t\t}\n\t\treturn ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS );\n\t}\n\treturn false;\n}\n\n\n// EXPORTS //\n\nmodule.exports = isUnityProbabilityArray;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Test if a value is an array of probabilities that sum to one.\n*\n* @module @stdlib/assert-is-unity-probability-array\n*\n* @example\n* var isUnityProbabilityArray = require( '@stdlib/assert-is-unity-probability-array' );\n*\n* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] );\n* // returns true\n*\n* bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) );\n* // returns true\n*\n* bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] );\n* // returns false\n*\n* bool = isUnityProbabilityArray( [ 3.14, 0.0 ] );\n* // returns false\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,EAAe,QAAS,+BAAgC,EACxDC,EAAU,QAAS,yBAA0B,EAC7CC,EAAW,QAAS,0BAA2B,EAAE,YACjDC,EAAU,QAAS,6CAA8C,EACjEC,EAAmB,QAAS,oCAAqC,EA2BrE,SAASC,EAAyBC,EAAI,CACrC,IAAIC,EACAC,EACJ,GAAKP,EAASK,CAAE,EAAI,CAEnB,IADAC,EAAM,EACAC,EAAI,EAAGA,EAAIF,EAAE,OAAQE,IAAM,CAChC,GACC,CAACN,EAAUI,EAAGE,CAAE,CAAE,GAClBF,EAAGE,CAAE,EAAI,GACTF,EAAGE,CAAE,EAAI,EAET,MAAO,GAERD,GAAOD,EAAGE,CAAE,CACb,CACA,OAASL,EAASI,EAAK,CAAI,GAAKH,CACjC,CACA,GAAKJ,EAAcM,CAAE,EAAI,CAExB,IADAC,EAAM,EACAC,EAAI,EAAGA,EAAIF,EAAE,OAAQE,IAAM,CAChC,GACCF,EAAGE,CAAE,EAAI,GACTF,EAAGE,CAAE,EAAI,EAET,MAAO,GAERD,GAAOD,EAAGE,CAAE,CACb,CACA,OAASL,EAASI,EAAK,CAAI,GAAKH,CACjC,CACA,MAAO,EACR,CAKAL,EAAO,QAAUM,IC9CjB,IAAII,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isTypedArray", "isArray", "isNumber", "absdiff", "FLOAT64_SQRT_EPS", "isUnityProbabilityArray", "v", "sum", "i", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index a2414be..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,29 +0,0 @@ - -{{alias}}( value ) - Tests if a value is an array of probabilities that sum to one. - - Parameters - ---------- - value: any - Value to test. - - Returns - ------- - bool: boolean - Boolean indicating whether value is an array of probabilities that sum - to one. - - Examples - -------- - > var bool = {{alias}}( [ 0.25, 0.5, 0.25 ] ) - true - > bool = {{alias}}( new {{alias:@stdlib/array/uint8}}( [ 0, 1 ] ) ) - true - > bool = {{alias}}( [ 0.4, 0.4, 0.4 ] ) - false - > bool = {{alias}}( [ 3.14, 0.0 ] ) - false - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 6b41658..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,34 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import isUnityProbabilityArray = require( './index' ); - - -// TESTS // - -// The function returns a boolean... -{ - isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] ); // $ExpectType boolean - isUnityProbabilityArray( [ 2, 3 ] ); // $ExpectType boolean -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - isUnityProbabilityArray(); // $ExpectError - isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ], 123 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index b0b6bbc..0000000 --- a/examples/index.js +++ /dev/null @@ -1,48 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var Uint8Array = require( '@stdlib/array-uint8' ); -var isUnityProbabilityArray = require( './../lib' ); - -var arr = [ 0.0, 1.0 ]; -console.log( isUnityProbabilityArray( arr ) ); -// => true - -arr = [ 0.5, 0.25, 0.25 ]; -console.log( isUnityProbabilityArray( arr ) ); -// => true - -arr = new Uint8Array( [ 0, 0, 1, 0 ] ); -console.log( isUnityProbabilityArray( arr ) ); -// => true - -arr = [ 0.4, 0.4, 0.4 ]; -console.log( isUnityProbabilityArray( arr ) ); -// => false - -arr = [ 3.14, -1.0 ]; -console.log( isUnityProbabilityArray( arr ) ); -// => false - -console.log( isUnityProbabilityArray( [] ) ); -// => false - -console.log( isUnityProbabilityArray( null ) ); -// => false diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..efe2531 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2025 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-typed-array@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-array@v0.2.2-esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-number@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/math-base-utils-absolute-difference@v0.3.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/constants-float64-sqrt-eps@v0.2.2-esm/index.mjs";function n(n){var d,m;if(t(n)){for(d=0,m=0;m1||n[m]<0)return!1;d+=n[m]}return r(d,1)<=i}if(s(n)){for(d=0,m=0;m1||n[m]<0)return!1;d+=n[m]}return r(d,1)<=i}return!1}export{n as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..08904b0 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isTypedArray from '@stdlib/assert-is-typed-array';\nimport isArray from '@stdlib/assert-is-array';\nimport { isPrimitive as isNumber } from '@stdlib/assert-is-number';\nimport absdiff from '@stdlib/math-base-utils-absolute-difference';\nimport FLOAT64_SQRT_EPS from '@stdlib/constants-float64-sqrt-eps';\n\n\n// MAIN //\n\n/**\n* Tests if a value is an array of probabilities that sum to one.\n*\n* @param {*} v - value to test\n* @returns {boolean} boolean indicating if a value is a probability array\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] );\n* // returns true\n*\n* @example\n* var bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) );\n* // returns true\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] );\n* // returns false\n*\n* @example\n* var bool = isUnityProbabilityArray( [ 3.14, 0.0 ] );\n* // returns false\n*/\nfunction isUnityProbabilityArray( v ) {\n\tvar sum;\n\tvar i;\n\tif ( isArray( v ) ) {\n\t\tsum = 0.0;\n\t\tfor ( i = 0; i < v.length; i++ ) {\n\t\t\tif (\n\t\t\t\t!isNumber( v[ i ] ) ||\n\t\t\t\tv[ i ] > 1.0 ||\n\t\t\t\tv[ i ] < 0.0\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tsum += v[ i ];\n\t\t}\n\t\treturn ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS );\n\t}\n\tif ( isTypedArray( v ) ) {\n\t\tsum = 0.0;\n\t\tfor ( i = 0; i < v.length; i++ ) {\n\t\t\tif (\n\t\t\t\tv[ i ] > 1.0 ||\n\t\t\t\tv[ i ] < 0.0\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tsum += v[ i ];\n\t\t}\n\t\treturn ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS );\n\t}\n\treturn false;\n}\n\n\n// EXPORTS //\n\nexport default isUnityProbabilityArray;\n"],"names":["isUnityProbabilityArray","v","sum","i","isArray","length","isNumber","absdiff","FLOAT64_SQRT_EPS","isTypedArray"],"mappings":";;ufAqDA,SAASA,EAAyBC,GACjC,IAAIC,EACAC,EACJ,GAAKC,EAASH,GAAM,CAEnB,IADAC,EAAM,EACAC,EAAI,EAAGA,EAAIF,EAAEI,OAAQF,IAAM,CAChC,IACEG,EAAUL,EAAGE,KACdF,EAAGE,GAAM,GACTF,EAAGE,GAAM,EAET,OAAO,EAERD,GAAOD,EAAGE,EACV,CACD,OAASI,EAASL,EAAK,IAASM,CAChC,CACD,GAAKC,EAAcR,GAAM,CAExB,IADAC,EAAM,EACAC,EAAI,EAAGA,EAAIF,EAAEI,OAAQF,IAAM,CAChC,GACCF,EAAGE,GAAM,GACTF,EAAGE,GAAM,EAET,OAAO,EAERD,GAAOD,EAAGE,EACV,CACD,OAASI,EAASL,EAAK,IAASM,CAChC,CACD,OAAO,CACR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 13a67d1..0000000 --- a/lib/index.js +++ /dev/null @@ -1,49 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Test if a value is an array of probabilities that sum to one. -* -* @module @stdlib/assert-is-unity-probability-array -* -* @example -* var isUnityProbabilityArray = require( '@stdlib/assert-is-unity-probability-array' ); -* -* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] ); -* // returns true -* -* bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) ); -* // returns true -* -* bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] ); -* // returns false -* -* bool = isUnityProbabilityArray( [ 3.14, 0.0 ] ); -* // returns false -*/ - -// 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 d0bda40..0000000 --- a/lib/main.js +++ /dev/null @@ -1,90 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isTypedArray = require( '@stdlib/assert-is-typed-array' ); -var isArray = require( '@stdlib/assert-is-array' ); -var isNumber = require( '@stdlib/assert-is-number' ).isPrimitive; -var absdiff = require( '@stdlib/math-base-utils-absolute-difference' ); -var FLOAT64_SQRT_EPS = require( '@stdlib/constants-float64-sqrt-eps' ); - - -// MAIN // - -/** -* Tests if a value is an array of probabilities that sum to one. -* -* @param {*} v - value to test -* @returns {boolean} boolean indicating if a value is a probability array -* -* @example -* var bool = isUnityProbabilityArray( [ 0.25, 0.5, 0.25 ] ); -* // returns true -* -* @example -* var bool = isUnityProbabilityArray( new Uint8Array( [ 0, 1 ] ) ); -* // returns true -* -* @example -* var bool = isUnityProbabilityArray( [ 0.4, 0.4, 0.4 ] ); -* // returns false -* -* @example -* var bool = isUnityProbabilityArray( [ 3.14, 0.0 ] ); -* // returns false -*/ -function isUnityProbabilityArray( v ) { - var sum; - var i; - if ( isArray( v ) ) { - sum = 0.0; - for ( i = 0; i < v.length; i++ ) { - if ( - !isNumber( v[ i ] ) || - v[ i ] > 1.0 || - v[ i ] < 0.0 - ) { - return false; - } - sum += v[ i ]; - } - return ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS ); - } - if ( isTypedArray( v ) ) { - sum = 0.0; - for ( i = 0; i < v.length; i++ ) { - if ( - v[ i ] > 1.0 || - v[ i ] < 0.0 - ) { - return false; - } - sum += v[ i ]; - } - return ( absdiff( sum, 1.0 ) <= FLOAT64_SQRT_EPS ); - } - return false; -} - - -// EXPORTS // - -module.exports = isUnityProbabilityArray; diff --git a/package.json b/package.json index 2375604..9ba851e 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.2", "description": "Test if a value is an array of probabilities that sum to one.", "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" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,47 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-array": "^0.2.2", - "@stdlib/assert-is-number": "^0.2.2", - "@stdlib/assert-is-typed-array": "^0.2.2", - "@stdlib/constants-float64-sqrt-eps": "^0.2.2", - "@stdlib/math-base-utils-absolute-difference": "^0.3.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/array-float32": "^0.2.2", - "@stdlib/array-float64": "^0.2.2", - "@stdlib/array-int16": "^0.2.2", - "@stdlib/array-int32": "^0.2.2", - "@stdlib/array-int8": "^0.2.2", - "@stdlib/array-uint16": "^0.2.2", - "@stdlib/array-uint32": "^0.2.2", - "@stdlib/array-uint8": "^0.2.2", - "@stdlib/array-uint8c": "^0.2.2", - "@stdlib/assert-is-boolean": "^0.2.2", - "@stdlib/buffer-from-array": "^0.2.2", - "@stdlib/math-base-special-pow": "^0.3.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.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdassert", @@ -105,4 +41,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..2282772 --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index a0424fb..0000000 --- a/test/test.js +++ /dev/null @@ -1,106 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Int8Array = require( '@stdlib/array-int8' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Float64Array = require( '@stdlib/array-float64' ); -var array2buffer = require( '@stdlib/buffer-from-array' ); -var isUnityProbabilityArray = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof isUnityProbabilityArray, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns `true` if provided an array of probabilities that sum to one', function test( t ) { - var values; - var i; - - values = [ - new Int8Array( [ 0, 0, 1 ] ), - new Uint8Array( [ 1, 0, 0 ] ), - new Uint8ClampedArray( [ 0, 1 ] ), - new Int16Array( [ 0, 0, 1, 0 ] ), - new Uint16Array( [ 1 ] ), - new Int32Array( [ 1, 0, 0 ] ), - new Uint32Array( [ 0, 1, 0 ] ), - new Float32Array( [ 0.0, 0.5, 0.5 ] ), - new Float64Array( [ 0.25, 0.25, 0.5 ] ), - [ 0.5, 0.25, 0.25 ] - ]; - - for ( i = 0; i < values.length; i++ ) { - t.strictEqual( isUnityProbabilityArray( values[i] ), true, 'returns true when provided '+values[i] ); - } - t.end(); -}); - -tape( 'the function allows a difference in sum within floating-point epsilon', function test( t ) { - var bool = isUnityProbabilityArray( [ 0.1, 0.2, 0.1, 0.1, 0.2, 0.2, 0.1 ] ); - t.strictEqual( bool, true, 'returns true' ); - t.end(); -}); - -tape( 'the function returns `false` if not provided an array of probabilities that sum to one', function test( t ) { - var values; - var i; - - values = [ - '10', - '01', - '0.5', - '5', - 5, - NaN, - null, - void 0, - true, - [], - [ 5, null ], - [ 5, '5' ], - [ 1.0, 3.14 ], - [ -1.0, 1.0, 1.0 ], - [ 0.25, 0.33, 0.5 ], - new Float64Array( [ 0.25, 0.33, 0.5 ] ), - new Float64Array( [ 0.25, 1.33, 0.5 ] ), - new Float64Array( [ 0.25, -0.33, 0.5 ] ), - {}, - function noop() {}, - array2buffer( [ 1, 1, 0 ] ) - ]; - - for ( i = 0; i < values.length; i++ ) { - t.strictEqual( isUnityProbabilityArray( values[i] ), false, 'returns false when provided '+values[i] ); - } - t.end(); -});