From 086aa2d9c4a22f74974f6bffd2bbc29bb8be76b1 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 15 Jun 2021 14:23:40 -0400 Subject: [PATCH] Auto-generated commit --- .editorconfig | 154 ++ .gitattributes | 33 + .github/PULL_REQUEST_TEMPLATE.md | 7 + .github/workflows/benchmark.yml | 19 + .github/workflows/close_pull_requests.yml | 23 + .github/workflows/examples.yml | 19 + .github/workflows/publish.yml | 34 + .github/workflows/test.yml | 29 + .github/workflows/test_coverage.yml | 24 + .github/workflows/test_install.yml | 27 + .gitignore | 181 ++ .npmignore | 225 +++ .npmrc | 28 + CODE_OF_CONDUCT.md | 3 + CONTRIBUTING.md | 3 + CONTRIBUTORS | 24 + LICENSE | 481 +++++ Makefile | 534 ++++++ NOTICE | 1 + README.md | 281 +++ benchmark/benchmark.js | 228 +++ benchmark/benchmark.length.float32.js | 93 + benchmark/benchmark.length.float64.js | 93 + benchmark/benchmark.length.generic.js | 93 + benchmark/benchmark.length.int16.js | 93 + benchmark/benchmark.length.int32.js | 93 + benchmark/benchmark.length.int8.js | 93 + benchmark/benchmark.length.uint16.js | 93 + benchmark/benchmark.length.uint32.js | 93 + benchmark/benchmark.length.uint8.js | 93 + benchmark/benchmark.length.uint8c.js | 93 + docs/repl.txt | 155 ++ docs/types/index.d.ts | 225 +++ docs/types/test.ts | 206 +++ examples/index.js | 37 + lib/index.js | 132 ++ lib/main.js | 228 +++ package.json | 144 ++ test/test.js | 2059 +++++++++++++++++++++ 39 files changed, 6474 insertions(+) create mode 100644 .editorconfig create mode 100644 .gitattributes create mode 100644 .github/PULL_REQUEST_TEMPLATE.md create mode 100644 .github/workflows/benchmark.yml create mode 100644 .github/workflows/close_pull_requests.yml create mode 100644 .github/workflows/examples.yml create mode 100644 .github/workflows/publish.yml create mode 100644 .github/workflows/test.yml create mode 100644 .github/workflows/test_coverage.yml create mode 100644 .github/workflows/test_install.yml create mode 100644 .gitignore create mode 100644 .npmignore create mode 100644 .npmrc create mode 100644 CODE_OF_CONDUCT.md create mode 100644 CONTRIBUTING.md create mode 100644 CONTRIBUTORS create mode 100644 LICENSE create mode 100644 Makefile create mode 100644 NOTICE create mode 100644 README.md create mode 100644 benchmark/benchmark.js create mode 100644 benchmark/benchmark.length.float32.js create mode 100644 benchmark/benchmark.length.float64.js create mode 100644 benchmark/benchmark.length.generic.js create mode 100644 benchmark/benchmark.length.int16.js create mode 100644 benchmark/benchmark.length.int32.js create mode 100644 benchmark/benchmark.length.int8.js create mode 100644 benchmark/benchmark.length.uint16.js create mode 100644 benchmark/benchmark.length.uint32.js create mode 100644 benchmark/benchmark.length.uint8.js create mode 100644 benchmark/benchmark.length.uint8c.js create mode 100644 docs/repl.txt create mode 100644 docs/types/index.d.ts create mode 100644 docs/types/test.ts create mode 100644 examples/index.js create mode 100644 lib/index.js create mode 100644 lib/main.js create mode 100644 package.json create mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..c66ad55 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,154 @@ +#/ +# @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] +indent_style = tab + +# Set properties for TypeScript files: +[*.ts] +indent_style = tab + +# Set properties for Python files: +[*.py] +indent_style = space +indent_size = 4 + +# Set properties for Julia files: +[*.jl] +indent_style = tab + +# Set properties for R files: +[*.R] +indent_style = tab + +# Set properties for C files: +[*.c] +indent_style = tab + +# Set properties for C header files: +[*.h] +indent_style = tab + +# Set properties for C++ files: +[*.cpp] +indent_style = tab + +# Set properties for C++ header files: +[*.hpp] +indent_style = tab + +# Set properties for Fortran files: +[*.f] +indent_style = space +indent_size = 2 +insert_final_newline = false + +# Set properties for shell files: +[*.sh] +indent_style = tab + +# Set properties for AWK files: +[*.awk] +indent_style = tab + +# Set properties for HTML files: +[*.html] +indent_style = tab +tab_width = 2 + +# Set properties for CSS files: +[*.css] +indent_style = tab + +# Set properties for Makefiles: +[Makefile] +indent_style = tab + +[*.mk] +indent_style = tab + +# Set properties for Markdown files: +[*.md] +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] +indent_style = space +indent_size = 2 + +# Set properties for `datapackage.json` files: +[datapackage.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] +indent_style = tab + +# Set properties for LaTeX Bibliography files: +[*.bib] +indent_style = tab + +# Set properties for YAML files: +[*.yml] +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/.gitattributes b/.gitattributes new file mode 100644 index 0000000..7212d81 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,33 @@ +#/ +# @license Apache-2.0 +# +# Copyright (c) 2017 The Stdlib Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +#/ + +# Configuration file which assigns attributes to pathnames. +# +# [1]: https://git-scm.com/docs/gitattributes + +# Automatically normalize the line endings of any committed text files: +* text=auto + +# Override what is considered "vendored" by GitHub's linguist: +/deps/** linguist-vendored=false +/lib/node_modules/** linguist-vendored=false linguist-generated=false +test/fixtures/** linguist-vendored=false +tools/** linguist-vendored=false + +# Override what is considered "documentation" by GitHub's linguist: +examples/** linguist-documentation=false diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 0000000..437e823 --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,7 @@ + + +We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/filled) of the main repository where we’ll review and provide feedback. + +If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. + +We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml new file mode 100644 index 0000000..e51e34e --- /dev/null +++ b/.github/workflows/benchmark.yml @@ -0,0 +1,19 @@ +name: benchmark + +on: + workflow_dispatch: + +jobs: + benchmark: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-node@v1 + with: + node-version: 15 + - name: Install production and development dependencies + run: | + npm install + - name: Run benchmarks + run: | + npm run benchmark diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml new file mode 100644 index 0000000..3dbb184 --- /dev/null +++ b/.github/workflows/close_pull_requests.yml @@ -0,0 +1,23 @@ +name: Close Pull Requests + +on: + pull_request_target: + types: [opened] + +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/array/filled) 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 new file mode 100644 index 0000000..0c19f10 --- /dev/null +++ b/.github/workflows/examples.yml @@ -0,0 +1,19 @@ +name: examples + +on: + workflow_dispatch: + +jobs: + examples: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-node@v1 + with: + node-version: 15 + - name: Install production and development dependencies + run: | + npm install + - name: Run examples + run: | + npm run examples diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..ae05f51 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,34 @@ +name: Publish Package + +on: push + +jobs: + publish: + runs-on: ubuntu-latest + env: + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-node@v1 + with: + node-version: 15 + - name: Increment version + run: | + git config --local user.email "noreply@stdlib.io" + git config --local user.name "stdlib-bot" + npm version patch + - name: Publish package to npm + uses: JS-DevTools/npm-publish@v1 + with: + token: ${{ secrets.NPM_TOKEN }} + access: public + - name: Push changes + run: | + git push origin main + git push --tags + - uses: act10ns/slack@v1 + with: + status: ${{ job.status }} + steps: ${{ toJson(steps) }} + channel: '#npm-ci' + if: failure() diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..3c99108 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,29 @@ +name: build + +on: + workflow_dispatch: + +jobs: + test: + runs-on: ubuntu-latest + env: + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-node@v1 + with: + node-version: 15 + - name: Install production and development dependencies + id: install + run: | + npm install + - name: Run tests + id: tests + run: | + npm test + - uses: act10ns/slack@v1 + with: + status: ${{ job.status }} + steps: ${{ toJson(steps) }} + channel: '#npm-ci' + if: failure() diff --git a/.github/workflows/test_coverage.yml b/.github/workflows/test_coverage.yml new file mode 100644 index 0000000..0e8045d --- /dev/null +++ b/.github/workflows/test_coverage.yml @@ -0,0 +1,24 @@ +name: coverage + +on: + workflow_dispatch: + +jobs: + test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-node@v1 + with: + node-version: 15 + - name: Install production and development dependencies + run: | + npm install + - name: Calculate test coverage + run: | + npm run test-cov + - name: Upload coverage to Codecov + uses: codecov/codecov-action@v1 + with: + directory: reports/coverage + flags: unittests diff --git a/.github/workflows/test_install.yml b/.github/workflows/test_install.yml new file mode 100644 index 0000000..ee70831 --- /dev/null +++ b/.github/workflows/test_install.yml @@ -0,0 +1,27 @@ +name: Test Installing Dependencies + +on: + workflow_run: + workflows: ["Publish Package"] + types: [completed] + +jobs: + on-success: + runs-on: ubuntu-latest + env: + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} + if: ${{ github.event.workflow_run.conclusion == 'success' }} + steps: + - uses: actions/checkout@v1 + - uses: actions/setup-node@v1 + with: + node-version: 15 + - name: Install production dependencies via npm + run: | + npm install --only=prod + - uses: act10ns/slack@v1 + with: + status: ${{ job.status }} + steps: ${{ toJson(steps) }} + channel: '#npm-ci' + if: failure() diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..1475963 --- /dev/null +++ b/.gitignore @@ -0,0 +1,181 @@ +#/ +# @license Apache-2.0 +# +# Copyright (c) 2017 The Stdlib Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +#/ + +# Files # +######### +.postinstall.json + +# Directories # +############### +build/ +downloads/ +reports/ +tmp/ + +# Compiled source # +################### +*.com +*.class +*.dll +*.o +*.so +*.slo +*.lo +*.obj +*.dylib +*.lai +*.la +*.a +*.lib +*.ko +*.elf +*.node + +# Precompiled headers # +####################### +*.gch +*.pch + +# Executables # +############### +*.exe +*.out +*.app + +# Packages # +############ +# It is better to unpack these files and commit the raw source +# git has its own built in compression methods +*.7z +*.dmg +*.gz +*.iso +*.jar +*.rar +*.tar +*.zip + +# Make an exception for compressed distributable files: +!dist/*.gz + +# Logs and databases # +###################### +*.log +*.sql +*.sqlite + +# OS generated files # +###################### +.DS_Store +.DS_Store? +._* +.Spotlight-V100 +.Trashes +Icon? +ehthumbs.db +Thumbs.db +Desktop.ini + +# Temporary files # +################### +*~ + +# Node.js # +########### +/node_modules/ +lib/node_modules/**/node_modules/ +docs/**/node_modules/ +pids +*.pid +*.seed + +# Typescript # +############## +*.tsbuildinfo +lib/node_modules/**/tsconfig.json +lib/node_modules/**/tslint.json + +# Matlab # +########## +*.asv +*.mex* + +# Fortran # +########### +*.mod + +# R # +##### +.Rhistory +.Rapp.history +.Rproj.user/ + +# Python # +########## +__pycache__/ +*.py[cod] +*$py.class +*.egg-info/ + +# TeX # +####### +*.aux +*.lof +*.log +*.lot +*.fls +*.out +*.toc +*.dvi +*-converted-to.* +*.bbl +*.bcf +*.blg +*-blx.aux +*-blx.bib +*.brf +*.run.xml +*.fdb_latexmk +*.synctex +*.synctex.gz +*.synctex.gz(busy) +*.pdfsync +*.alg +*.loa +acs-*.bib +*.thm +*.nav +*.snm +*.vrb +*.acn +*.acr +*.glg +*.glo +*.gls +*-concordance.tex +*.tikz +*-tikzDictionary +*.idx +*.ilg +*.ind +*.ist + +# Visual Studio # +################# +.vscode/ +jsconfig.json diff --git a/.npmignore b/.npmignore new file mode 100644 index 0000000..401aa76 --- /dev/null +++ b/.npmignore @@ -0,0 +1,225 @@ +#/ +# @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. +#/ + +# Files # +######### +CODE_OF_CONDUCT.md +CONTRIBUTING.md +CONTRIBUTORS +TODO.md +ROADMAP.md +.postinstall.json + +# Directories # +############### +.circleci/ +.github/ +**/benchmark/ +**/build/ +**/examples/ +reports/ +support/ +**/tmp/ +workshops/ + +# Ignore test directories, except for testing dependency installation: +**/test/ +!/deps/test/ + +# Only top-level directories: +/etc/ +/docs/ + +# Compiled source # +################### +*.com +*.class +*.dll +*.o +*.so +*.slo +*.lo +*.obj +*.dylib +*.lai +*.la +*.a +*.lib +*.ko +*.elf +*.node + +# Precompiled headers # +####################### +*.gch +*.pch + +# Executables # +############### +*.exe +*.out +*.app + +# Packages # +############ +*.7z +*.dmg +*.gz +*.iso +*.jar +*.rar +*.tar +*.zip + +# Make an exception for compressed distributable files: +!dist/*.gz + +# Logs and databases # +###################### +*.log +*.sql +*.sqlite + +# OS generated files # +###################### +.DS_Store +.DS_Store? +._* +.Spotlight-V100 +.Trashes +Icon? +ehthumbs.db +Thumbs.db +Desktop.ini + +# Temporary files # +################### +*~ + +# Node.js # +########### +.npmignore + +# Only top-level node_modules: +/node_modules/ + +# TypeScript # +############## +tsconfig.json +tslint.json +*.tsbuildinfo + +# Matlab # +########## +*.asv +*.mex* + +# Fortran # +########### +*.mod + +# R # +##### +.Rhistory +.Rapp.history +.Rproj.user/ + +# Python # +########## +__pycache__/ +*.py[cod] +*$py.class +*.egg-info/ +.ipynb_checkpoints +setup.cfg +setup.py + +# TeX # +####### +*.aux +*.lof +*.log +*.lot +*.fls +*.out +*.toc +*.dvi +*-converted-to.* +*.bbl +*.bcf +*.blg +*-blx.aux +*-blx.bib +*.brf +*.run.xml +*.fdb_latexmk +*.synctex +*.synctex.gz +*.synctex.gz(busy) +*.pdfsync +*.alg +*.loa +acs-*.bib +*.thm +*.nav +*.snm +*.vrb +*.acn +*.acr +*.glg +*.glo +*.gls +*-concordance.tex +*.tikz +*-tikzDictionary +*.idx +*.ilg +*.ind +*.ist + +# Git # +####### +.git* +.mailmap + +# Visual Studio # +################# +.vscode/ +jsconfig.json + +# Utilities # +############# +.jshintrc +.jshintignore +.eslintrc* +.eslintignore + +.pylintrc +.pycodestyle +.pydocstyle + +.travis.yml +circle.yml +appveyor.yml +azure-pipelines.yml + +.editorconfig +.codeclimate.yml +.codecov.yml + +.rtlintrc diff --git a/.npmrc b/.npmrc new file mode 100644 index 0000000..36f5bef --- /dev/null +++ b/.npmrc @@ -0,0 +1,28 @@ +#/ +# @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 for [npm][1]. +# +# [1]: https://docs.npmjs.com/files/npmrc + +# Disable the creation of a lock file: +package-lock = false +shrinkwrap = false + +# Disable automatically "saving" dependencies on install: +save = false diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md new file mode 100644 index 0000000..35b70c9 --- /dev/null +++ b/CODE_OF_CONDUCT.md @@ -0,0 +1,3 @@ +# Code of Conduct + +stdlib expects community participants to adhere to the project Code of Conduct. The [full text](https://github.com/stdlib-js/stdlib/blob/develop/CODE_OF_CONDUCT.md) is available in the main project repository. diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..5f59443 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,3 @@ +# Contribution Guidelines + +Woot woot! If you are new to stdlib, welcome! And thanks for your interest! Guidelines for how to contribute to the project are [available](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) in the main project repository. diff --git a/CONTRIBUTORS b/CONTRIBUTORS new file mode 100644 index 0000000..da469e5 --- /dev/null +++ b/CONTRIBUTORS @@ -0,0 +1,24 @@ +# This file is generated by tools/scripts/update_contributors. +# +# Contributors listed in alphabetical order. + +Athan Reines +Brendan Graetz +Bruno Fenzl +Christopher Dambamuromo +Dominik Moritz +Frank Kovacs +James +Jithin KS +Joey Reed +Joris Labie +Justin Dennison +Marcus +Matt Cochrane +Milan Raj +Ognjen Jevremović +Philipp Burckhardt +Ricky Reusser +Ryan Seal +Shraddheya Shendre +rei2hu diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..fcc9934 --- /dev/null +++ b/LICENSE @@ -0,0 +1,481 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + + +Boost Software License - Version 1.0 - August 17th, 2003 + +Permission is hereby granted, free of charge, to any person or organization +obtaining a copy of the software and accompanying documentation covered by this +license (the "Software") to use, reproduce, display, distribute, execute, and +transmit the Software, and to prepare derivative works of the Software, and to +permit third-parties to whom the Software is furnished to do so, all subject to +the following: + +The copyright notices in the Software and this entire statement, including the +above license grant, this restriction and the following disclaimer, must be +included in all copies of the Software, in whole or in part, and all derivative +works of the Software, unless such copies or derivative works are solely in the +form of machine-executable object code generated by a source language processor. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE +COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE FOR ANY DAMAGES +OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF +OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + + + + +DEPENDENCIES + +The library links against the following external libraries, which have their own +licenses: + +* OpenBLAS + +Copyright (c) 2011-2014, The OpenBLAS Project +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + + 3. Neither the name of the OpenBLAS project nor the names of + its contributors may be used to endorse or promote products + derived from this software without specific prior written + permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF +THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +* Electron + +Copyright (c) 2013-2017 GitHub Inc. + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + + +* Boost + +Boost Software License - Version 1.0 - August 17th, 2003 + +Permission is hereby granted, free of charge, to any person or organization +obtaining a copy of the software and accompanying documentation covered by +this license (the "Software") to use, reproduce, display, distribute, +execute, and transmit the Software, and to prepare derivative works of the +Software, and to permit third-parties to whom the Software is furnished to +do so, all subject to the following: + +The copyright notices in the Software and this entire statement, including +the above license grant, this restriction and the following disclaimer, +must be included in all copies of the Software, in whole or in part, and +all derivative works of the Software, unless such copies or derivative +works are solely in the form of machine-executable object code generated by +a source language processor. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT +SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE +FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, +ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. + + +* Cephes + +Copyright (c) 1984-2000 Stephen L. Moshier + +Some software in this archive may be from the book _Methods and Programs for +Mathematical Functions_ (Prentice-Hall or Simon & Schuster International, 1989) +or from the Cephes Mathematical Library, a commercial product. In either event, +it is copyrighted by the author. What you see here may be used freely but it +comes with no support or guarantee. + +Stephen L. Moshier +moshier@na-net.ornl.gov + + + +ATTRIBUTION + +The library contains implementations from the following external libraries, +which have their own licenses: + +* FreeBSD + +Copyright (C) 1993-2004 by Sun Microsystems, Inc. All rights reserved. + +Developed at SunPro, a Sun Microsystems, Inc. business. +Permission to use, copy, modify, and distribute this +software is freely granted, provided that this notice +is preserved. + + +* FDLIBM + +Copyright (C) 2004 by Sun Microsystems, Inc. All rights reserved. + +Developed at SunPro, a Sun Microsystems, Inc. business. +Permission to use, copy, modify, and distribute this +software is freely granted, provided that this notice +is preserved. + + +* Go + +Copyright (c) 2009 The Go Authors. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above +copyright notice, this list of conditions and the following disclaimer +in the documentation and/or other materials provided with the +distribution. + * Neither the name of Google Inc. nor the names of its +contributors may be used to endorse or promote products derived from +this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +* SLATEC Common Mathematical Library + +Public domain. + + +* ESLint + +Copyright JS Foundation and other contributors, https://js.foundation + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + + +* StatsFuns.jl + +Copyright (c) 2015: Dahua Lin. + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + + +* SpecialFunctions.jl + +The MIT License (MIT) + +Copyright (c) 2017 Jeff Bezanson, Stefan Karpinski, Viral B. Shah, and others: + +https://github.com/JuliaMath/SpecialFunctions.jl/graphs/contributors + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + + +* MT19937 + +Copyright (C) 1997 - 2002, Makoto Matsumoto and Takuji Nishimura, +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: + + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + 3. The names of its contributors may not be used to endorse or promote + products derived from this software without specific prior written + permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..1c7d53e --- /dev/null +++ b/Makefile @@ -0,0 +1,534 @@ +#/ +# @license Apache-2.0 +# +# Copyright (c) 2021 The Stdlib Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +#/ + +# USER VARIABLES # + +ifndef VERBOSE + QUIET := @ +else + QUIET := +endif + +# Indicate whether to "fast" fail when linting, running tests, etc: +ifndef FAST_FAIL + FAIL_FAST := true +else +ifeq ($(FAST_FAIL), 0) + FAIL_FAST := false +else + FAIL_FAST := true +endif +endif + +# Define the `NODE_PATH` environment variable: +NODE_PATH ?= + +# Define the `NODE_ENV` environment variable: +NODE_ENV ?= + + +# INTERNAL VARIABLES # + +# Instruct make to warn us when we use an undefined variable (e.g., misspellings). +MAKEFLAGS += --warn-undefined-variables + +# Define the default target: +.DEFAULT_GOAL := all + +# Define the `SHELL` variable to avoid issues on systems where the variable may be inherited from the environment. +# +# ## Notes +# +# - We use `bash` so that we can use `pipefail`. +# +# +# [1]: https://www.gnu.org/prep/standards/html_node/Makefile-Basics.html#Makefile-Basics +# [2]: http://clarkgrubb.com/makefile-style-guide +SHELL := bash + +# Define shell flags. +# +# ## Notes +# +# - `.SHELLFLAGS` was introduced in GNU Make 3.82 and has no effect on the version of GNU Make installed on Mac OS X, which is 3.81. +# - The `-e` flag causes `bash` to exit immediately if a `bash` executed command fails. +# - The `-u` flag causes `bash` to exit with an error message if a variable is accessed without being defined. +# - The `pipefail` option specifies that, if any of the commands in a pipeline fail, the entire pipeline fails. Otherwise the return value of a pipeline is the return value of the last command. +# - The `-c` flag is in the default value of `.SHELLFLAGS`, which must be preserved, as this is how `make` passes the script to be executed to `bash`. +# +.SHELLFLAGS := -eu -o pipefail -c + +# Remove targets if its recipe fails. +# +# ## Notes +# +# - Mentioning this target anywhere in a Makefile prevents a user from re-running make and using an incomplete or invalid target. +# - When debugging, it may be necessary to comment this line out so the incomplete or invalid target can be inspected. +# +# [1]: https://www.gnu.org/software/make/manual/html_node/Special-Targets.html +.DELETE_ON_ERROR: + +# Remove all the default suffixes, preferring to define all rules explicitly. +# +# [1]: https://www.gnu.org/software/make/manual/html_node/Suffix-Rules.html#Suffix-Rules +# [2]: https://www.gnu.org/software/make/manual/html_node/Suffix-Rules.html#Suffix-Rules +.SUFFIXES: + +# Determine the OS ([1][1], [2][2]). +# +# [1]: https://en.wikipedia.org/wiki/Uname#Examples +# [2]: http://stackoverflow.com/a/27776822/2225624 +OS ?= $(shell uname) +ifneq (, $(findstring MINGW,$(OS))) + OS := WINNT +else +ifneq (, $(findstring MSYS,$(OS))) + OS := WINNT +else +ifneq (, $(findstring CYGWIN,$(OS))) + OS := WINNT +else +ifneq (, $(findstring Windows_NT,$(OS))) + OS := WINNT +endif +endif +endif +endif + +# Determine the filename: +this_file := $(lastword $(MAKEFILE_LIST)) + +# Determine the absolute path of the Makefile (see http://blog.jgc.org/2007/01/what-makefile-am-i-in.html): +this_dir := $(dir $(CURDIR)/$(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST))) + +# Remove the trailing slash: +this_dir := $(patsubst %/,%,$(this_dir)) + +# Determine root directory: +ROOT_DIR = $(this_dir) + +# Define the root build directory: +BUILD_DIR ?= $(ROOT_DIR)/build + +# Define the root directory for storing distributable files: +DIST_DIR ?= $(ROOT_DIR)/dist + +# Define the root directory for storing temporary files: +TMP_DIR ?= $(ROOT_DIR)/tmp + +# Define the directories for writing reports, including code coverage: +REPORTS_DIR ?= $(ROOT_DIR)/reports +COVERAGE_DIR ?= $(REPORTS_DIR)/coverage + +# Define the top-level directory containing node module dependencies: +NODE_MODULES ?= $(ROOT_DIR)/node_modules + +# Define the top-level directory containing node module executables: +BIN_DIR ?= $(NODE_MODULES)/.bin + +# Define the path to the root `package.json`: +ROOT_PACKAGE_JSON ?= $(ROOT_DIR)/package.json + +# Define the folder name convention for source files requiring compilation: +SRC_FOLDER ?= src + +# Define the folder name convention for documentation files: +DOCUMENTATION_FOLDER ?= docs + +# Define the folder name convention for configuration files: +CONFIG_FOLDER ?= etc + +# Define the folder name convention for benchmark files: +BENCHMARKS_FOLDER ?= benchmark + +# Define the folder name convention for benchmark fixtures: +BENCHMARKS_FIXTURES_FOLDER ?= $(BENCHMARKS_FOLDER)/fixtures + +# Define the folder name convention for examples files: +EXAMPLES_FOLDER ?= examples + +# Define the folder name convention for examples fixtures: +EXAMPLES_FIXTURES_FOLDER ?= $(EXAMPLES_FOLDER)/fixtures + +# Define the folder name convention for test files: +TESTS_FOLDER ?= test + +# Define the folder name convention for test fixtures: +TESTS_FIXTURES_FOLDER ?= $(TESTS_FOLDER)/fixtures + +# Define a filepath pattern for benchmark files: +BENCHMARKS_FILTER ?= .*/.* + +# Define a filepath pattern for example files: +EXAMPLES_FILTER ?= .*/.* + +# Define a filepath pattern for test files: +TESTS_FILTER ?= .*/.* + +# Define a filename pattern for benchmark files: +BENCHMARKS_PATTERN ?= benchmark*.js + +# Define a filename pattern for example files: +EXAMPLES_PATTERN ?= *.js + +# Define a filename pattern for test files: +TESTS_PATTERN ?= test*.js + +# Define Node environments: +ifdef NODE_ENV + NODE_ENV_BENCHMARK := $(NODE_ENV) + NODE_ENV_EXAMPLES := $(NODE_ENV) + NODE_ENV_TEST := $(NODE_ENV) +else + NODE_ENV ?= + NODE_ENV_BENCHMARK ?= benchmark + NODE_ENV_EXAMPLES ?= examples + NODE_ENV_TEST ?= test +endif + +# Define whether delete operations should be safe (i.e., deleted items are sent to trash, rather than permanently deleted): +SAFE_DELETE ?= false + +# Define the delete command: +ifeq ($(SAFE_DELETE), true) + # FIXME: -rm -rf + DELETE := -rm + DELETE_FLAGS := -rf +else + DELETE ?= -rm + DELETE_FLAGS ?= -rf +endif + +# Determine the `open` command: +ifeq ($(OS), Darwin) + OPEN ?= open +else + OPEN ?= xdg-open +endif +# TODO: add Windows command + +# Define the command for `node`: +NODE ?= node + +# Define the command for `npm`: +NPM ?= npm + +# Define the path to a JavaScript test runner. +# +# ## Notes +# +# - We reference the `bin` file directly in order to support using `istanbul` for code coverage on Windows (https://github.com/gotwarlost/istanbul#usage-on-windows) +JAVASCRIPT_TEST ?= $(NODE_MODULES)/tape/bin/tape + +# Define any command-line options to use when invoking the test runner: +JAVASCRIPT_TEST_FLAGS ?= + +# Define the path to the executable for parsing TAP output: +TAP_REPORTER ?= $(BIN_DIR)/tap-spec + +# Define the path to the Istanbul executable: +ISTANBUL ?= $(BIN_DIR)/istanbul + +# Define which files and directories to exclude from coverage instrumentation: +ISTANBUL_EXCLUDES_FLAGS ?= \ + --no-default-excludes \ + -x 'node_modules/**' \ + -x 'reports/**' \ + -x 'tmp/**' \ + -x 'deps/**' \ + -x 'dist/**' \ + -x "**/$(SRC_FOLDER)/**" \ + -x "**/$(TESTS_FOLDER)/**" \ + -x "**/$(EXAMPLES_FOLDER)/**" \ + -x "**/$(BENCHMARKS_FOLDER)/**" \ + -x "**/$(CONFIG_FOLDER)/**" \ + -x "**/$(DOCUMENTATION_FOLDER)/**" + +# Define the command to generate test coverage: +ISTANBUL_COVER ?= $(ISTANBUL) cover + +# Define the type of report Istanbul should produce: +ISTANBUL_COVER_REPORT_FORMAT ?= lcov + +# Define the command-line options to be used when generating code coverage: +ISTANBUL_COVER_FLAGS ?= \ + $(ISTANBUL_EXCLUDES_FLAGS) \ + --dir $(COVERAGE_DIR) \ + --report $(ISTANBUL_COVER_REPORT_FORMAT) + +# On Mac OSX, in order to use `|` and other regular expression operators, we need to use enhanced regular expression syntax (-E); see https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man7/re_format.7.html#//apple_ref/doc/man/7/re_format. +ifeq ($(OS), Darwin) + find_kernel_prefix := -E +else + find_kernel_prefix := +endif + +# Common exclude flags that most recipes for finding package files should use (Note: order does matter to some degree): +FIND_COMMON_EXCLUDE_FLAGS ?= \ + -not -path "$(ROOT_DIR)/.*" \ + -not -path "$(NODE_MODULES)/*" \ + -not -path "$(BUILD_DIR)/*" \ + -not -path "$(REPORTS_DIR)/*" \ + +# Define exclusion flags to use when searching for benchmark files: +FIND_BENCHMARKS_EXCLUDE_FLAGS ?= \ + $(FIND_COMMON_EXCLUDE_FLAGS) \ + -not -path "$(ROOT_DIR)/**/$(BENCHMARKS_FIXTURES_FOLDER)/*" + +# Define flags for finding benchmark files: +FIND_BENCHMARKS_FLAGS ?= \ + -type f \ + -name "$(BENCHMARKS_PATTERN)" \ + -path "$(ROOT_DIR)/**/$(BENCHMARKS_FOLDER)/**" \ + -regex "$(BENCHMARKS_FILTER)" \ + $(FIND_BENCHMARKS_EXCLUDE_FLAGS) + +ifneq ($(OS), Darwin) + FIND_BENCHMARKS_FLAGS := -regextype posix-extended $(FIND_BENCHMARKS_FLAGS) +endif + +# Define a command to list benchmark files: +FIND_BENCHMARKS_CMD ?= find $(find_kernel_prefix) $(ROOT_DIR) $(FIND_BENCHMARKS_FLAGS) + +# Define exclusion flags to use when searching for examples files: +FIND_EXAMPLES_EXCLUDE_FLAGS ?= \ + $(FIND_COMMON_EXCLUDE_FLAGS) \ + -not -path "$(ROOT_DIR)/**/$(EXAMPLES_FIXTURES_FOLDER)/*" + +# Define flags for finding examples files: +FIND_EXAMPLES_FLAGS ?= \ + -type f \ + -name "$(EXAMPLES_PATTERN)" \ + -path "$(ROOT_DIR)/**/$(EXAMPLES_FOLDER)/**" \ + -regex "$(EXAMPLES_FILTER)" \ + $(FIND_EXAMPLES_EXCLUDE_FLAGS) + +ifneq ($(OS), Darwin) + FIND_EXAMPLES_FLAGS := -regextype posix-extended $(FIND_EXAMPLES_FLAGS) +endif + +# Define a command to list example files: +FIND_EXAMPLES_CMD ?= find $(find_kernel_prefix) $(ROOT_DIR) $(FIND_EXAMPLES_FLAGS) + +# Define exclusion flags to use when searching for test files: +FIND_TESTS_EXCLUDE_FLAGS ?= \ + $(FIND_COMMON_EXCLUDE_FLAGS) \ + -not -path "$(ROOT_DIR)/**/$(TESTS_FIXTURES_FOLDER)/*" + +# Define flags for finding test files: +FIND_TESTS_FLAGS ?= \ + -type f \ + -name "$(TESTS_PATTERN)" \ + -regex "$(TESTS_FILTER)" \ + $(FIND_TESTS_EXCLUDE_FLAGS) + +ifneq ($(OS), Darwin) + FIND_TESTS_FLAGS := -regextype posix-extended $(FIND_TESTS_FLAGS) +endif + +# Define a command to list test files: +FIND_TESTS_CMD ?= find $(find_kernel_prefix) $(ROOT_DIR) $(FIND_TESTS_FLAGS) + + +# RULES # + +#/ +# Default target. +# +# @example +# make +# +# @example +# make all +#/ +all: help + +.PHONY: all + +#/ +# Prints a `Makefile` help message. +# +# @example +# make help +#/ +help: + $(QUIET) echo 'Read the Makefile to see the list of available commands.' + $(QUIET) echo '' + +.PHONY: help + +#/ +# Prints the runtime value of a `Makefile` variable. +# +# ## Notes +# +# - The rule uses the following format: +# +# ```bash +# $ make inspect. +# ``` +# +# @example +# make inspect.ROOT_DIR +# +# @example +# make inspect.CC +#/ +inspect.%: + $(QUIET) echo '$*=$($*)' + +#/ +# Runs the project's install sequence. +# +# @example +# make install +#/ +install: + $(NPM) install + +.PHONY: install + +#/ +# Removes node module dependencies. +# +# @example +# make clean-node +#/ +clean-node: + $(QUIET) $(DELETE) $(DELETE_FLAGS) $(NODE_MODULES) + +#/ +# Runs the project's cleanup sequence. +# +# @example +# make clean +#/ +clean: clean-node clean-cov + $(QUIET) $(DELETE) $(DELETE_FLAGS) $(BUILD_DIR) + $(QUIET) $(DELETE) $(DELETE_FLAGS) $(REPORTS_DIR) + +.PHONY: clean + +#/ +# Runs JavaScript benchmarks consecutively. +# +# ## Notes +# +# - The recipe assumes that benchmark files can be run via Node.js. +# - This rule is useful when wanting to glob for JavaScript benchmark files (e.g., run all JavaScript benchmarks for a particular package). +# +# +# @param {string} [BENCHMARKS_FILTER] - file path pattern (e.g., `.*/utils/group-by/.*`) +# +# @example +# make benchmark +# +# @example +# make benchmark BENCHMARKS_FILTER=".*/utils/group-by/.*" +#/ +benchmark: $(NODE_MODULES) + $(QUIET) $(FIND_BENCHMARKS_CMD) | grep '^[\/]\|^[a-zA-Z]:[/\]' | while read -r file; do \ + echo ""; \ + echo "Running benchmark: $$file"; \ + NODE_ENV="$(NODE_ENV_BENCHMARK)" \ + NODE_PATH="$(NODE_PATH)" \ + $(NODE) $$file || exit 1; \ + done + +.PHONY: benchmark + +#/ +# Runs JavaScript examples consecutively. +# +# ## Notes +# +# - This rule is useful when wanting to glob for JavaScript examples files (e.g., run all JavaScript examples for a particular package). +# - This rule **assumes** that examples files can be run using Node.js. +# +# +# @param {string} [EXAMPLES_FILTER] - file path pattern (e.g., `.*/math/base/special/abs/.*`) +# +# @example +# make examples +# +# @example +# make examples EXAMPLES_FILTER=".*/strided/common/.*" +#/ +examples: $(NODE_MODULES) + $(QUIET) $(FIND_EXAMPLES_CMD) | grep '^[\/]\|^[a-zA-Z]:[/\]' | while read -r file; do \ + echo ""; \ + echo "Running example: $$file"; \ + NODE_ENV="$(NODE_ENV_EXAMPLES)" \ + NODE_PATH="$(NODE_PATH)" \ + $(NODE) $$file || exit 1; \ + done + +.PHONY: examples + +#/ +# Runs JavaScript tests consecutively. +# +# ## Notes +# +# - This rule is useful when wanting to glob for JavaScript test files (e.g., run all JavaScript tests for a particular package). +# - This rule **assumes** that test files can be run using Node.js. +# +# +# @param {string} [TEST_FILTER] - file path pattern (e.g., `.*/math/base/special/abs/.*`) +# +# @example +# make test +# +# @example +# make test TESTS_FILTER=".*/strided/common/.*" +#/ +test: $(NODE_MODULES) + $(QUIET) $(FIND_TESTS_CMD) | grep '^[\/]\|^[a-zA-Z]:[/\]' | while read -r test; do \ + echo ''; \ + echo "Running test: $$test"; \ + NODE_ENV="$(NODE_ENV_TEST)" \ + NODE_PATH="$(NODE_PATH)" \ + $(JAVASCRIPT_TEST) \ + $(JAVASCRIPT_TEST_FLAGS) \ + $$test \ + | $(TAP_REPORTER) || exit 1; \ + done + +.PHONY: test + +#/ +# Runs unit tests and generate a test coverage report. +# +# @example +# make test-cov +#/ +test-cov: clean-cov + $(QUIET) NODE_ENV="$(NODE_ENV_TEST)" \ + NODE_PATH="$(NODE_PATH)" \ + $(ISTANBUL_COVER) $(ISTANBUL_COVER_FLAGS) $(JAVASCRIPT_TEST) -- $$( $(FIND_TESTS_CMD) ) + +.PHONY: test-cov + +#/ +# Removes a test coverage directory. +# +# @example +# make clean-cov +#/ +clean-cov: + $(QUIET) $(DELETE) $(DELETE_FLAGS) $(COVERAGE_DIR) diff --git a/NOTICE b/NOTICE new file mode 100644 index 0000000..f5374f6 --- /dev/null +++ b/NOTICE @@ -0,0 +1 @@ +Copyright (c) 2016-2021 The Stdlib Authors. diff --git a/README.md b/README.md new file mode 100644 index 0000000..e3a8ce0 --- /dev/null +++ b/README.md @@ -0,0 +1,281 @@ + + +# Filled Array + +[![NPM version][npm-image]][npm-url] [![Build Status][test-image]][test-url] [![Coverage Status][coverage-image]][coverage-url] [![dependencies][dependencies-image]][dependencies-url] + +> Create a filled array. + + + +
+ +
+ + + + + +
+ +## Installation + +```bash +npm install @stdlib/array-filled +``` + +
+ +
+ +## Usage + +```javascript +var filledarray = require( '@stdlib/array-filled' ); +``` + +#### filledarray( \[dtype] ) + +Creates a filled array having a specified data type `dtype`. + +```javascript +var arr = filledarray(); +// returns +``` + +The function recognizes the following data types: + +- `float64`: double-precision floating-point numbers (IEEE 754) +- `float32`: single-precision floating-point numbers (IEEE 754) +- `int32`: 32-bit two's complement signed integers +- `uint32`: 32-bit unsigned integers +- `int16`: 16-bit two's complement signed integers +- `uint16`: 16-bit unsigned integers +- `int8`: 8-bit two's complement signed integers +- `uint8`: 8-bit unsigned integers +- `uint8c`: 8-bit unsigned integers clamped to `0-255` +- `generic`: generic JavaScript values + +By default, the output array data type is `float64` (i.e., a [typed array][mdn-typed-array]). To specify an alternative data type, provide a `dtype` argument. + +```javascript +var arr = filledarray( 'int32' ); +// returns +``` + +#### filledarray( value, length\[, dtype] ) + +Returns a filled array having a specified `length`. + +```javascript +var arr1 = filledarray( 1.0, 5 ); +// returns [ 1.0, 1.0, 1.0, 1.0, 1.0 ] + +var arr2 = filledarray( 1, 5, 'uint8' ); +// returns [ 1, 1, 1, 1, 1 ] +``` + +#### filledarray( value, array\[, dtype] ) + +Creates a filled array from another array (or array-like object). + +```javascript +var arr0 = { + '0': 0.5, + '1': 0.5, + '2': 0.5, + 'length': 3 +}; + +var arr1 = filledarray( 1.0, arr0 ); +// returns [ 1.0, 1.0, 1.0 ] + +var arr2 = filledarray( 2.0, arr1 ); +// returns [ 2.0, 2.0, 2.0 ] + +var arr3 = filledarray( 3, arr1, 'int32' ); +// returns [ 3, 3, 3 ] +``` + +#### filledarray( value, iterable\[, dtype] ) + +Creates a filled array from an iterable. + +```javascript +var iterConstant = require( '@stdlib/iter-constant' ); + +var it = iterConstant( 3.0, { + 'iter': 3 +}); +var arr1 = filledarray( 1.0, it ); +// returns [ 1.0, 1.0, 1.0 ] + +var arr2 = filledarray( 1.0, it, 'float32' ); +// returns [ 1.0, 1.0, 1.0 ] +``` + +#### filledarray( value, buffer\[, byteOffset\[, length]]\[, dtype] ) + +Returns a filled [typed array][mdn-typed-array] view of an [`ArrayBuffer`][mdn-arraybuffer]. + +```javascript +var ArrayBuffer = require( '@stdlib/array-buffer' ); + +var buf = new ArrayBuffer( 32 ); +var arr = filledarray( 1.0, buf ); +// returns [ 1.0, 1.0, 1.0, 1.0 ] + +buf = new ArrayBuffer( 32 ); +arr = filledarray( 1.0, buf, 'float32' ); +// returns [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] + +buf = new ArrayBuffer( 32 ); +arr = filledarray( 1.0, buf, 16 ); +// returns [ 1.0, 1.0 ] + +buf = new ArrayBuffer( 32 ); +arr = filledarray( 1.0, buf, 16, 'float32' ); +// returns [ 1.0, 1.0, 1.0, 1.0 ] + +buf = new ArrayBuffer( 32 ); +arr = filledarray( 1.0, buf, 16, 1 ); +// returns [ 1.0 ] + +buf = new ArrayBuffer( 32 ); +arr = filledarray( 1, buf, 10, 4, 'int16' ); +// returns [ 1, 1, 1, 1 ] +``` + +
+ + + + + +
+ +## Notes + +- Creating a generic [array][mdn-array] from an [`ArrayBuffer`][mdn-arraybuffer] is **not** supported. + +
+ + + + + +
+ +## Examples + + + +```javascript +var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); +var dtypes = require( '@stdlib/array-dtypes' ); +var filledarray = require( '@stdlib/array-filled' ); + +// Generate a random number: +var r = discreteUniform( 0, 100 ); + +// Get the list of supported array data types: +var dt = dtypes(); + +// Generate filled arrays... +var arr; +var i; +for ( i = 0; i < dt.length; i++ ) { + arr = filledarray( r, 10, dt[ i ] ); + console.log( arr ); +} +``` + +
+ + + + + +
+ +
+ + + + + + +
+ +* * * + +## 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. + +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]. + +--- + +## License + +See [LICENSE][stdlib-license]. + + +## Copyright + +Copyright © 2016-2021. The Stdlib [Authors][stdlib-authors]. + +
+ + + + + + + + diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js new file mode 100644 index 0000000..a816ff2 --- /dev/null +++ b/benchmark/benchmark.js @@ -0,0 +1,228 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2020 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF 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 isTypedArray = require( '@stdlib/assert-is-typed-array' ); +var isArray = require( '@stdlib/assert-is-array' ); +var pkg = require( './../package.json' ).name; +var filledarray = require( './../lib' ); + + +// MAIN // + +bench( pkg, function benchmark( b ) { + var arr; + var i; + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + arr = filledarray( 0.0, 0 ); + if ( arr.length !== 0 ) { + b.fail( 'should have length 0' ); + } + } + b.toc(); + if ( !isTypedArray( arr ) ) { + b.fail( 'should return a typed array' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); + +bench( pkg+':dtype=float64', function benchmark( b ) { + var arr; + var i; + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + arr = filledarray( 0.0, 0, 'float64' ); + if ( arr.length !== 0 ) { + b.fail( 'should have length 0' ); + } + } + b.toc(); + if ( !isTypedArray( arr ) ) { + b.fail( 'should return a typed array' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); + +bench( pkg+':dtype=float32', function benchmark( b ) { + var arr; + var i; + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + arr = filledarray( 0.0, 0, 'float32' ); + if ( arr.length !== 0 ) { + b.fail( 'should have length 0' ); + } + } + b.toc(); + if ( !isTypedArray( arr ) ) { + b.fail( 'should return a typed array' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); + +bench( pkg+':dtype=int32', function benchmark( b ) { + var arr; + var i; + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + arr = filledarray( 0, 0, 'int32' ); + if ( arr.length !== 0 ) { + b.fail( 'should have length 0' ); + } + } + b.toc(); + if ( !isTypedArray( arr ) ) { + b.fail( 'should return a typed array' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); + +bench( pkg+':dtype=uint32', function benchmark( b ) { + var arr; + var i; + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + arr = filledarray( 0, 0, 'uint32' ); + if ( arr.length !== 0 ) { + b.fail( 'should have length 0' ); + } + } + b.toc(); + if ( !isTypedArray( arr ) ) { + b.fail( 'should return a typed array' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); + +bench( pkg+':dtype=int16', function benchmark( b ) { + var arr; + var i; + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + arr = filledarray( 0, 0, 'int16' ); + if ( arr.length !== 0 ) { + b.fail( 'should have length 0' ); + } + } + b.toc(); + if ( !isTypedArray( arr ) ) { + b.fail( 'should return a typed array' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); + +bench( pkg+':dtype=uint16', function benchmark( b ) { + var arr; + var i; + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + arr = filledarray( 0, 0, 'uint16' ); + if ( arr.length !== 0 ) { + b.fail( 'should have length 0' ); + } + } + b.toc(); + if ( !isTypedArray( arr ) ) { + b.fail( 'should return a typed array' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); + +bench( pkg+':dtype=int8', function benchmark( b ) { + var arr; + var i; + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + arr = filledarray( 0, 0, 'int8' ); + if ( arr.length !== 0 ) { + b.fail( 'should have length 0' ); + } + } + b.toc(); + if ( !isTypedArray( arr ) ) { + b.fail( 'should return a typed array' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); + +bench( pkg+':dtype=uint8', function benchmark( b ) { + var arr; + var i; + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + arr = filledarray( 0, 0, 'uint8' ); + if ( arr.length !== 0 ) { + b.fail( 'should have length 0' ); + } + } + b.toc(); + if ( !isTypedArray( arr ) ) { + b.fail( 'should return a typed array' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); + +bench( pkg+':dtype=uint8c', function benchmark( b ) { + var arr; + var i; + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + arr = filledarray( 0, 0, 'uint8c' ); + if ( arr.length !== 0 ) { + b.fail( 'should have length 0' ); + } + } + b.toc(); + if ( !isTypedArray( arr ) ) { + b.fail( 'should return a typed array' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); + +bench( pkg+':dtype=generic', function benchmark( b ) { + var arr; + var i; + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + arr = filledarray( 0, 0, 'generic' ); + if ( arr.length !== 0 ) { + b.fail( 'should have length 0' ); + } + } + b.toc(); + if ( !isArray( arr ) ) { + b.fail( 'should return an array' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); diff --git a/benchmark/benchmark.length.float32.js b/benchmark/benchmark.length.float32.js new file mode 100644 index 0000000..5626bc0 --- /dev/null +++ b/benchmark/benchmark.length.float32.js @@ -0,0 +1,93 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2020 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF 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 isTypedArray = require( '@stdlib/assert-is-typed-array' ); +var pkg = require( './../package.json' ).name; +var filledarray = require( './../lib' ); + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - array length +* @returns {Function} benchmark function +*/ +function createBenchmark( len ) { + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var arr; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + arr = filledarray( 1.0, len, 'float32' ); + if ( arr.length !== len ) { + b.fail( 'unexpected length' ); + } + } + b.toc(); + if ( !isTypedArray( arr ) ) { + b.fail( 'should return a typed array' ); + } + b.pass( 'benchmark finished' ); + 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+':dtype=float32,len='+len, f ); + } +} + +main(); diff --git a/benchmark/benchmark.length.float64.js b/benchmark/benchmark.length.float64.js new file mode 100644 index 0000000..8f2651f --- /dev/null +++ b/benchmark/benchmark.length.float64.js @@ -0,0 +1,93 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2020 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF 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 isTypedArray = require( '@stdlib/assert-is-typed-array' ); +var pkg = require( './../package.json' ).name; +var filledarray = require( './../lib' ); + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - array length +* @returns {Function} benchmark function +*/ +function createBenchmark( len ) { + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var arr; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + arr = filledarray( 1.0, len, 'float64' ); + if ( arr.length !== len ) { + b.fail( 'unexpected length' ); + } + } + b.toc(); + if ( !isTypedArray( arr ) ) { + b.fail( 'should return a typed array' ); + } + b.pass( 'benchmark finished' ); + 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+':dtype=float64,len='+len, f ); + } +} + +main(); diff --git a/benchmark/benchmark.length.generic.js b/benchmark/benchmark.length.generic.js new file mode 100644 index 0000000..bc1c4ac --- /dev/null +++ b/benchmark/benchmark.length.generic.js @@ -0,0 +1,93 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2020 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF 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 isArray = require( '@stdlib/assert-is-array' ); +var pkg = require( './../package.json' ).name; +var filledarray = require( './../lib' ); + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - array length +* @returns {Function} benchmark function +*/ +function createBenchmark( len ) { + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var arr; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + arr = filledarray( 1.0, len, 'generic' ); + if ( arr.length !== len ) { + b.fail( 'unexpected length' ); + } + } + b.toc(); + if ( !isArray( arr ) ) { + b.fail( 'should return a typed array' ); + } + b.pass( 'benchmark finished' ); + 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+':dtype=generic,len='+len, f ); + } +} + +main(); diff --git a/benchmark/benchmark.length.int16.js b/benchmark/benchmark.length.int16.js new file mode 100644 index 0000000..e271641 --- /dev/null +++ b/benchmark/benchmark.length.int16.js @@ -0,0 +1,93 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2020 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF 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 isTypedArray = require( '@stdlib/assert-is-typed-array' ); +var pkg = require( './../package.json' ).name; +var filledarray = require( './../lib' ); + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - array length +* @returns {Function} benchmark function +*/ +function createBenchmark( len ) { + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var arr; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + arr = filledarray( 1, len, 'int16' ); + if ( arr.length !== len ) { + b.fail( 'unexpected length' ); + } + } + b.toc(); + if ( !isTypedArray( arr ) ) { + b.fail( 'should return a typed array' ); + } + b.pass( 'benchmark finished' ); + 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+':dtype=int16,len='+len, f ); + } +} + +main(); diff --git a/benchmark/benchmark.length.int32.js b/benchmark/benchmark.length.int32.js new file mode 100644 index 0000000..4106e59 --- /dev/null +++ b/benchmark/benchmark.length.int32.js @@ -0,0 +1,93 @@ +/** +* @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 isTypedArray = require( '@stdlib/assert-is-typed-array' ); +var pkg = require( './../package.json' ).name; +var filledarray = require( './../lib' ); + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - array length +* @returns {Function} benchmark function +*/ +function createBenchmark( len ) { + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var arr; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + arr = filledarray( 1, len, 'int32' ); + if ( arr.length !== len ) { + b.fail( 'unexpected length' ); + } + } + b.toc(); + if ( !isTypedArray( arr ) ) { + b.fail( 'should return a typed array' ); + } + b.pass( 'benchmark finished' ); + 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+':dtype=int32,len='+len, f ); + } +} + +main(); diff --git a/benchmark/benchmark.length.int8.js b/benchmark/benchmark.length.int8.js new file mode 100644 index 0000000..4335be8 --- /dev/null +++ b/benchmark/benchmark.length.int8.js @@ -0,0 +1,93 @@ +/** +* @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 isTypedArray = require( '@stdlib/assert-is-typed-array' ); +var pkg = require( './../package.json' ).name; +var filledarray = require( './../lib' ); + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - array length +* @returns {Function} benchmark function +*/ +function createBenchmark( len ) { + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var arr; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + arr = filledarray( 1, len, 'int8' ); + if ( arr.length !== len ) { + b.fail( 'unexpected length' ); + } + } + b.toc(); + if ( !isTypedArray( arr ) ) { + b.fail( 'should return a typed array' ); + } + b.pass( 'benchmark finished' ); + 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+':dtype=int8,len='+len, f ); + } +} + +main(); diff --git a/benchmark/benchmark.length.uint16.js b/benchmark/benchmark.length.uint16.js new file mode 100644 index 0000000..d17e7ab --- /dev/null +++ b/benchmark/benchmark.length.uint16.js @@ -0,0 +1,93 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2020 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF 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 isTypedArray = require( '@stdlib/assert-is-typed-array' ); +var pkg = require( './../package.json' ).name; +var filledarray = require( './../lib' ); + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - array length +* @returns {Function} benchmark function +*/ +function createBenchmark( len ) { + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var arr; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + arr = filledarray( 1, len, 'uint16' ); + if ( arr.length !== len ) { + b.fail( 'unexpected length' ); + } + } + b.toc(); + if ( !isTypedArray( arr ) ) { + b.fail( 'should return a typed array' ); + } + b.pass( 'benchmark finished' ); + 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+':dtype=uint16,len='+len, f ); + } +} + +main(); diff --git a/benchmark/benchmark.length.uint32.js b/benchmark/benchmark.length.uint32.js new file mode 100644 index 0000000..667cf11 --- /dev/null +++ b/benchmark/benchmark.length.uint32.js @@ -0,0 +1,93 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2020 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF 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 isTypedArray = require( '@stdlib/assert-is-typed-array' ); +var pkg = require( './../package.json' ).name; +var filledarray = require( './../lib' ); + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - array length +* @returns {Function} benchmark function +*/ +function createBenchmark( len ) { + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var arr; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + arr = filledarray( 1, len, 'uint32' ); + if ( arr.length !== len ) { + b.fail( 'unexpected length' ); + } + } + b.toc(); + if ( !isTypedArray( arr ) ) { + b.fail( 'should return a typed array' ); + } + b.pass( 'benchmark finished' ); + 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+':dtype=uint32,len='+len, f ); + } +} + +main(); diff --git a/benchmark/benchmark.length.uint8.js b/benchmark/benchmark.length.uint8.js new file mode 100644 index 0000000..a06f397 --- /dev/null +++ b/benchmark/benchmark.length.uint8.js @@ -0,0 +1,93 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2020 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF 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 isTypedArray = require( '@stdlib/assert-is-typed-array' ); +var pkg = require( './../package.json' ).name; +var filledarray = require( './../lib' ); + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - array length +* @returns {Function} benchmark function +*/ +function createBenchmark( len ) { + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var arr; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + arr = filledarray( 1, len, 'uint8' ); + if ( arr.length !== len ) { + b.fail( 'unexpected length' ); + } + } + b.toc(); + if ( !isTypedArray( arr ) ) { + b.fail( 'should return a typed array' ); + } + b.pass( 'benchmark finished' ); + 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+':dtype=uint8,len='+len, f ); + } +} + +main(); diff --git a/benchmark/benchmark.length.uint8c.js b/benchmark/benchmark.length.uint8c.js new file mode 100644 index 0000000..083e121 --- /dev/null +++ b/benchmark/benchmark.length.uint8c.js @@ -0,0 +1,93 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2020 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF 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 isTypedArray = require( '@stdlib/assert-is-typed-array' ); +var pkg = require( './../package.json' ).name; +var filledarray = require( './../lib' ); + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - array length +* @returns {Function} benchmark function +*/ +function createBenchmark( len ) { + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var arr; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + arr = filledarray( 1, len, 'uint8c' ); + if ( arr.length !== len ) { + b.fail( 'unexpected length' ); + } + } + b.toc(); + if ( !isTypedArray( arr ) ) { + b.fail( 'should return a typed array' ); + } + b.pass( 'benchmark finished' ); + 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+':dtype=uint8c,len='+len, f ); + } +} + +main(); diff --git a/docs/repl.txt b/docs/repl.txt new file mode 100644 index 0000000..cca6173 --- /dev/null +++ b/docs/repl.txt @@ -0,0 +1,155 @@ + +{{alias}}( [dtype] ) + Creates a filled array. + + The function supports the following data types: + + - float64: double-precision floating-point numbers (IEEE 754) + - float32: single-precision floating-point numbers (IEEE 754) + - int32: 32-bit two's complement signed integers + - uint32: 32-bit unsigned integers + - int16: 16-bit two's complement signed integers + - uint16: 16-bit unsigned integers + - int8: 8-bit two's complement signed integers + - uint8: 8-bit unsigned integers + - uint8c: 8-bit unsigned integers clamped to 0-255 + - generic: generic JavaScript values + + The default array data type is `float64`. + + Parameters + ---------- + dtype: string (optional) + Data type. Default: 'float64'. + + Returns + ------- + out: TypedArray|Array + Output array. + + Examples + -------- + > var arr = {{alias}}() + + > arr = {{alias}}( 'float32' ) + + + +{{alias}}( value, length[, dtype] ) + Returns a filled array having a specified length. + + Parameters + ---------- + value: any + Fill value. + + length: integer + Array length. + + dtype: string (optional) + Data type. Default: 'float64'. + + Returns + ------- + out: TypedArray|Array + Output array. + + Examples + -------- + > var arr = {{alias}}( 1.0, 5 ) + [ 1.0, 1.0, 1.0, 1.0, 1.0 ] + > arr = {{alias}}( 1, 5, 'int32' ) + [ 1, 1, 1, 1, 1 ] + + +{{alias}}( value, array[, dtype] ) + Creates a filled array from another array (or array-like object). + + Parameters + ---------- + value: any + Fill value. + + array: ArrayLikeObject + Array from which to generate another array. + + dtype: string (optional) + Data type. Default: 'float64'. + + Returns + ------- + out: TypedArray|Array + Output array. + + Examples + -------- + > var arr1 = {{alias}}( 2.0, [ 0.5, 0.5, 0.5 ] ) + [ 2.0, 2.0, 2.0 ] + > var arr2 = {{alias}}( 1.0, arr1, 'float32' ) + [ 1.0, 1.0, 1.0 ] + + +{{alias}}( value, iterable[, dtype] ) + Creates a filled array from an iterable. + + Parameters + ---------- + value: any + Fill value. + + iterable: Object + Iterable from which to generate an array. + + dtype: string (optional) + Data type. Default: 'float64'. + + Returns + ------- + out: TypedArray|Array + Output array. + + Examples + -------- + > var arr1 = {{alias:@stdlib/iter/constant}}( 3.0, {'iter': 3} ); + > var arr2 = {{alias}}( 1.0, arr1, 'float32' ) + [ 1.0, 1.0, 1.0 ] + + +{{alias}}( value, buffer[, byteOffset[, length]][, dtype] ) + Returns a filled typed array view of an ArrayBuffer. + + The 'generic' array data type is *not* supported. + + Parameters + ---------- + value: any + Fill value. + + buffer: ArrayBuffer + Underlying ArrayBuffer. + + byteOffset: integer (optional) + Integer byte offset specifying the location of the first typed array + element. Default: 0. + + length: integer (optional) + View length. If not provided, the view spans from the byteOffset to + the end of the underlying ArrayBuffer. + + dtype: string (optional) + Data type. Default: 'float64'. + + Returns + ------- + out: TypedArray + A typed array. + + Examples + -------- + > var buf = new {{alias:@stdlib/array/buffer}}( 16 ); + > var arr = {{alias}}( 1.0, buf, 0, 4, 'float32' ) + [ 1.0, 1.0, 1.0, 1.0 ] + + See Also + -------- + diff --git a/docs/types/index.d.ts b/docs/types/index.d.ts new file mode 100644 index 0000000..d57f999 --- /dev/null +++ b/docs/types/index.d.ts @@ -0,0 +1,225 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2020 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT 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 + +/// + +import { TypedArray } from '@stdlib/types/array'; +import { Collection } from '@stdlib/types/object'; +import { IterableIterator } from '@stdlib/types/iter'; + +/** +* Array or typed array. +*/ +type ArrayOrTypedArray = Array | TypedArray; + +/** +* Creates a filled array. +* +* The function recognizes the following data types: +* +* - `float64`: double-precision floating-point numbers (IEEE 754) +* - `float32`: single-precision floating-point numbers (IEEE 754) +* - `int32`: 32-bit two's complement signed integers +* - `uint32`: 32-bit unsigned integers +* - `int16`: 16-bit two's complement signed integers +* - `uint16`: 16-bit unsigned integers +* - `int8`: 8-bit two's complement signed integers +* - `uint8`: 8-bit unsigned integers +* - `uint8c`: 8-bit unsigned integers clamped to `0-255` +* - `generic`: generic JavaScript values +* +* @param dtype - data type (default: 'float64') +* @throws must provide a recognized data type +* @returns filled array +* +* @example +* var arr = filledarray(); +* // returns +* +* @example +* var arr = filledarray( 'float32' ); +* // returns +*/ +declare function filledarray( dtype?: string ): ArrayOrTypedArray; + +/** +* Creates a filled array having a specified `length`. +* +* @param value - fill value +* @param length - array length +* @param dtype - data type (default: 'float64') +* @throws must provide a recognized data type +* @returns filled array +* +* @example +* var arr = filledarray( 1.0, 5 ); +* // returns [ 0.0, 0.0, 0.0, 0.0, 0.0 ] +* +* @example +* var arr = filledarray( 1.0, 5, 'float32' ); +* // returns [ 0.0, 0.0, 0.0, 0.0, 0.0 ] +*/ +declare function filledarray( value: any, length: number, dtype?: string ): ArrayOrTypedArray; // tslint:disable-line:max-line-length + +/** +* Creates a filled array from another `array`. +* +* @param value - fill value +* @param array - typed array or array-like object +* @param dtype - data type (default: 'float64') +* @throws must provide a recognized data type +* @returns filled array +* +* @example +* var arr = filledarray( 1.0, [ 5.0, -3.0, 2.0 ] ); +* // returns [ 1.0, 1.0, 1.0 ] +* +* @example +* var arr = filledarray( 1.0, [ 5.0, -3.0, 2.0 ], 'float32' ); +* // returns [ 1.0, 1.0, 1.0 ] +*/ +declare function filledarray( value: any, array: Collection, dtype?: string ): ArrayOrTypedArray; // tslint:disable-line:max-line-length unified-signatures + +/** +* Creates a filled array from an iterable. +* +* @param value - fill value +* @param iterable - iterable +* @param dtype - data type (default: 'float64') +* @throws must provide a recognized data type +* @returns filled array +* +* @example +* var iterConstant = require( `@stdlib/iter/constant` ); +* +* var it = iterConstant( 3.0, { +* 'iter': 3 +* }); +* var arr = filledarray( 1.0, it ); +* // returns [ 1.0, 1.0, 1.0 ] +* +* @example +* var iterConstant = require( `@stdlib/iter/constant` ); +* +* var it = iterConstant( 3.0, { +* 'iter': 3 +* }); +* var arr = filledarray( 1.0, it, 'float32' ); +* // returns [ 1.0, 1.0, 1.0 ] +*/ +declare function filledarray( value: any, iterable: IterableIterator, dtype?: string ): ArrayOrTypedArray; // tslint:disable-line:max-line-length unified-signatures + +/** +* Returns a filled typed array view of an `ArrayBuffer`. +* +* ## Notes +* +* - Creating a generic array from an `ArrayBuffer` is **not** supported. +* +* @param value - fill value +* @param buffer - `ArrayBuffer` +* @param byteOffset - byte offset +* @param length - view length +* @param dtype - data type (default: 'float64') +* @throws must provide a recognized data type +* @returns filled array +* +* @example +* var ArrayBuffer = require( `@stdlib/array/buffer` ); +* +* var buf = new ArrayBuffer( 32 ); +* var arr = filledarray( 1.0, buf, 8, 2 ); +* // returns [ 1.0, 1.0 ] +* +* @example +* var ArrayBuffer = require( `@stdlib/array/buffer` ); +* +* var buf = new ArrayBuffer( 32 ); +* var arr = filledarray( 1.0, buf, 8, 2, 'float32' ); +* // returns [ 1.0, 1.0 ] +* +*/ +declare function filledarray( value: any, buffer: ArrayBuffer, byteOffset: number, length: number, dtype?: string ): TypedArray; // tslint:disable-line:max-line-length + +/** +* Returns a filled typed array view of an `ArrayBuffer`. +* +* ## Notes +* +* - Creating a generic array from an `ArrayBuffer` is **not** supported. +* +* @param value - fill value +* @param buffer - `ArrayBuffer` +* @param byteOffset - byte offset +* @param dtype - data type (default: 'float64') +* @throws must provide a recognized data type +* @returns filled array +* +* @example +* var ArrayBuffer = require( `@stdlib/array/buffer` ); +* +* var buf = new ArrayBuffer( 32 ); +* var arr = filledarray( 1.0, buf, 8 ); +* // returns [ 1.0, 1.0, 1.0 ] +* +* @example +* var ArrayBuffer = require( `@stdlib/array/buffer` ); +* +* var buf = new ArrayBuffer( 32 ); +* var arr = filledarray( 1.0, buf, 8, 'float32' ); +* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] +* +*/ +declare function filledarray( value: any, buffer: ArrayBuffer, byteOffset: number, dtype?: string ): TypedArray; // tslint:disable-line:max-line-length + +/** +* Returns a filled typed array view of an `ArrayBuffer`. +* +* ## Notes +* +* - Creating a generic array from an `ArrayBuffer` is **not** supported. +* +* @param value - fill value +* @param buffer - `ArrayBuffer` +* @param dtype - data type (default: 'float64') +* @throws must provide a recognized data type +* @returns filled array +* +* @example +* var ArrayBuffer = require( `@stdlib/array/buffer` ); +* +* var buf = new ArrayBuffer( 32 ); +* var arr = filledarray( 1.0, buf ); +* // returns [ 1.0, 1.0, 1.0, 1.0 ] +* +* @example +* var ArrayBuffer = require( `@stdlib/array/buffer` ); +* +* var buf = new ArrayBuffer( 32 ); +* var arr = filledarray( 1.0, buf, 'float32' ); +* // returns [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] +* +*/ +declare function filledarray( value: any, buffer: ArrayBuffer, dtype?: string ): TypedArray; // tslint:disable-line:max-line-length unified-signatures + + +// EXPORTS // + +export = filledarray; diff --git a/docs/types/test.ts b/docs/types/test.ts new file mode 100644 index 0000000..2371173 --- /dev/null +++ b/docs/types/test.ts @@ -0,0 +1,206 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2020 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT 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 { IterableIterator } from '@stdlib/types/iter'; +import filledarray = require( './index' ); + + +/** +* Returns an iterator protocol-compliant object. +* +* @returns iterator protocol-compliant object +*/ +function iterator(): IterableIterator { + const obj: IterableIterator = { + [Symbol.iterator]: iterator, + 'next': next + }; + return obj; +} + +/** +* Implements the iterator protocol `next` method. +* +* @returns iterator protocol-compliant object +*/ +function next(): any { + return { + 'value': 1.0, + 'done': false + }; +} + + +// TESTS // + +// The function returns an array or typed array... +{ + filledarray(); // $ExpectType ArrayOrTypedArray + filledarray( 'float32' ); // $ExpectType ArrayOrTypedArray + + filledarray( 1.0, 10 ); // $ExpectType ArrayOrTypedArray + filledarray( 1.0, 10, 'int32' ); // $ExpectType ArrayOrTypedArray + + const x = new Float64Array( 10 ); + filledarray( 1.0, x ); // $ExpectType ArrayOrTypedArray + filledarray( 1.0, x, 'uint8' ); // $ExpectType ArrayOrTypedArray + + const y = [ 2.0, 2.0, 2.0 ]; + filledarray( 1.0, y ); // $ExpectType ArrayOrTypedArray + filledarray( 1.0, y, 'float64' ); // $ExpectType ArrayOrTypedArray + + const it = iterator(); + filledarray( 1.0, it ); // $ExpectType ArrayOrTypedArray + filledarray( 1.0, it, 'uint8c' ); // $ExpectType ArrayOrTypedArray + + const buf = new ArrayBuffer( 32 ); + filledarray( 1.0, buf ); // $ExpectType TypedArray + filledarray( 1.0, buf, 'uint32' ); // $ExpectType TypedArray + + filledarray( 1.0, buf, 8 ); // $ExpectType TypedArray + filledarray( 1.0, buf, 8, 'uint16' ); // $ExpectType TypedArray + + filledarray( 1.0, buf, 8, 2 ); // $ExpectType TypedArray + filledarray( 1.0, buf, 8, 2, 'int16' ); // $ExpectType TypedArray +} + +// The compiler throws an error if the function is not provided a valid length, typed array, array-like object, or `ArrayBuffer` argument... +{ + filledarray( 1.0, false ); // $ExpectError + filledarray( 1.0, true ); // $ExpectError + filledarray( 1.0, null ); // $ExpectError + filledarray( 1.0, {} ); // $ExpectError + + filledarray( 1.0, false, 'float64' ); // $ExpectError + filledarray( 1.0, true, 'float64' ); // $ExpectError + filledarray( 1.0, null, 'float64' ); // $ExpectError + filledarray( 1.0, undefined, 'float64' ); // $ExpectError + filledarray( 1.0, {}, 'float64' ); // $ExpectError + + filledarray( 1.0, '5', 8 ); // $ExpectError + filledarray( 1.0, 1.0, 8 ); // $ExpectError + filledarray( 1.0, false, 8 ); // $ExpectError + filledarray( 1.0, true, 8 ); // $ExpectError + filledarray( 1.0, null, 8 ); // $ExpectError + filledarray( 1.0, undefined, 8 ); // $ExpectError + filledarray( 1.0, [], 8 ); // $ExpectError + filledarray( 1.0, {}, 8 ); // $ExpectError + filledarray( 1.0, ( x: number ): number => x, 8 ); // $ExpectError + + filledarray( 1.0, '5', 8, 'float64' ); // $ExpectError + filledarray( 1.0, 1.0, 8, 'float64' ); // $ExpectError + filledarray( 1.0, false, 8, 'float64' ); // $ExpectError + filledarray( 1.0, true, 8, 'float64' ); // $ExpectError + filledarray( 1.0, null, 8, 'float64' ); // $ExpectError + filledarray( 1.0, undefined, 8, 'float64' ); // $ExpectError + filledarray( 1.0, [], 8, 'float64' ); // $ExpectError + filledarray( 1.0, {}, 8, 'float64' ); // $ExpectError + filledarray( 1.0, ( x: number ): number => x, 8, 'float64' ); // $ExpectError + + filledarray( 1.0, '5', 8, 2 ); // $ExpectError + filledarray( 1.0, 1.0, 8, 2 ); // $ExpectError + filledarray( 1.0, false, 8, 2 ); // $ExpectError + filledarray( 1.0, true, 8, 2 ); // $ExpectError + filledarray( 1.0, null, 8, 2 ); // $ExpectError + filledarray( 1.0, undefined, 8, 2 ); // $ExpectError + filledarray( 1.0, [], 8, 2 ); // $ExpectError + filledarray( 1.0, {}, 8, 2 ); // $ExpectError + filledarray( 1.0, ( x: number ): number => x, 8, 2 ); // $ExpectError + + filledarray( 1.0, '5', 8, 2, 'float64' ); // $ExpectError + filledarray( 1.0, 1.0, 8, 2, 'float64' ); // $ExpectError + filledarray( 1.0, false, 8, 2, 'float64' ); // $ExpectError + filledarray( 1.0, true, 8, 2, 'float64' ); // $ExpectError + filledarray( 1.0, null, 8, 2, 'float64' ); // $ExpectError + filledarray( 1.0, undefined, 8, 2, 'float64' ); // $ExpectError + filledarray( 1.0, [], 8, 2, 'float64' ); // $ExpectError + filledarray( 1.0, {}, 8, 2, 'float64' ); // $ExpectError + filledarray( 1.0, ( x: number ): number => x, 8, 2, 'float64' ); // $ExpectError +} + +// The compiler throws an error if the function is provided a byte offset argument which is not a number... +{ + const buf = new ArrayBuffer( 32 ); + + filledarray( 1.0, buf, false ); // $ExpectError + filledarray( 1.0, buf, true ); // $ExpectError + filledarray( 1.0, buf, null ); // $ExpectError + filledarray( 1.0, buf, [] ); // $ExpectError + filledarray( 1.0, buf, {} ); // $ExpectError + filledarray( 1.0, buf, ( x: number ): number => x ); // $ExpectError + + filledarray( 1.0, buf, '5', 'float64' ); // $ExpectError + filledarray( 1.0, buf, false, 'float64' ); // $ExpectError + filledarray( 1.0, buf, true, 'float64' ); // $ExpectError + filledarray( 1.0, buf, null, 'float64' ); // $ExpectError + filledarray( 1.0, buf, undefined, 'float64' ); // $ExpectError + filledarray( 1.0, buf, [], 'float64' ); // $ExpectError + filledarray( 1.0, buf, {}, 'float64' ); // $ExpectError + filledarray( 1.0, buf, ( x: number ): number => x, 'float64' ); // $ExpectError +} + +// The compiler throws an error if the function is provided a view length argument which is not a number... +{ + const buf = new ArrayBuffer( 32 ); + + filledarray( 1.0, buf, 8, false ); // $ExpectError + filledarray( 1.0, buf, 8, true ); // $ExpectError + filledarray( 1.0, buf, 8, null ); // $ExpectError + filledarray( 1.0, buf, 8, [] ); // $ExpectError + filledarray( 1.0, buf, 8, {} ); // $ExpectError + filledarray( 1.0, buf, 8, ( x: number ): number => x ); // $ExpectError + + filledarray( 1.0, buf, 8, '5', 'float64' ); // $ExpectError + filledarray( 1.0, buf, 8, false, 'float64' ); // $ExpectError + filledarray( 1.0, buf, 8, true, 'float64' ); // $ExpectError + filledarray( 1.0, buf, 8, null, 'float64' ); // $ExpectError + filledarray( 1.0, buf, 8, undefined, 'float64' ); // $ExpectError + filledarray( 1.0, buf, 8, [], 'float64' ); // $ExpectError + filledarray( 1.0, buf, 8, {}, 'float64' ); // $ExpectError + filledarray( 1.0, buf, 8, ( x: number ): number => x, 'float64' ); // $ExpectError +} + +// The compiler throws an error if the function is not provided a third argument which is a number... +{ + const buf = new ArrayBuffer( 32 ); + + filledarray( 1.0, buf, false ); // $ExpectError + filledarray( 1.0, buf, true ); // $ExpectError + filledarray( 1.0, buf, null ); // $ExpectError + filledarray( 1.0, buf, [] ); // $ExpectError + filledarray( 1.0, buf, {} ); // $ExpectError + filledarray( 1.0, buf, ( x: number ): number => x ); // $ExpectError + + filledarray( 1.0, buf, '5', 'float64' ); // $ExpectError + filledarray( 1.0, buf, false, 'float64' ); // $ExpectError + filledarray( 1.0, buf, true, 'float64' ); // $ExpectError + filledarray( 1.0, buf, null, 'float64' ); // $ExpectError + filledarray( 1.0, buf, undefined, 'float64' ); // $ExpectError + filledarray( 1.0, buf, [], 'float64' ); // $ExpectError + filledarray( 1.0, buf, {}, 'float64' ); // $ExpectError + filledarray( 1.0, buf, ( x: number ): number => x, 'float64' ); // $ExpectError +} + +// The compiler throws an error if the function is provided too many arguments... +{ + const buf = new ArrayBuffer( 32 ); + + filledarray( 1.0, buf, 8, 2, 'float64', 1 ); // $ExpectError +} diff --git a/examples/index.js b/examples/index.js new file mode 100644 index 0000000..967cd90 --- /dev/null +++ b/examples/index.js @@ -0,0 +1,37 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2020 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR 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 discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); +var dtypes = require( '@stdlib/array-dtypes' ); +var filledarray = require( './../lib' ); + +// Generate a random number: +var r = discreteUniform( 0, 100 ); + +// Get the list of supported array data types: +var dt = dtypes(); + +// Generate filled arrays... +var arr; +var i; +for ( i = 0; i < dt.length; i++ ) { + arr = filledarray( r, 10, dt[ i ] ); + console.log( arr ); +} diff --git a/lib/index.js b/lib/index.js new file mode 100644 index 0000000..7796d81 --- /dev/null +++ b/lib/index.js @@ -0,0 +1,132 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2020 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +/** +* Create a filled array. +* +* @module @stdlib/array/filled +* +* @example +* var filledarray = require( '@stdlib/array-filled' ); +* +* var arr = filledarray(); +* // returns +* +* @example +* var filledarray = require( '@stdlib/array-filled' ); +* +* var arr = filledarray( 1.0, 2 ); +* // returns [ 1.0, 1.0 ] +* +* @example +* var filledarray = require( '@stdlib/array-filled' ); +* +* var arr = filledarray( 1.0, 2, 'float32' ); +* // returns [ 1.0, 1.0 ] +* +* @example +* var filledarray = require( '@stdlib/array-filled' ); +* +* var arr = filledarray( 1.0, 2, 'generic' ); +* // returns [ 1.0, 1.0 ] +* +* @example +* var filledarray = require( '@stdlib/array-filled' ); +* +* var arr = filledarray( 1.0, [ 0.5, 0.5 ] ); +* // returns [ 1.0, 1.0 ] +* +* @example +* var filledarray = require( '@stdlib/array-filled' ); +* +* var arr = filledarray( 1, [ 5, -3 ], 'int32' ); +* // returns [ 1, 1 ] +* +* @example +* var filledarray = require( '@stdlib/array-filled' ); +* +* var arr1 = filledarray( 10, [ 5, 3 ], 'int32' ); +* var arr2 = filledarray( 1.0, arr1 ); +* // returns [ 1.0, 1.0 ] +* +* @example +* var filledarray = require( '@stdlib/array-filled' ); +* +* var arr1 = filledarray( 1, [ 5, 3 ], 'int32' ); +* var arr2 = filledarray( 2, arr1, 'uint32' ); +* // returns [ 2, 2 ] +* +* @example +* var ArrayBuffer = require( '@stdlib/array-buffer' ); +* var filledarray = require( '@stdlib/array-filled' ); +* +* var buf = new ArrayBuffer( 16 ); +* var arr = filledarray( 1.0, buf ); +* // returns [ 1.0, 1.0 ] +* +* @example +* var ArrayBuffer = require( '@stdlib/array-buffer' ); +* var filledarray = require( '@stdlib/array-filled' ); +* +* var buf = new ArrayBuffer( 16 ); +* var arr = filledarray( 1.0, buf, 'float32' ); +* // returns [ 1.0, 1.0, 1.0, 1.0 ] +* +* @example +* var ArrayBuffer = require( '@stdlib/array-buffer' ); +* var filledarray = require( '@stdlib/array-filled' ); +* +* var buf = new ArrayBuffer( 16 ); +* var arr = filledarray( 1.0, buf, 8 ); +* // returns [ 1.0 ] +* +* @example +* var ArrayBuffer = require( '@stdlib/array-buffer' ); +* var filledarray = require( '@stdlib/array-filled' ); +* +* var buf = new ArrayBuffer( 16 ); +* var arr = filledarray( 1.0, buf, 8, 'float32' ); +* // returns [ 1.0, 1.0 ] +* +* @example +* var ArrayBuffer = require( '@stdlib/array-buffer' ); +* var filledarray = require( '@stdlib/array-filled' ); +* +* var buf = new ArrayBuffer( 32 ); +* var arr = filledarray( 1.0, buf, 8, 2 ); +* // returns [ 1.0, 1.0 ] +* +* @example +* var ArrayBuffer = require( '@stdlib/array-buffer' ); +* var filledarray = require( '@stdlib/array-filled' ); +* +* var buf = new ArrayBuffer( 32 ); +* var arr = filledarray( 1, buf, 8, 2, 'int32' ); +* // returns [ 1, 1 ] +*/ + +// MODULES // + +var filledarray = require( './main.js' ); + + +// EXPORTS // + +module.exports = filledarray; diff --git a/lib/main.js b/lib/main.js new file mode 100644 index 0000000..7d2b5b0 --- /dev/null +++ b/lib/main.js @@ -0,0 +1,228 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2020 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var isString = require( '@stdlib/assert-is-string' ).isPrimitive; +var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; +var isCollection = require( '@stdlib/assert-is-collection' ); +var isArrayBuffer = require( '@stdlib/assert-is-arraybuffer' ); +var isObject = require( '@stdlib/assert-is-object' ); +var isFunction = require( '@stdlib/assert-is-function' ); +var hasOwnProp = require( '@stdlib/assert-has-own-property' ); +var ctors = require( '@stdlib/array-ctors' ); +var gfill = require( '@stdlib/blas-ext-base-gfill' ); +var hasIteratorSymbolSupport = require( '@stdlib/assert-has-iterator-symbol-support' ); +var ITERATOR_SYMBOL = require( '@stdlib/symbol-iterator' ); + + +// VARIABLES // + +var HAS_ITERATOR_SYMBOL = hasIteratorSymbolSupport(); + + +// MAIN // + +/** +* Creates a filled array. +* +* @param {*} [value] - fill value +* @param {(NonNegativeInteger|TypedArray|ArrayLikeObject|ArrayBuffer)} [arg] - a length, typed array, array-like object, or buffer +* @param {NonNegativeInteger} [byteOffset=0] - byte offset +* @param {NonNegativeInteger} [length] - view length +* @param {string} [dtype="float64"] - data type +* @throws {TypeError} must provide a recognized data type +* @throws {TypeError} must provide a length, typed array, array-like object, or buffer +* @throws {Error} creating a generic array from an `ArrayBuffer` is not supported +* @returns {(TypedArray|Array)} array or typed array +* +* @example +* var arr = filledarray(); +* // returns +* +* @example +* var arr = filledarray( 1.0, 2 ); +* // returns [ 1.0, 1.0 ] +* +* @example +* var arr = filledarray( 1.0, 2, 'float32' ); +* // returns [ 1.0, 1.0 ] +* +* @example +* var arr = filledarray( 1.0, 2, 'generic' ); +* // returns [ 1.0, 1.0 ] +* +* @example +* var arr = filledarray( 1.0, [ 0.5, 0.5 ] ); +* // returns [ 1.0, 1.0 ] +* +* @example +* var arr = filledarray( 1, [ 5, -3 ], 'int32' ); +* // returns [ 1, 1 ] +* +* @example +* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' ); +* var arr2 = filledarray( 1.0, arr1 ); +* // returns [ 1.0, 1.0 ] +* +* @example +* var arr1 = filledarray( 2, [ 5, 3 ], 'int32' ); +* var arr2 = filledarray( 1, arr1, 'uint32' ); +* // returns [ 1, 1 ] +* +* @example +* var ArrayBuffer = require( '@stdlib/array-buffer' ); +* +* var buf = new ArrayBuffer( 16 ); +* var arr = filledarray( 1.0, buf ); +* // returns [ 1.0, 1.0 ] +* +* @example +* var ArrayBuffer = require( '@stdlib/array-buffer' ); +* +* var buf = new ArrayBuffer( 16 ); +* var arr = filledarray( 1.0, buf, 'float32' ); +* // returns [ 1.0, 1.0, 1.0, 1.0 ] +* +* @example +* var ArrayBuffer = require( '@stdlib/array-buffer' ); +* +* var buf = new ArrayBuffer( 16 ); +* var arr = filledarray( 1.0, buf, 8 ); +* // returns [ 1.0 ] +* +* @example +* var ArrayBuffer = require( '@stdlib/array-buffer' ); +* +* var buf = new ArrayBuffer( 16 ); +* var arr = filledarray( 1.0, buf, 8, 'float32' ); +* // returns [ 1.0, 1.0 ] +* +* @example +* var ArrayBuffer = require( '@stdlib/array-buffer' ); +* +* var buf = new ArrayBuffer( 32 ); +* var arr = filledarray( 1.0, buf, 8, 2 ); +* // returns [ 1.0, 1.0 ] +* +* @example +* var ArrayBuffer = require( '@stdlib/array-buffer' ); +* +* var buf = new ArrayBuffer( 32 ); +* var arr = filledarray( 1, buf, 8, 2, 'int32' ); +* // returns [ 1, 1 ] +*/ +function filledarray() { + var value; + var nargs; + var dtype; + var ctor; + var arr; + var len; + var arg; + var v; + var i; + + nargs = arguments.length; + nargs -= 1; + if ( nargs >= 0 && isString( arguments[ nargs ] ) ) { + dtype = arguments[ nargs ]; + nargs -= 1; + } else { + dtype = 'float64'; + } + ctor = ctors( dtype ); + if ( ctor === null ) { + throw new TypeError( 'invalid argument. Must provide a recognized data type. Value: `'+dtype+'`.' ); + } + if ( dtype === 'generic' ) { + if ( nargs <= 0 ) { + return []; + } + value = arguments[ 0 ]; + arg = arguments[ 1 ]; + if ( nargs === 1 ) { + if ( isNonNegativeInteger( arg ) ) { + len = arg; + } else if ( isCollection( arg ) ) { + len = arg.length; + } + if ( len !== void 0 ) { + arr = []; + + // Manually push elements in order to ensure "fast" elements... + for ( i = 0; i < len; i++ ) { + arr.push( value ); + } + return arr; + } + if ( isArrayBuffer( arg ) ) { + throw new Error( 'invalid arguments. Creating a generic array from an ArrayBuffer is not supported.' ); + } + if ( isObject( arg ) ) { + if ( HAS_ITERATOR_SYMBOL === false ) { + throw new TypeError( 'invalid argument. Environment lacks Symbol.iterator support. Must provide a length, typed array, or array-like object. Value: `'+arg+'`.' ); + } + if ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) { + throw new TypeError( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `'+arg+'`.' ); + } + arg = arg[ ITERATOR_SYMBOL ](); + if ( !isFunction( arg.next ) ) { + throw new TypeError( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable.' ); + } + arr = []; + while ( true ) { + v = arg.next(); + if ( hasOwnProp( v, 'value' ) ) { + arr.push( value ); + } + if ( v.done ) { + break; + } + } + return arr; + } + throw new TypeError( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `'+arg+'`.' ); + } else if ( isArrayBuffer( arg ) ) { + throw new Error( 'invalid arguments. Creating a generic array from an ArrayBuffer is not supported.' ); + } + throw new TypeError( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `'+arg+'`.' ); + } + if ( nargs <= 0 ) { + return new ctor( 0 ); + } + if ( nargs === 1 ) { + arr = new ctor( arguments[1] ); + } else if ( nargs === 2 ) { + arr = new ctor( arguments[1], arguments[2] ); + } else { + arr = new ctor( arguments[1], arguments[2], arguments[3] ); + } + value = arguments[ 0 ]; + if ( arr.length > 0 && value !== 0 ) { // i.e., nonzero + gfill( arr.length, value, arr, 1 ); + } + return arr; +} + + +// EXPORTS // + +module.exports = filledarray; diff --git a/package.json b/package.json new file mode 100644 index 0000000..70122e8 --- /dev/null +++ b/package.json @@ -0,0 +1,144 @@ +{ + "name": "@stdlib/array-filled", + "version": "0.0.0", + "description": "Create a filled array.", + "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" + }, + "homepage": "https://github.com/stdlib-js/stdlib", + "repository": { + "type": "git", + "url": "git://github.com/stdlib-js/array-filled.git" + }, + "bugs": { + "url": "https://github.com/stdlib-js/stdlib/issues" + }, + "dependencies": { + "@stdlib/array-ctors": "^0.0.x", + "@stdlib/assert-has-iterator-symbol-support": "^0.0.x", + "@stdlib/assert-has-own-property": "^0.0.x", + "@stdlib/assert-is-arraybuffer": "^0.0.x", + "@stdlib/assert-is-collection": "^0.0.x", + "@stdlib/assert-is-function": "^0.0.x", + "@stdlib/assert-is-nonnegative-integer": "^0.0.x", + "@stdlib/assert-is-object": "^0.0.x", + "@stdlib/assert-is-string": "^0.0.x", + "@stdlib/blas-ext-base-gfill": "^0.0.x", + "@stdlib/symbol-iterator": "^0.0.x", + "@stdlib/types": "^0.0.x" + }, + "devDependencies": { + "@stdlib/array-buffer": "^0.0.x", + "@stdlib/array-dtypes": "^0.0.x", + "@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-instance-of": "^0.0.x", + "@stdlib/assert-is-array": "^0.0.x", + "@stdlib/assert-is-typed-array": "^0.0.x", + "@stdlib/bench": "^0.0.x", + "@stdlib/iter-constant": "^0.0.x", + "@stdlib/math-base-special-pow": "^0.0.x", + "@stdlib/random-base-discrete-uniform": "^0.0.x", + "proxyquire": "^2.0.0", + "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", + "stdtypes", + "types", + "data", + "structure", + "typed", + "array", + "typed array", + "typed-array", + "vector", + "ndarray", + "matrix", + "float64array", + "float32array", + "int32array", + "uint32array", + "int16array", + "uint16array", + "int8array", + "uint8array", + "uint8clampedarray", + "float64", + "double", + "precision", + "double-precision", + "single", + "float", + "single-precision", + "float32", + "ieee754", + "integer", + "int32", + "signed", + "unsigned", + "uint32", + "int16", + "uint16", + "int8", + "uint8", + "uint8c", + "clamped", + "short", + "long", + "generic", + "fill", + "filled" + ], + "funding": { + "type": "patreon", + "url": "https://www.patreon.com/athan" + } +} diff --git a/test/test.js b/test/test.js new file mode 100644 index 0000000..29ac7d9 --- /dev/null +++ b/test/test.js @@ -0,0 +1,2059 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2020 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF 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 proxyquire = require( 'proxyquire' ); +var Float64Array = require( '@stdlib/array-float64' ); +var Float32Array = require( '@stdlib/array-float32' ); +var Int32Array = require( '@stdlib/array-int32' ); +var Uint32Array = require( '@stdlib/array-uint32' ); +var Int16Array = require( '@stdlib/array-int16' ); +var Uint16Array = require( '@stdlib/array-uint16' ); +var Int8Array = require( '@stdlib/array-int8' ); +var Uint8Array = require( '@stdlib/array-uint8' ); +var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); +var ArrayBuffer = require( '@stdlib/array-buffer' ); +var instanceOf = require( '@stdlib/assert-instance-of' ); +var iterConstant = require( '@stdlib/iter-constant' ); +var hasIteratorSymbolSupport = require( '@stdlib/assert-has-iterator-symbol-support' ); +var filledarray = require( './../lib' ); + + +// VARIABLES // + +var opts = { + 'skip': !hasIteratorSymbolSupport() +}; + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof filledarray, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function throws an error if provided an unrecognized data type (one argument)', function test( t ) { + var values; + var i; + + values = [ + '5', + 'beep', + 'filledarray', + 'Int32', + 'Uint32', + 'Int16', + 'Uint16', + 'Int8', + 'Uint8', + 'Uint8c', + 'uint8_clamped', + 'Float64', + 'Float32', + 'FLOAT64', + 'FLOAT32', + 'GENERIC' + ]; + + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + filledarray( value ); + }; + } +}); + +tape( 'the function throws an error if provided an unrecognized data type (length)', function test( t ) { + var values; + var i; + + values = [ + '5', + 'beep', + 'filledarray', + 'Int32', + 'Uint32', + 'Int16', + 'Uint16', + 'Int8', + 'Uint8', + 'Uint8c', + 'uint8_clamped', + 'Float64', + 'Float32', + 'FLOAT64', + 'FLOAT32', + 'GENERIC' + ]; + + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + filledarray( 1.0, 10, value ); + }; + } +}); + +tape( 'the function throws an error if provided an unrecognized data type (typed array)', function test( t ) { + var values; + var i; + + values = [ + '5', + 'beep', + 'filledarray', + 'Int32', + 'Uint32', + 'Int16', + 'Uint16', + 'Int8', + 'Uint8', + 'Uint8c', + 'uint8_clamped', + 'Float64', + 'Float32', + 'FLOAT64', + 'FLOAT32', + 'GENERIC' + ]; + + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + filledarray( 1.0, new Float64Array( 10 ), value ); + }; + } +}); + +tape( 'the function throws an error if provided an unrecognized data type (array-like object)', function test( t ) { + var values; + var i; + + values = [ + '5', + 'beep', + 'filledarray', + 'Int32', + 'Uint32', + 'Int16', + 'Uint16', + 'Int8', + 'Uint8', + 'Uint8c', + 'uint8_clamped', + 'Float64', + 'Float32', + 'FLOAT64', + 'FLOAT32', + 'GENERIC' + ]; + + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + filledarray( 1.0, [ 1, 2, 3 ], value ); + }; + } +}); + +tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer)', function test( t ) { + var values; + var i; + + values = [ + '5', + 'beep', + 'filledarray', + 'Int32', + 'Uint32', + 'Int16', + 'Uint16', + 'Int8', + 'Uint8', + 'Uint8c', + 'uint8_clamped', + 'Float64', + 'Float32', + 'FLOAT64', + 'FLOAT32', + 'GENERIC' + ]; + + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + filledarray( 1.0, new ArrayBuffer( 16 ), value ); + }; + } +}); + +tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer, byteOffset)', function test( t ) { + var values; + var i; + + values = [ + '5', + 'beep', + 'filledarray', + 'Int32', + 'Uint32', + 'Int16', + 'Uint16', + 'Int8', + 'Uint8', + 'Uint8c', + 'uint8_clamped', + 'Float64', + 'Float32', + 'FLOAT64', + 'FLOAT32', + 'GENERIC' + ]; + + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + filledarray( 1.0, new ArrayBuffer( 16 ), 0, value ); + }; + } +}); + +tape( 'the function throws an error if provided an unrecognized data type (ArrayBuffer, byteOffset, length)', function test( t ) { + var values; + var i; + + values = [ + '5', + 'beep', + 'filledarray', + 'Int32', + 'Uint32', + 'Int16', + 'Uint16', + 'Int8', + 'Uint8', + 'Uint8c', + 'uint8_clamped', + 'Float64', + 'Float32', + 'FLOAT64', + 'FLOAT32', + 'GENERIC' + ]; + + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + filledarray( 1.0, new ArrayBuffer( 16 ), 0, 1, value ); + }; + } +}); + +tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array', function test( t ) { + var values; + var i; + + values = [ + '5', + true, + false, + null, + void 0, + {}, + function noop() {} + ]; + + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + filledarray( 1.0, value, 'generic' ); + }; + } +}); + +tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array (no iterator symbol support)', function test( t ) { + var filledarray; + var values; + var i; + + filledarray = proxyquire( './../lib/main.js', { + '@stdlib/assert/has-iterator-symbol-support': hasSupport + }); + + values = [ + '5', + true, + false, + null, + void 0, + {}, + function noop() {} + ]; + + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + filledarray( 1.0, value, 'generic' ); + }; + } + + function hasSupport() { + return false; + } +}); + +tape( 'the function throws an error if not provided a length, typed array, array-like object, or an iterable when attempting to create a generic array (iterator symbol support)', function test( t ) { + var filledarray; + var values; + var i; + + filledarray = proxyquire( './../lib/main.js', { + '@stdlib/assert/has-iterator-symbol-support': hasSupport + }); + + values = [ + '5', + true, + false, + null, + void 0, + {}, + function noop() {} + ]; + + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + filledarray( 1.0, value, 'generic' ); + }; + } + + function hasSupport() { + return true; + } +}); + +tape( 'the function throws an error if not provided a valid iterable when attempting to create a generic array (non-function iterator symbol property)', function test( t ) { + var filledarray; + var values; + var i; + + filledarray = proxyquire( './../lib/main.js', { + '@stdlib/assert/has-iterator-symbol-support': hasSupport, + '@stdlib/symbol/iterator': '__ITERATOR_SYMBOL__' + }); + + values = [ + '5', + 5, + true, + false, + null, + void 0, + {}, + [] + ]; + + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + var obj = { + '__ITERATOR_SYMBOL__': value + }; + filledarray( 1.0, obj, 'generic' ); + }; + } + + function hasSupport() { + return true; + } +}); + +tape( 'the function throws an error if not provided a valid iterable when attempting to create a generic array (`next` property is not a function)', function test( t ) { + var filledarray; + var values; + var i; + + filledarray = proxyquire( './../lib/main.js', { + '@stdlib/assert/has-iterator-symbol-support': hasSupport, + '@stdlib/symbol/iterator': '__ITERATOR_SYMBOL__' + }); + + values = [ + '5', + 5, + true, + false, + null, + void 0, + {}, + [] + ]; + + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + var obj = { + '__ITERATOR_SYMBOL__': iterator + }; + filledarray( 1.0, obj, 'generic' ); + }; + + function iterator() { + return { + 'next': value + }; + } + } + + function hasSupport() { + return true; + } +}); + +tape( 'the function throws an error if not provided valid arguments when attempting to create a generic array (arraybuffer, byteoffset)', function test( t ) { + var values; + var i; + + values = [ + '5', + 5, + true, + false, + null, + void 0, + {}, + [], + function noop() {} + ]; + + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + filledarray( 1.0, value, 1, 'generic' ); + }; + } +}); + +tape( 'the function throws an error if not provided valid arguments when attempting to create a generic array (arraybuffer, byteoffset, length)', function test( t ) { + var values; + var i; + + values = [ + '5', + 5, + true, + false, + null, + void 0, + {}, + [], + function noop() {} + ]; + + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + filledarray( 1.0, value, 1, 1, 'generic' ); + }; + } +}); + +tape( 'the function returns a filled array (default)', function test( t ) { + var expected; + var arr; + + expected = new Float64Array( 0 ); + + arr = filledarray(); + t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); + t.strictEqual( arr.length, 0, 'returns expected value' ); + t.deepEqual( arr, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns a filled array (dtype=float64)', function test( t ) { + var expected; + var arr; + + expected = new Float64Array( 0 ); + + arr = filledarray( 'float64' ); + t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); + t.strictEqual( arr.length, 0, 'returns expected value' ); + t.deepEqual( arr, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns a filled array (dtype=float32)', function test( t ) { + var expected; + var arr; + + expected = new Float32Array( 0 ); + + arr = filledarray( 'float32' ); + t.strictEqual( instanceOf( arr, Float32Array ), true, 'returns expected value' ); + t.strictEqual( arr.length, 0, 'returns expected value' ); + t.deepEqual( arr, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns a filled array (dtype=int32)', function test( t ) { + var expected; + var arr; + + expected = new Int32Array( 0 ); + + arr = filledarray( 'int32' ); + t.strictEqual( instanceOf( arr, Int32Array ), true, 'returns expected value' ); + t.strictEqual( arr.length, 0, 'returns expected value' ); + t.deepEqual( arr, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns a filled array (dtype=uint32)', function test( t ) { + var expected; + var arr; + + expected = new Uint32Array( 0 ); + + arr = filledarray( 'uint32' ); + t.strictEqual( instanceOf( arr, Uint32Array ), true, 'returns expected value' ); + t.strictEqual( arr.length, 0, 'returns expected value' ); + t.deepEqual( arr, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns a filled array (dtype=int16)', function test( t ) { + var expected; + var arr; + + expected = new Int16Array( 0 ); + + arr = filledarray( 'int16' ); + t.strictEqual( instanceOf( arr, Int16Array ), true, 'returns expected value' ); + t.strictEqual( arr.length, 0, 'returns expected value' ); + t.deepEqual( arr, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns a filled array (dtype=uint16)', function test( t ) { + var expected; + var arr; + + expected = new Uint16Array( 0 ); + + arr = filledarray( 'uint16' ); + t.strictEqual( instanceOf( arr, Uint16Array ), true, 'returns expected value' ); + t.strictEqual( arr.length, 0, 'returns expected value' ); + t.deepEqual( arr, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns a filled array (dtype=int8)', function test( t ) { + var expected; + var arr; + + expected = new Int8Array( 0 ); + + arr = filledarray( 'int8' ); + t.strictEqual( instanceOf( arr, Int8Array ), true, 'returns expected value' ); + t.strictEqual( arr.length, 0, 'returns expected value' ); + t.deepEqual( arr, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns a filled array (dtype=uint8)', function test( t ) { + var expected; + var arr; + + expected = new Uint8Array( 0 ); + + arr = filledarray( 'uint8' ); + t.strictEqual( instanceOf( arr, Uint8Array ), true, 'returns expected value' ); + t.strictEqual( arr.length, 0, 'returns expected value' ); + t.deepEqual( arr, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns a filled array (dtype=uint8c)', function test( t ) { + var expected; + var arr; + + expected = new Uint8ClampedArray( 0 ); + + arr = filledarray( 'uint8c' ); + t.strictEqual( instanceOf( arr, Uint8ClampedArray ), true, 'returns expected value' ); + t.strictEqual( arr.length, 0, 'returns expected value' ); + t.deepEqual( arr, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns a filled array (dtype=generic)', function test( t ) { + var expected; + var arr; + + expected = []; + + arr = filledarray( 'generic' ); + t.strictEqual( instanceOf( arr, Array ), true, 'returns expected value' ); + t.strictEqual( arr.length, 0, 'returns expected value' ); + t.deepEqual( arr, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns a filled array (default, length)', function test( t ) { + var expected; + var arr; + + expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); + + arr = filledarray( 1.0, 5 ); + t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); + t.strictEqual( arr.length, expected.length, 'returns expected value' ); + t.deepEqual( arr, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns a filled array (value=0, default, length)', function test( t ) { + var expected; + var arr; + + expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + + arr = filledarray( 0.0, 5 ); + t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); + t.strictEqual( arr.length, expected.length, 'returns expected value' ); + t.deepEqual( arr, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns a filled array (dtype=float64, length)', function test( t ) { + var expected; + var arr; + + expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); + + arr = filledarray( 1.0, 5, 'float64' ); + t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); + t.strictEqual( arr.length, expected.length, 'returns expected value' ); + t.deepEqual( arr, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns a filled array (value=0, dtype=float64, length)', function test( t ) { + var expected; + var arr; + + expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + + arr = filledarray( 0.0, 5, 'float64' ); + t.strictEqual( instanceOf( arr, Float64Array ), true, 'returns expected value' ); + t.strictEqual( arr.length, expected.length, 'returns expected value' ); + t.deepEqual( arr, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns a filled array (dtype=float32, length)', function test( t ) { + var expected; + var arr; + + expected = new Float32Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); + + arr = filledarray( 1.0, 5, 'float32' ); + t.strictEqual( instanceOf( arr, Float32Array ), true, 'returns expected value' ); + t.strictEqual( arr.length, expected.length, 'returns expected value' ); + t.deepEqual( arr, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns a filled array (value=0, dtype=float32, length)', function test( t ) { + var expected; + var arr; + + expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + + arr = filledarray( 0.0, 5, 'float32' ); + t.strictEqual( instanceOf( arr, Float32Array ), true, 'returns expected value' ); + t.strictEqual( arr.length, expected.length, 'returns expected value' ); + t.deepEqual( arr, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns a filled array (dtype=int32, length)', function test( t ) { + var expected; + var arr; + + expected = new Int32Array( [ 1, 1, 1, 1, 1 ] ); + + arr = filledarray( 1, 5, 'int32' ); + t.strictEqual( instanceOf( arr, Int32Array ), true, 'returns expected value' ); + t.strictEqual( arr.length, expected.length, 'returns expected value' ); + t.deepEqual( arr, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns a filled array (value=0, dtype=int32, length)', function test( t ) { + var expected; + var arr; + + expected = new Int32Array( [ 0, 0, 0, 0, 0 ] ); + + arr = filledarray( 0, 5, 'int32' ); + t.strictEqual( instanceOf( arr, Int32Array ), true, 'returns expected value' ); + t.strictEqual( arr.length, expected.length, 'returns expected value' ); + t.deepEqual( arr, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns a filled array (dtype=uint32, length)', function test( t ) { + var expected; + var arr; + + expected = new Uint32Array( [ 1, 1, 1, 1, 1 ] ); + + arr = filledarray( 1, 5, 'uint32' ); + t.strictEqual( instanceOf( arr, Uint32Array ), true, 'returns expected value' ); + t.strictEqual( arr.length, expected.length, 'returns expected value' ); + t.deepEqual( arr, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns a filled array (value=0, dtype=uint32, length)', function test( t ) { + var expected; + var arr; + + expected = new Uint32Array( [ 0, 0, 0, 0, 0 ] ); + + arr = filledarray( 0, 5, 'uint32' ); + t.strictEqual( instanceOf( arr, Uint32Array ), true, 'returns expected value' ); + t.strictEqual( arr.length, expected.length, 'returns expected value' ); + t.deepEqual( arr, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns a filled array (dtype=int16, length)', function test( t ) { + var expected; + var arr; + + expected = new Int16Array( [ 1, 1, 1, 1, 1 ] ); + + arr = filledarray( 1, 5, 'int16' ); + t.strictEqual( instanceOf( arr, Int16Array ), true, 'returns expected value' ); + t.strictEqual( arr.length, expected.length, 'returns expected value' ); + t.deepEqual( arr, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns a filled array (value=0, dtype=int16, length)', function test( t ) { + var expected; + var arr; + + expected = new Int16Array( [ 0, 0, 0, 0, 0 ] ); + + arr = filledarray( 0, 5, 'int16' ); + t.strictEqual( instanceOf( arr, Int16Array ), true, 'returns expected value' ); + t.strictEqual( arr.length, expected.length, 'returns expected value' ); + t.deepEqual( arr, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns a filled array (dtype=uint16, length)', function test( t ) { + var expected; + var arr; + + expected = new Uint16Array( [ 1, 1, 1, 1, 1 ] ); + + arr = filledarray( 1, 5, 'uint16' ); + t.strictEqual( instanceOf( arr, Uint16Array ), true, 'returns expected value' ); + t.strictEqual( arr.length, expected.length, 'returns expected value' ); + t.deepEqual( arr, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns a filled array (value=0, dtype=uint16, length)', function test( t ) { + var expected; + var arr; + + expected = new Uint16Array( [ 0, 0, 0, 0, 0 ] ); + + arr = filledarray( 0, 5, 'uint16' ); + t.strictEqual( instanceOf( arr, Uint16Array ), true, 'returns expected value' ); + t.strictEqual( arr.length, expected.length, 'returns expected value' ); + t.deepEqual( arr, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns a filled array (dtype=int8, length)', function test( t ) { + var expected; + var arr; + + expected = new Int8Array( [ 1, 1, 1, 1, 1 ] ); + + arr = filledarray( 1, 5, 'int8' ); + t.strictEqual( instanceOf( arr, Int8Array ), true, 'returns expected value' ); + t.strictEqual( arr.length, expected.length, 'returns expected value' ); + t.deepEqual( arr, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns a filled array (value=0, dtype=int8, length)', function test( t ) { + var expected; + var arr; + + expected = new Int8Array( [ 0, 0, 0, 0, 0 ] ); + + arr = filledarray( 0, 5, 'int8' ); + t.strictEqual( instanceOf( arr, Int8Array ), true, 'returns expected value' ); + t.strictEqual( arr.length, expected.length, 'returns expected value' ); + t.deepEqual( arr, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns a filled array (dtype=uint8, length)', function test( t ) { + var expected; + var arr; + + expected = new Uint8Array( [ 1, 1, 1, 1, 1 ] ); + + arr = filledarray( 1, 5, 'uint8' ); + t.strictEqual( instanceOf( arr, Uint8Array ), true, 'returns expected value' ); + t.strictEqual( arr.length, expected.length, 'returns expected value' ); + t.deepEqual( arr, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns a filled array (value=0, dtype=uint8, length)', function test( t ) { + var expected; + var arr; + + expected = new Uint8Array( [ 0, 0, 0, 0, 0 ] ); + + arr = filledarray( 0, 5, 'uint8' ); + t.strictEqual( instanceOf( arr, Uint8Array ), true, 'returns expected value' ); + t.strictEqual( arr.length, expected.length, 'returns expected value' ); + t.deepEqual( arr, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns a filled array (dtype=uint8c, length)', function test( t ) { + var expected; + var arr; + + expected = new Uint8ClampedArray( [ 1, 1, 1, 1, 1 ] ); + + arr = filledarray( 1, 5, 'uint8c' ); + t.strictEqual( instanceOf( arr, Uint8ClampedArray ), true, 'returns expected value' ); + t.strictEqual( arr.length, expected.length, 'returns expected value' ); + t.deepEqual( arr, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns a filled array (value=0, dtype=uint8c, length)', function test( t ) { + var expected; + var arr; + + expected = new Uint8ClampedArray( [ 0, 0, 0, 0, 0 ] ); + + arr = filledarray( 0, 5, 'uint8c' ); + t.strictEqual( instanceOf( arr, Uint8ClampedArray ), true, 'returns expected value' ); + t.strictEqual( arr.length, expected.length, 'returns expected value' ); + t.deepEqual( arr, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns a filled array (dtype=generic, length)', function test( t ) { + var expected; + var arr; + + expected = [ 1, 1, 1, 1, 1 ]; + + arr = filledarray( 1, 5, 'generic' ); + t.strictEqual( instanceOf( arr, Array ), true, 'returns expected value' ); + t.strictEqual( arr.length, expected.length, 'returns expected value' ); + t.deepEqual( arr, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns a filled array (value=0, dtype=generic, length)', function test( t ) { + var expected; + var arr; + + expected = [ 0, 0, 0, 0, 0 ]; + + arr = filledarray( 0, 5, 'generic' ); + t.strictEqual( instanceOf( arr, Array ), true, 'returns expected value' ); + t.strictEqual( arr.length, expected.length, 'returns expected value' ); + t.deepEqual( arr, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns a filled array (default, array)', function test( t ) { + var expected; + var arr; + var out; + + expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); + + arr = [ 1.0, 2.0, 3.0 ]; + out = filledarray( 1.0, arr ); + t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); + t.strictEqual( out.length, expected.length, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns a filled array (dtype=float64, array)', function test( t ) { + var expected; + var arr; + var out; + + expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); + + arr = [ 1.0, 2.0, 3.0 ]; + out = filledarray( 1.0, arr, 'float64' ); + t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); + t.strictEqual( out.length, expected.length, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns a filled array (dtype=float32, array)', function test( t ) { + var expected; + var arr; + var out; + + expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); + + arr = [ 1.0, 2.0, 3.0 ]; + out = filledarray( 1.0, arr, 'float32' ); + t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); + t.strictEqual( out.length, expected.length, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns a filled array (dtype=int32, array)', function test( t ) { + var expected; + var arr; + var out; + + expected = new Int32Array( [ 1, 1, 1 ] ); + + arr = [ 1.0, 2.0, 3.0 ]; + out = filledarray( 1, arr, 'int32' ); + t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); + t.strictEqual( out.length, expected.length, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns a filled array (dtype=uint32, array)', function test( t ) { + var expected; + var arr; + var out; + + expected = new Uint32Array( [ 1, 1, 1 ] ); + + arr = [ 1.0, 2.0, 3.0 ]; + out = filledarray( 1, arr, 'uint32' ); + t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); + t.strictEqual( out.length, expected.length, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns a filled array (dtype=int16, array)', function test( t ) { + var expected; + var arr; + var out; + + expected = new Int16Array( [ 1, 1, 1 ] ); + + arr = [ 1.0, 2.0, 3.0 ]; + out = filledarray( 1, arr, 'int16' ); + t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); + t.strictEqual( out.length, expected.length, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns a filled array (dtype=uint16, array)', function test( t ) { + var expected; + var arr; + var out; + + expected = new Uint16Array( [ 1, 1, 1 ] ); + + arr = [ 1.0, 2.0, 3.0 ]; + out = filledarray( 1, arr, 'uint16' ); + t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); + t.strictEqual( out.length, expected.length, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns a filled array (dtype=int8, array)', function test( t ) { + var expected; + var arr; + var out; + + expected = new Int8Array( [ 1, 1, 1 ] ); + + arr = [ 1.0, 2.0, 3.0 ]; + out = filledarray( 1, arr, 'int8' ); + t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); + t.strictEqual( out.length, expected.length, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns a filled array (dtype=uint8, array)', function test( t ) { + var expected; + var arr; + var out; + + expected = new Uint8Array( [ 1, 1, 1 ] ); + + arr = [ 1.0, 2.0, 3.0 ]; + out = filledarray( 1, arr, 'uint8' ); + t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); + t.strictEqual( out.length, expected.length, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns a filled array (dtype=uint8c, array)', function test( t ) { + var expected; + var arr; + var out; + + expected = new Uint8ClampedArray( [ 1, 1, 1 ] ); + + arr = [ 1.0, 2.0, 3.0 ]; + out = filledarray( 1, arr, 'uint8c' ); + t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); + t.strictEqual( out.length, expected.length, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns a filled array (dtype=generic, array)', function test( t ) { + var expected; + var arr; + var out; + + expected = [ 1.0, 1.0, 1.0 ]; + + arr = [ 1.0, 2.0, 3.0 ]; + out = filledarray( 1.0, arr, 'generic' ); + t.strictEqual( instanceOf( out, Array ), true, 'returns expected value' ); + t.strictEqual( out.length, expected.length, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns a filled array (default, typed array)', function test( t ) { + var expected; + var arr; + var out; + + expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); + + arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); + out = filledarray( 1.0, arr ); + t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); + t.strictEqual( out.length, expected.length, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns a filled array (dtype=float64, typed array)', function test( t ) { + var expected; + var arr; + var out; + + expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); + + arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); + out = filledarray( 1.0, arr, 'float64' ); + t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); + t.strictEqual( out.length, expected.length, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns a filled array (dtype=float32, typed array)', function test( t ) { + var expected; + var arr; + var out; + + expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); + + arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); + out = filledarray( 1.0, arr, 'float32' ); + t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); + t.strictEqual( out.length, expected.length, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns a filled array (dtype=int32, typed array)', function test( t ) { + var expected; + var arr; + var out; + + expected = new Int32Array( [ 1, 1, 1 ] ); + + arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); + out = filledarray( 1, arr, 'int32' ); + t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); + t.strictEqual( out.length, expected.length, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns a filled array (dtype=uint32, typed array)', function test( t ) { + var expected; + var arr; + var out; + + expected = new Uint32Array( [ 1, 1, 1 ] ); + + arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); + out = filledarray( 1, arr, 'uint32' ); + t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); + t.strictEqual( out.length, expected.length, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns a filled array (dtype=int16, typed array)', function test( t ) { + var expected; + var arr; + var out; + + expected = new Int16Array( [ 1, 1, 1 ] ); + + arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); + out = filledarray( 1, arr, 'int16' ); + t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); + t.strictEqual( out.length, expected.length, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns a filled array (dtype=uint16, typed array)', function test( t ) { + var expected; + var arr; + var out; + + expected = new Uint16Array( [ 1, 1, 1 ] ); + + arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); + out = filledarray( 1, arr, 'uint16' ); + t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); + t.strictEqual( out.length, expected.length, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns a filled array (dtype=int8, typed array)', function test( t ) { + var expected; + var arr; + var out; + + expected = new Int8Array( [ 1, 1, 1 ] ); + + arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); + out = filledarray( 1, arr, 'int8' ); + t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); + t.strictEqual( out.length, expected.length, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns a filled array (dtype=uint8, typed array)', function test( t ) { + var expected; + var arr; + var out; + + expected = new Uint8Array( [ 1, 1, 1 ] ); + + arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); + out = filledarray( 1, arr, 'uint8' ); + t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); + t.strictEqual( out.length, expected.length, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns a filled array (dtype=uint8c, typed array)', function test( t ) { + var expected; + var arr; + var out; + + expected = new Uint8ClampedArray( [ 1, 1, 1 ] ); + + arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); + out = filledarray( 1, arr, 'uint8c' ); + t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); + t.strictEqual( out.length, expected.length, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns a filled array (dtype=generic, typed array)', function test( t ) { + var expected; + var arr; + var out; + + expected = [ 1.0, 1.0, 1.0 ]; + + arr = new Float64Array( [ 1.0, 2.0, 3.0 ] ); + out = filledarray( 1.0, arr, 'generic' ); + t.strictEqual( instanceOf( out, Array ), true, 'returns expected value' ); + t.strictEqual( out.length, expected.length, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns a filled typed array (default, arraybuffer)', function test( t ) { + var expected; + var buf; + var out; + + expected = new Float64Array( [ 1.0 ] ); + + buf = new ArrayBuffer( 8 ); + out = filledarray( 1.0, buf ); + t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); + t.strictEqual( out.length, expected.length, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns a filled typed array (dtype=float64, arraybuffer)', function test( t ) { + var expected; + var buf; + var out; + + expected = new Float64Array( [ 1.0 ] ); + + buf = new ArrayBuffer( 8 ); + out = filledarray( 1.0, buf, 'float64' ); + t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); + t.strictEqual( out.length, expected.length, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns a filled typed array (dtype=float32, arraybuffer)', function test( t ) { + var expected; + var buf; + var out; + + expected = new Float32Array( [ 1.0, 1.0 ] ); + + buf = new ArrayBuffer( 8 ); + out = filledarray( 1.0, buf, 'float32' ); + t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); + t.strictEqual( out.length, expected.length, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns a filled typed array (dtype=int32, arraybuffer)', function test( t ) { + var expected; + var buf; + var out; + + expected = new Int32Array( [ 1, 1 ] ); + + buf = new ArrayBuffer( 8 ); + out = filledarray( 1, buf, 'int32' ); + t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); + t.strictEqual( out.length, expected.length, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns a filled typed array (dtype=uint32, arraybuffer)', function test( t ) { + var expected; + var buf; + var out; + + expected = new Uint32Array( [ 1, 1 ] ); + + buf = new ArrayBuffer( 8 ); + out = filledarray( 1, buf, 'uint32' ); + t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); + t.strictEqual( out.length, expected.length, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns a filled typed array (dtype=int16, arraybuffer)', function test( t ) { + var expected; + var buf; + var out; + + expected = new Int16Array( [ 1, 1, 1, 1 ] ); + + buf = new ArrayBuffer( 8 ); + out = filledarray( 1, buf, 'int16' ); + t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); + t.strictEqual( out.length, expected.length, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns a filled typed array (dtype=uint16, arraybuffer)', function test( t ) { + var expected; + var buf; + var out; + + expected = new Uint16Array( [ 1, 1, 1, 1 ] ); + + buf = new ArrayBuffer( 8 ); + out = filledarray( 1, buf, 'uint16' ); + t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); + t.strictEqual( out.length, expected.length, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns a filled typed array (dtype=int8, arraybuffer)', function test( t ) { + var expected; + var buf; + var out; + + expected = new Int8Array( [ 1, 1, 1, 1, 1, 1, 1, 1 ] ); + + buf = new ArrayBuffer( 8 ); + out = filledarray( 1, buf, 'int8' ); + t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); + t.strictEqual( out.length, expected.length, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns a filled typed array (dtype=uint8, arraybuffer)', function test( t ) { + var expected; + var buf; + var out; + + expected = new Uint8Array( [ 1, 1, 1, 1, 1, 1, 1, 1 ] ); + + buf = new ArrayBuffer( 8 ); + out = filledarray( 1, buf, 'uint8' ); + t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); + t.strictEqual( out.length, expected.length, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns a filled typed array (dtype=uint8c, arraybuffer)', function test( t ) { + var expected; + var buf; + var out; + + expected = new Uint8ClampedArray( [ 1, 1, 1, 1, 1, 1, 1, 1 ] ); + + buf = new ArrayBuffer( 8 ); + out = filledarray( 1, buf, 'uint8c' ); + t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); + t.strictEqual( out.length, expected.length, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer)', function test( t ) { + t.throws( foo, Error, 'throws an error' ); + t.end(); + + function foo() { + var buf = new ArrayBuffer( 8 ); + return filledarray( 1, buf, 'generic' ); + } +}); + +tape( 'the function returns a filled typed array (default, arraybuffer, byteoffset)', function test( t ) { + var expected; + var buf; + var out; + + expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); + + buf = new ArrayBuffer( 32 ); + out = filledarray( 1.0, buf, 8 ); + t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); + t.strictEqual( out.length, expected.length, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns a filled typed array (dtype=float64, arraybuffer, byteoffset)', function test( t ) { + var expected; + var buf; + var out; + + expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); + + buf = new ArrayBuffer( 32 ); + out = filledarray( 1.0, buf, 8, 'float64' ); + t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); + t.strictEqual( out.length, expected.length, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns a filled typed array (dtype=float32, arraybuffer, byteoffset)', function test( t ) { + var expected; + var buf; + var out; + + expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); + + buf = new ArrayBuffer( 16 ); + out = filledarray( 1.0, buf, 4, 'float32' ); + t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); + t.strictEqual( out.length, expected.length, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns a filled typed array (dtype=int32, arraybuffer, byteoffset)', function test( t ) { + var expected; + var buf; + var out; + + expected = new Int32Array( [ 1, 1, 1 ] ); + + buf = new ArrayBuffer( 16 ); + out = filledarray( 1, buf, 4, 'int32' ); + t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); + t.strictEqual( out.length, expected.length, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns a filled typed array (dtype=uint32, arraybuffer, byteoffset)', function test( t ) { + var expected; + var buf; + var out; + + expected = new Uint32Array( [ 1, 1, 1 ] ); + + buf = new ArrayBuffer( 16 ); + out = filledarray( 1, buf, 4, 'uint32' ); + t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); + t.strictEqual( out.length, expected.length, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns a filled typed array (dtype=int16, arraybuffer, byteoffset)', function test( t ) { + var expected; + var buf; + var out; + + expected = new Int16Array( [ 1, 1, 1, 1, 1, 1 ] ); + + buf = new ArrayBuffer( 16 ); + out = filledarray( 1, buf, 4, 'int16' ); + t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); + t.strictEqual( out.length, expected.length, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns a filled typed array (dtype=uint16, arraybuffer, byteoffset)', function test( t ) { + var expected; + var buf; + var out; + + expected = new Uint16Array( [ 1, 1, 1, 1, 1, 1 ] ); + + buf = new ArrayBuffer( 16 ); + out = filledarray( 1, buf, 4, 'uint16' ); + t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); + t.strictEqual( out.length, expected.length, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns a filled typed array (dtype=int8, arraybuffer, byteoffset)', function test( t ) { + var expected; + var buf; + var out; + + expected = new Int8Array( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ); + + buf = new ArrayBuffer( 16 ); + out = filledarray( 1, buf, 4, 'int8' ); + t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); + t.strictEqual( out.length, expected.length, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns a filled typed array (dtype=uint8, arraybuffer, byteoffset)', function test( t ) { + var expected; + var buf; + var out; + + expected = new Uint8Array( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ); + + buf = new ArrayBuffer( 16 ); + out = filledarray( 1, buf, 4, 'uint8' ); + t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); + t.strictEqual( out.length, expected.length, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns a filled typed array (dtype=uint8c, arraybuffer, byteoffset)', function test( t ) { + var expected; + var buf; + var out; + + expected = new Uint8ClampedArray( [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ] ); + + buf = new ArrayBuffer( 16 ); + out = filledarray( 1, buf, 4, 'uint8c' ); + t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); + t.strictEqual( out.length, expected.length, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer, byteoffset)', function test( t ) { + t.throws( foo, Error, 'throws an error' ); + t.end(); + + function foo() { + var buf = new ArrayBuffer( 8 ); + return filledarray( 1, buf, 4, 'generic' ); + } +}); + +tape( 'the function returns a filled typed array (default, arraybuffer, byteoffset, length)', function test( t ) { + var expected; + var buf; + var out; + + expected = new Float64Array( [ 1.0, 1.0 ] ); + + buf = new ArrayBuffer( 32 ); + out = filledarray( 1.0, buf, 8, 2 ); + t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); + t.strictEqual( out.length, expected.length, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns a filled typed array (dtype=float64, arraybuffer, byteoffset, length)', function test( t ) { + var expected; + var buf; + var out; + + expected = new Float64Array( [ 1.0, 1.0 ] ); + + buf = new ArrayBuffer( 32 ); + out = filledarray( 1.0, buf, 8, 2, 'float64' ); + t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); + t.strictEqual( out.length, expected.length, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns a filled typed array (dtype=float32, arraybuffer, byteoffset, length)', function test( t ) { + var expected; + var buf; + var out; + + expected = new Float32Array( [ 1.0, 1.0 ] ); + + buf = new ArrayBuffer( 16 ); + out = filledarray( 1.0, buf, 4, 2, 'float32' ); + t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); + t.strictEqual( out.length, expected.length, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns a typed array (dtype=int32, arraybuffer, byteoffset, length)', function test( t ) { + var expected; + var buf; + var out; + + expected = new Int32Array( [ 1, 1 ] ); + + buf = new ArrayBuffer( 16 ); + out = filledarray( 1, buf, 4, 2, 'int32' ); + t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); + t.strictEqual( out.length, expected.length, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns a filled typed array (dtype=uint32, arraybuffer, byteoffset, length)', function test( t ) { + var expected; + var buf; + var out; + + expected = new Uint32Array( [ 1, 1 ] ); + + buf = new ArrayBuffer( 16 ); + out = filledarray( 1, buf, 4, 2, 'uint32' ); + t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); + t.strictEqual( out.length, expected.length, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns a filled typed array (dtype=int16, arraybuffer, byteoffset, length)', function test( t ) { + var expected; + var buf; + var out; + + expected = new Int16Array( [ 1, 1 ] ); + + buf = new ArrayBuffer( 16 ); + out = filledarray( 1, buf, 4, 2, 'int16' ); + t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); + t.strictEqual( out.length, expected.length, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns a filled typed array (dtype=uint16, arraybuffer, byteoffset, length)', function test( t ) { + var expected; + var buf; + var out; + + expected = new Uint16Array( [ 1, 1 ] ); + + buf = new ArrayBuffer( 16 ); + out = filledarray( 1, buf, 4, 2, 'uint16' ); + t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); + t.strictEqual( out.length, expected.length, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns a filled typed array (dtype=int8, arraybuffer, byteoffset, length)', function test( t ) { + var expected; + var buf; + var out; + + expected = new Int8Array( [ 1, 1 ] ); + + buf = new ArrayBuffer( 16 ); + out = filledarray( 1, buf, 4, 2, 'int8' ); + t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); + t.strictEqual( out.length, expected.length, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns a filled typed array (dtype=uint8, arraybuffer, byteoffset, length)', function test( t ) { + var expected; + var buf; + var out; + + expected = new Uint8Array( [ 1, 1 ] ); + + buf = new ArrayBuffer( 16 ); + out = filledarray( 1, buf, 4, 2, 'uint8' ); + t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); + t.strictEqual( out.length, expected.length, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns a filled typed array (dtype=uint8c, arraybuffer, byteoffset, length)', function test( t ) { + var expected; + var buf; + var out; + + expected = new Uint8ClampedArray( [ 1, 1 ] ); + + buf = new ArrayBuffer( 16 ); + out = filledarray( 1, buf, 4, 2, 'uint8c' ); + t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); + t.strictEqual( out.length, expected.length, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function throws an error if provided an ArrayBuffer when attempting to create a generic array (dtype=generic, arraybuffer, byteoffset, length)', function test( t ) { + t.throws( foo, Error, 'throws an error' ); + t.end(); + + function foo() { + var buf = new ArrayBuffer( 8 ); + return filledarray( 1, buf, 4, 1, 'generic' ); + } +}); + +tape( 'the function returns a filled array (default, iterator)', opts, function test( t ) { + var expected; + var arr; + var out; + + expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); + + arr = iterConstant( 3.0, { + 'iter': 3 + }); + out = filledarray( 1.0, arr ); + t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); + t.strictEqual( out.length, expected.length, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns a filled array (dtype=float64, iterator)', opts, function test( t ) { + var expected; + var arr; + var out; + + expected = new Float64Array( [ 1.0, 1.0, 1.0 ] ); + + arr = iterConstant( 3.0, { + 'iter': 3 + }); + out = filledarray( 1.0, arr, 'float64' ); + t.strictEqual( instanceOf( out, Float64Array ), true, 'returns expected value' ); + t.strictEqual( out.length, expected.length, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns a filled array (dtype=float32, iterator)', opts, function test( t ) { + var expected; + var arr; + var out; + + expected = new Float32Array( [ 1.0, 1.0, 1.0 ] ); + + arr = iterConstant( 3.0, { + 'iter': 3 + }); + out = filledarray( 1.0, arr, 'float32' ); + t.strictEqual( instanceOf( out, Float32Array ), true, 'returns expected value' ); + t.strictEqual( out.length, expected.length, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns a filled array (dtype=int32, iterator)', opts, function test( t ) { + var expected; + var arr; + var out; + + expected = new Int32Array( [ 1, 1, 1 ] ); + + arr = iterConstant( 3, { + 'iter': 3 + }); + out = filledarray( 1, arr, 'int32' ); + t.strictEqual( instanceOf( out, Int32Array ), true, 'returns expected value' ); + t.strictEqual( out.length, expected.length, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns a filled array (dtype=uint32, iterator)', opts, function test( t ) { + var expected; + var arr; + var out; + + expected = new Uint32Array( [ 1, 1, 1 ] ); + + arr = iterConstant( 3, { + 'iter': 3 + }); + out = filledarray( 1, arr, 'uint32' ); + t.strictEqual( instanceOf( out, Uint32Array ), true, 'returns expected value' ); + t.strictEqual( out.length, expected.length, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns a filled array (dtype=int16, iterator)', opts, function test( t ) { + var expected; + var arr; + var out; + + expected = new Int16Array( [ 1, 1, 1 ] ); + + arr = iterConstant( 3, { + 'iter': 3 + }); + out = filledarray( 1, arr, 'int16' ); + t.strictEqual( instanceOf( out, Int16Array ), true, 'returns expected value' ); + t.strictEqual( out.length, expected.length, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns a filled array (dtype=uint16, iterator)', opts, function test( t ) { + var expected; + var arr; + var out; + + expected = new Uint16Array( [ 1, 1, 1 ] ); + + arr = iterConstant( 3, { + 'iter': 3 + }); + out = filledarray( 1, arr, 'uint16' ); + t.strictEqual( instanceOf( out, Uint16Array ), true, 'returns expected value' ); + t.strictEqual( out.length, expected.length, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns a filled array (dtype=int8, iterator)', opts, function test( t ) { + var expected; + var arr; + var out; + + expected = new Int8Array( [ 1, 1, 1 ] ); + + arr = iterConstant( 3, { + 'iter': 3 + }); + out = filledarray( 1, arr, 'int8' ); + t.strictEqual( instanceOf( out, Int8Array ), true, 'returns expected value' ); + t.strictEqual( out.length, expected.length, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns a filled array (dtype=uint8, iterator)', opts, function test( t ) { + var expected; + var arr; + var out; + + expected = new Uint8Array( [ 1, 1, 1 ] ); + + arr = iterConstant( 3, { + 'iter': 3 + }); + out = filledarray( 1, arr, 'uint8' ); + t.strictEqual( instanceOf( out, Uint8Array ), true, 'returns expected value' ); + t.strictEqual( out.length, expected.length, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns a filled array (dtype=uint8c, iterator)', opts, function test( t ) { + var expected; + var arr; + var out; + + expected = new Uint8ClampedArray( [ 1, 1, 1 ] ); + + arr = iterConstant( 3, { + 'iter': 3 + }); + out = filledarray( 1, arr, 'uint8c' ); + t.strictEqual( instanceOf( out, Uint8ClampedArray ), true, 'returns expected value' ); + t.strictEqual( out.length, expected.length, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns a filled array (dtype=generic, iterator)', opts, function test( t ) { + var expected; + var arr; + var out; + + expected = [ 1.0, 1.0, 1.0 ]; + + arr = iterConstant( 3, { + 'iter': 3 + }); + out = filledarray( 1.0, arr, 'generic' ); + t.strictEqual( instanceOf( out, Array ), true, 'returns expected value' ); + t.strictEqual( out.length, expected.length, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +});