Skip to content

Commit 7c9305b

Browse files
committedJun 14, 2021
Auto-generated commit
0 parents  commit 7c9305b

33 files changed

+2789
-0
lines changed
 

‎.editorconfig

+154
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,154 @@
1+
#/
2+
# @license Apache-2.0
3+
#
4+
# Copyright (c) 2017 The Stdlib Authors.
5+
#
6+
# Licensed under the Apache License, Version 2.0 (the "License");
7+
# you may not use this file except in compliance with the License.
8+
# You may obtain a copy of the License at
9+
#
10+
# http://www.apache.org/licenses/LICENSE-2.0
11+
#
12+
# Unless required by applicable law or agreed to in writing, software
13+
# distributed under the License is distributed on an "AS IS" BASIS,
14+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
# See the License for the specific language governing permissions and
16+
# limitations under the License.
17+
#/
18+
19+
# EditorConfig configuration file (see <http://editorconfig.org/>).
20+
21+
# Indicate that this file is a root-level configuration file:
22+
root = true
23+
24+
# Set properties for all files:
25+
[*]
26+
end_of_line = lf
27+
charset = utf-8
28+
trim_trailing_whitespace = true
29+
insert_final_newline = true
30+
31+
# Set properties for JavaScript files:
32+
[*.js]
33+
indent_style = tab
34+
35+
# Set properties for TypeScript files:
36+
[*.ts]
37+
indent_style = tab
38+
39+
# Set properties for Python files:
40+
[*.py]
41+
indent_style = space
42+
indent_size = 4
43+
44+
# Set properties for Julia files:
45+
[*.jl]
46+
indent_style = tab
47+
48+
# Set properties for R files:
49+
[*.R]
50+
indent_style = tab
51+
52+
# Set properties for C files:
53+
[*.c]
54+
indent_style = tab
55+
56+
# Set properties for C header files:
57+
[*.h]
58+
indent_style = tab
59+
60+
# Set properties for C++ files:
61+
[*.cpp]
62+
indent_style = tab
63+
64+
# Set properties for C++ header files:
65+
[*.hpp]
66+
indent_style = tab
67+
68+
# Set properties for Fortran files:
69+
[*.f]
70+
indent_style = space
71+
indent_size = 2
72+
insert_final_newline = false
73+
74+
# Set properties for shell files:
75+
[*.sh]
76+
indent_style = tab
77+
78+
# Set properties for AWK files:
79+
[*.awk]
80+
indent_style = tab
81+
82+
# Set properties for HTML files:
83+
[*.html]
84+
indent_style = tab
85+
tab_width = 2
86+
87+
# Set properties for CSS files:
88+
[*.css]
89+
indent_style = tab
90+
91+
# Set properties for Makefiles:
92+
[Makefile]
93+
indent_style = tab
94+
95+
[*.mk]
96+
indent_style = tab
97+
98+
# Set properties for Markdown files:
99+
[*.md]
100+
indent_style = space
101+
indent_size = 4
102+
trim_trailing_whitespace = false
103+
104+
# Set properties for `usage.txt` files:
105+
[usage.txt]
106+
indent_style = space
107+
indent_size = 2
108+
109+
# Set properties for `repl.txt` files:
110+
[repl.txt]
111+
indent_style = space
112+
indent_size = 4
113+
114+
# Set properties for `package.json` files:
115+
[package.json]
116+
indent_style = space
117+
indent_size = 2
118+
119+
# Set properties for `datapackage.json` files:
120+
[datapackage.json]
121+
indent_style = space
122+
indent_size = 2
123+
124+
# Set properties for `tslint.json` files:
125+
[tslint.json]
126+
indent_style = space
127+
indent_size = 2
128+
129+
# Set properties for `tsconfig.json` files:
130+
[tsconfig.json]
131+
indent_style = space
132+
indent_size = 2
133+
134+
# Set properties for LaTeX files:
135+
[*.tex]
136+
indent_style = tab
137+
138+
# Set properties for LaTeX Bibliography files:
139+
[*.bib]
140+
indent_style = tab
141+
142+
# Set properties for YAML files:
143+
[*.yml]
144+
indent_style = space
145+
indent_size = 2
146+
147+
# Set properties for GYP files:
148+
[binding.gyp]
149+
indent_style = space
150+
indent_size = 2
151+
152+
[*.gypi]
153+
indent_style = space
154+
indent_size = 2

‎.gitattributes

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#/
2+
# @license Apache-2.0
3+
#
4+
# Copyright (c) 2017 The Stdlib Authors.
5+
#
6+
# Licensed under the Apache License, Version 2.0 (the "License");
7+
# you may not use this file except in compliance with the License.
8+
# You may obtain a copy of the License at
9+
#
10+
# http://www.apache.org/licenses/LICENSE-2.0
11+
#
12+
# Unless required by applicable law or agreed to in writing, software
13+
# distributed under the License is distributed on an "AS IS" BASIS,
14+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
# See the License for the specific language governing permissions and
16+
# limitations under the License.
17+
#/
18+
19+
# Configuration file which assigns attributes to pathnames.
20+
#
21+
# [1]: https://git-scm.com/docs/gitattributes
22+
23+
# Automatically normalize the line endings of any committed text files:
24+
* text=auto
25+
26+
# Override what is considered "vendored" by GitHub's linguist:
27+
/deps/** linguist-vendored=false
28+
/lib/node_modules/** linguist-vendored=false linguist-generated=false
29+
test/fixtures/** linguist-vendored=false
30+
tools/** linguist-vendored=false
31+
32+
# Override what is considered "documentation" by GitHub's linguist:
33+
examples/** linguist-documentation=false

‎.github/PULL_REQUEST_TEMPLATE.md

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<!-- ----------^ Click "Preview"! -->
2+
3+
We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/assert/has-int16array-support) of the main repository where we’ll review and provide feedback.
4+
5+
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.
6+
7+
We look forward to receiving your contribution! :smiley:
+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: Close Pull Requests
2+
3+
on:
4+
pull_request_target:
5+
types: [opened]
6+
7+
jobs:
8+
run:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: superbrothers/close-pull-request@v3
12+
with:
13+
comment: |
14+
Thank you for submitting a pull request. :raised_hands:
15+
16+
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).
17+
18+
We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/assert/has-int16array-support) 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.
19+
20+
Thank you again, and we look forward to receiving your contribution! :smiley:
21+
22+
Best,
23+
The stdlib team

‎.github/workflows/examples.yml

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name: examples
2+
3+
on:
4+
workflow_dispatch:
5+
6+
jobs:
7+
examples:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- uses: actions/checkout@v2
11+
- uses: actions/setup-node@v1
12+
with:
13+
node-version: 14
14+
- name: Install production and development dependencies
15+
run: |
16+
npm install
17+
- name: Run examples
18+
run: |
19+
npm run examples

‎.github/workflows/publish.yml

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: Publish Package
2+
3+
on: push
4+
5+
jobs:
6+
publish:
7+
runs-on: ubuntu-latest
8+
env:
9+
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
10+
steps:
11+
- uses: actions/checkout@v2
12+
- uses: actions/setup-node@v1
13+
with:
14+
node-version: 14
15+
- name: Increment version
16+
run: |
17+
git config --local user.email "noreply@stdlib.io"
18+
git config --local user.name "stdlib-bot"
19+
npm version patch
20+
- name: Publish package to npm
21+
uses: JS-DevTools/npm-publish@v1
22+
with:
23+
token: ${{ secrets.NPM_TOKEN }}
24+
access: public
25+
- name: Push changes
26+
run: |
27+
git push origin main
28+
git push --tags
29+
- uses: act10ns/slack@v1
30+
with:
31+
status: ${{ job.status }}
32+
steps: ${{ toJson(steps) }}
33+
channel: '#npm-ci'
34+
if: failure()

‎.github/workflows/test.yml

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: build
2+
3+
on:
4+
workflow_dispatch:
5+
6+
jobs:
7+
test:
8+
runs-on: ubuntu-latest
9+
env:
10+
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
11+
steps:
12+
- uses: actions/checkout@v2
13+
- uses: actions/setup-node@v1
14+
with:
15+
node-version: 14
16+
- name: Install production and development dependencies
17+
id: install
18+
run: |
19+
npm install
20+
- name: Run tests
21+
id: tests
22+
run: |
23+
npm test
24+
- uses: act10ns/slack@v1
25+
with:
26+
status: ${{ job.status }}
27+
steps: ${{ toJson(steps) }}
28+
channel: '#npm-ci'
29+
if: failure()

‎.github/workflows/test_coverage.yml

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: coverage
2+
3+
on:
4+
workflow_dispatch:
5+
6+
jobs:
7+
test:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- uses: actions/checkout@v2
11+
- uses: actions/setup-node@v1
12+
with:
13+
node-version: 14
14+
- name: Install production and development dependencies
15+
run: |
16+
npm install
17+
- name: Calculate test coverage
18+
run: |
19+
npm run test-cov
20+
- name: Upload coverage to Codecov
21+
uses: codecov/codecov-action@v1
22+
with:
23+
directory: reports/coverage
24+
flags: unittests

‎.github/workflows/test_install.yml

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: Test Installing Dependencies
2+
3+
on:
4+
workflow_run:
5+
workflows: ["Publish Package"]
6+
types: [completed]
7+
8+
jobs:
9+
on-success:
10+
runs-on: ubuntu-latest
11+
env:
12+
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
13+
if: ${{ github.event.workflow_run.conclusion == 'success' }}
14+
steps:
15+
- uses: actions/checkout@v1
16+
- uses: actions/setup-node@v1
17+
with:
18+
node-version: 14
19+
- name: Install production dependencies via npm
20+
run: |
21+
npm install --only=prod
22+
- uses: act10ns/slack@v1
23+
with:
24+
status: ${{ job.status }}
25+
steps: ${{ toJson(steps) }}
26+
channel: '#npm-ci'
27+
if: failure()

‎.gitignore

+181
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,181 @@
1+
#/
2+
# @license Apache-2.0
3+
#
4+
# Copyright (c) 2017 The Stdlib Authors.
5+
#
6+
# Licensed under the Apache License, Version 2.0 (the "License");
7+
# you may not use this file except in compliance with the License.
8+
# You may obtain a copy of the License at
9+
#
10+
# http://www.apache.org/licenses/LICENSE-2.0
11+
#
12+
# Unless required by applicable law or agreed to in writing, software
13+
# distributed under the License is distributed on an "AS IS" BASIS,
14+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
# See the License for the specific language governing permissions and
16+
# limitations under the License.
17+
#/
18+
19+
# Files #
20+
#########
21+
.postinstall.json
22+
23+
# Directories #
24+
###############
25+
build/
26+
downloads/
27+
reports/
28+
tmp/
29+
30+
# Compiled source #
31+
###################
32+
*.com
33+
*.class
34+
*.dll
35+
*.o
36+
*.so
37+
*.slo
38+
*.lo
39+
*.obj
40+
*.dylib
41+
*.lai
42+
*.la
43+
*.a
44+
*.lib
45+
*.ko
46+
*.elf
47+
*.node
48+
49+
# Precompiled headers #
50+
#######################
51+
*.gch
52+
*.pch
53+
54+
# Executables #
55+
###############
56+
*.exe
57+
*.out
58+
*.app
59+
60+
# Packages #
61+
############
62+
# It is better to unpack these files and commit the raw source
63+
# git has its own built in compression methods
64+
*.7z
65+
*.dmg
66+
*.gz
67+
*.iso
68+
*.jar
69+
*.rar
70+
*.tar
71+
*.zip
72+
73+
# Make an exception for compressed distributable files:
74+
!dist/*.gz
75+
76+
# Logs and databases #
77+
######################
78+
*.log
79+
*.sql
80+
*.sqlite
81+
82+
# OS generated files #
83+
######################
84+
.DS_Store
85+
.DS_Store?
86+
._*
87+
.Spotlight-V100
88+
.Trashes
89+
Icon?
90+
ehthumbs.db
91+
Thumbs.db
92+
Desktop.ini
93+
94+
# Temporary files #
95+
###################
96+
*~
97+
98+
# Node.js #
99+
###########
100+
/node_modules/
101+
lib/node_modules/**/node_modules/
102+
docs/**/node_modules/
103+
pids
104+
*.pid
105+
*.seed
106+
107+
# Typescript #
108+
##############
109+
*.tsbuildinfo
110+
lib/node_modules/**/tsconfig.json
111+
lib/node_modules/**/tslint.json
112+
113+
# Matlab #
114+
##########
115+
*.asv
116+
*.mex*
117+
118+
# Fortran #
119+
###########
120+
*.mod
121+
122+
# R #
123+
#####
124+
.Rhistory
125+
.Rapp.history
126+
.Rproj.user/
127+
128+
# Python #
129+
##########
130+
__pycache__/
131+
*.py[cod]
132+
*$py.class
133+
*.egg-info/
134+
135+
# TeX #
136+
#######
137+
*.aux
138+
*.lof
139+
*.log
140+
*.lot
141+
*.fls
142+
*.out
143+
*.toc
144+
*.dvi
145+
*-converted-to.*
146+
*.bbl
147+
*.bcf
148+
*.blg
149+
*-blx.aux
150+
*-blx.bib
151+
*.brf
152+
*.run.xml
153+
*.fdb_latexmk
154+
*.synctex
155+
*.synctex.gz
156+
*.synctex.gz(busy)
157+
*.pdfsync
158+
*.alg
159+
*.loa
160+
acs-*.bib
161+
*.thm
162+
*.nav
163+
*.snm
164+
*.vrb
165+
*.acn
166+
*.acr
167+
*.glg
168+
*.glo
169+
*.gls
170+
*-concordance.tex
171+
*.tikz
172+
*-tikzDictionary
173+
*.idx
174+
*.ilg
175+
*.ind
176+
*.ist
177+
178+
# Visual Studio #
179+
#################
180+
.vscode/
181+
jsconfig.json

‎.npmignore

+225
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,225 @@
1+
#/
2+
# @license Apache-2.0
3+
#
4+
# Copyright (c) 2017 The Stdlib Authors.
5+
#
6+
# Licensed under the Apache License, Version 2.0 (the "License");
7+
# you may not use this file except in compliance with the License.
8+
# You may obtain a copy of the License at
9+
#
10+
# http://www.apache.org/licenses/LICENSE-2.0
11+
#
12+
# Unless required by applicable law or agreed to in writing, software
13+
# distributed under the License is distributed on an "AS IS" BASIS,
14+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
# See the License for the specific language governing permissions and
16+
# limitations under the License.
17+
#/
18+
19+
# Files #
20+
#########
21+
CODE_OF_CONDUCT.md
22+
CONTRIBUTING.md
23+
CONTRIBUTORS
24+
TODO.md
25+
ROADMAP.md
26+
.postinstall.json
27+
28+
# Directories #
29+
###############
30+
.circleci/
31+
.github/
32+
**/benchmark/
33+
**/build/
34+
**/examples/
35+
reports/
36+
support/
37+
**/tmp/
38+
workshops/
39+
40+
# Ignore test directories, except for testing dependency installation:
41+
**/test/
42+
!/deps/test/
43+
44+
# Only top-level directories:
45+
/etc/
46+
/docs/
47+
48+
# Compiled source #
49+
###################
50+
*.com
51+
*.class
52+
*.dll
53+
*.o
54+
*.so
55+
*.slo
56+
*.lo
57+
*.obj
58+
*.dylib
59+
*.lai
60+
*.la
61+
*.a
62+
*.lib
63+
*.ko
64+
*.elf
65+
*.node
66+
67+
# Precompiled headers #
68+
#######################
69+
*.gch
70+
*.pch
71+
72+
# Executables #
73+
###############
74+
*.exe
75+
*.out
76+
*.app
77+
78+
# Packages #
79+
############
80+
*.7z
81+
*.dmg
82+
*.gz
83+
*.iso
84+
*.jar
85+
*.rar
86+
*.tar
87+
*.zip
88+
89+
# Make an exception for compressed distributable files:
90+
!dist/*.gz
91+
92+
# Logs and databases #
93+
######################
94+
*.log
95+
*.sql
96+
*.sqlite
97+
98+
# OS generated files #
99+
######################
100+
.DS_Store
101+
.DS_Store?
102+
._*
103+
.Spotlight-V100
104+
.Trashes
105+
Icon?
106+
ehthumbs.db
107+
Thumbs.db
108+
Desktop.ini
109+
110+
# Temporary files #
111+
###################
112+
*~
113+
114+
# Node.js #
115+
###########
116+
.npmignore
117+
118+
# Only top-level node_modules:
119+
/node_modules/
120+
121+
# TypeScript #
122+
##############
123+
tsconfig.json
124+
tslint.json
125+
*.tsbuildinfo
126+
127+
# Matlab #
128+
##########
129+
*.asv
130+
*.mex*
131+
132+
# Fortran #
133+
###########
134+
*.mod
135+
136+
# R #
137+
#####
138+
.Rhistory
139+
.Rapp.history
140+
.Rproj.user/
141+
142+
# Python #
143+
##########
144+
__pycache__/
145+
*.py[cod]
146+
*$py.class
147+
*.egg-info/
148+
.ipynb_checkpoints
149+
setup.cfg
150+
setup.py
151+
152+
# TeX #
153+
#######
154+
*.aux
155+
*.lof
156+
*.log
157+
*.lot
158+
*.fls
159+
*.out
160+
*.toc
161+
*.dvi
162+
*-converted-to.*
163+
*.bbl
164+
*.bcf
165+
*.blg
166+
*-blx.aux
167+
*-blx.bib
168+
*.brf
169+
*.run.xml
170+
*.fdb_latexmk
171+
*.synctex
172+
*.synctex.gz
173+
*.synctex.gz(busy)
174+
*.pdfsync
175+
*.alg
176+
*.loa
177+
acs-*.bib
178+
*.thm
179+
*.nav
180+
*.snm
181+
*.vrb
182+
*.acn
183+
*.acr
184+
*.glg
185+
*.glo
186+
*.gls
187+
*-concordance.tex
188+
*.tikz
189+
*-tikzDictionary
190+
*.idx
191+
*.ilg
192+
*.ind
193+
*.ist
194+
195+
# Git #
196+
#######
197+
.git*
198+
.mailmap
199+
200+
# Visual Studio #
201+
#################
202+
.vscode/
203+
jsconfig.json
204+
205+
# Utilities #
206+
#############
207+
.jshintrc
208+
.jshintignore
209+
.eslintrc*
210+
.eslintignore
211+
212+
.pylintrc
213+
.pycodestyle
214+
.pydocstyle
215+
216+
.travis.yml
217+
circle.yml
218+
appveyor.yml
219+
azure-pipelines.yml
220+
221+
.editorconfig
222+
.codeclimate.yml
223+
.codecov.yml
224+
225+
.rtlintrc

‎.npmrc

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#/
2+
# @license Apache-2.0
3+
#
4+
# Copyright (c) 2017 The Stdlib Authors.
5+
#
6+
# Licensed under the Apache License, Version 2.0 (the "License");
7+
# you may not use this file except in compliance with the License.
8+
# You may obtain a copy of the License at
9+
#
10+
# http://www.apache.org/licenses/LICENSE-2.0
11+
#
12+
# Unless required by applicable law or agreed to in writing, software
13+
# distributed under the License is distributed on an "AS IS" BASIS,
14+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
# See the License for the specific language governing permissions and
16+
# limitations under the License.
17+
#/
18+
19+
# Configuration for [npm][1].
20+
#
21+
# [1]: https://docs.npmjs.com/files/npmrc
22+
23+
# Disable the creation of a lock file:
24+
package-lock = false
25+
shrinkwrap = false
26+
27+
# Disable automatically "saving" dependencies on install:
28+
save = false

‎CODE_OF_CONDUCT.md

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Code of Conduct
2+
3+
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.

‎CONTRIBUTING.md

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Contribution Guidelines
2+
3+
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.

‎CONTRIBUTORS

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# This file is generated by tools/scripts/update_contributors.
2+
#
3+
# Contributors listed in alphabetical order.
4+
5+
Athan Reines <kgryte@gmail.com>
6+
Brendan Graetz <bguiz@users.noreply.github.com>
7+
Bruno Fenzl <brunofenzl@gmail.com>
8+
Christopher Dambamuromo <chridam@gmail.com>
9+
Dominik Moritz <domoritz@gmail.com>
10+
Frank Kovacs <fran70kk@gmail.com>
11+
James <jdgelok@gmail.com>
12+
Jithin KS <jithinks112@gmail.com>
13+
Joey Reed <joeyrreed@gmail.com>
14+
Joris Labie <joris.labie1@gmail.com>
15+
Justin Dennison <justin1dennison@gmail.com>
16+
Marcus <mfantham@users.noreply.github.com>
17+
Matt Cochrane <matthew.cochrane.eng@gmail.com>
18+
Milan Raj <rajsite@users.noreply.github.com>
19+
Ognjen Jevremović <ognjenjevremovic@users.noreply.github.com>
20+
Philipp Burckhardt <pburckhardt@outlook.com>
21+
Ricky Reusser <rsreusser@gmail.com>
22+
Ryan Seal <splrk@users.noreply.github.com>
23+
Shraddheya Shendre <shendreshraddheya@gmail.com>
24+
rei2hu <rei2hu@users.noreply.github.com>

‎LICENSE

+481
Large diffs are not rendered by default.

‎Makefile

+534
Large diffs are not rendered by default.

‎NOTICE

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Copyright (c) 2016-2021 The Stdlib Authors.

‎README.md

+183
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,183 @@
1+
<!--
2+
3+
@license Apache-2.0
4+
5+
Copyright (c) 2018 The Stdlib Authors.
6+
7+
Licensed under the Apache License, Version 2.0 (the "License");
8+
you may not use this file except in compliance with the License.
9+
You may obtain a copy of the License at
10+
11+
http://www.apache.org/licenses/LICENSE-2.0
12+
13+
Unless required by applicable law or agreed to in writing, software
14+
distributed under the License is distributed on an "AS IS" BASIS,
15+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
See the License for the specific language governing permissions and
17+
limitations under the License.
18+
19+
-->
20+
21+
# Int16Array Support
22+
23+
[![NPM version][npm-image]][npm-url] [![Build Status][test-image]][test-url] [![Coverage Status][coverage-image]][coverage-url] [![dependencies][dependencies-image]][dependencies-url]
24+
25+
> Detect native [`Int16Array`][mdn-int16array] support.
26+
27+
<section class="installation">
28+
29+
## Installation
30+
31+
```bash
32+
npm install @stdlib/assert-has-int16array-support
33+
```
34+
35+
</section>
36+
37+
<section class="usage">
38+
39+
## Usage
40+
41+
```javascript
42+
var hasInt16ArraySupport = require( '@stdlib/assert-has-int16array-support' );
43+
```
44+
45+
#### hasInt16ArraySupport()
46+
47+
Detects if a runtime environment supports [`Int16Array`][mdn-int16array].
48+
49+
```javascript
50+
var bool = hasInt16ArraySupport();
51+
// returns <boolean>
52+
```
53+
54+
</section>
55+
56+
<!-- /.usage -->
57+
58+
<section class="examples">
59+
60+
## Examples
61+
62+
<!-- eslint no-undef: "error" -->
63+
64+
```javascript
65+
var hasInt16ArraySupport = require( '@stdlib/assert-has-int16array-support' );
66+
67+
var bool = hasInt16ArraySupport();
68+
if ( bool ) {
69+
console.log( 'Environment has Int16Array support.' );
70+
} else {
71+
console.log( 'Environment lacks Int16Array support.' );
72+
}
73+
```
74+
75+
</section>
76+
77+
<!-- /.examples -->
78+
79+
* * *
80+
81+
<section class="cli">
82+
83+
## CLI
84+
85+
<section class="installation">
86+
87+
## Installation
88+
89+
To use the module as a general utility, install the module globally
90+
91+
```bash
92+
npm install -g @stdlib/assert-has-int16array-support
93+
```
94+
95+
</section>
96+
97+
<section class="usage">
98+
99+
### Usage
100+
101+
```text
102+
Usage: has-int16array-support [options]
103+
104+
Options:
105+
106+
-h, --help Print this message.
107+
-V, --version Print the package version.
108+
```
109+
110+
</section>
111+
112+
<!-- /.usage -->
113+
114+
<section class="examples">
115+
116+
### Examples
117+
118+
```bash
119+
$ has-int16array-support
120+
<boolean>
121+
```
122+
123+
</section>
124+
125+
<!-- /.examples -->
126+
127+
</section>
128+
129+
<!-- /.cli -->
130+
131+
132+
<section class="main-repo" >
133+
134+
* * *
135+
136+
## Notice
137+
138+
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.
139+
140+
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].
141+
142+
---
143+
144+
## License
145+
146+
See [LICENSE][stdlib-license].
147+
148+
149+
## Copyright
150+
151+
Copyright &copy; 2016-2021. The Stdlib [Authors][stdlib-authors].
152+
153+
</section>
154+
155+
<!-- /.stdlib -->
156+
157+
<!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
158+
159+
<section class="links">
160+
161+
[npm-image]: http://img.shields.io/npm/v/@stdlib/assert-has-int16array-support.svg
162+
[npm-url]: https://npmjs.org/package/@stdlib/assert-has-int16array-support
163+
164+
[test-image]: https://github.com/stdlib-js/assert-has-int16array-support/actions/workflows/test.yml/badge.svg
165+
[test-url]: https://github.com/stdlib-js/assert-has-int16array-support/actions/workflows/test.yml
166+
167+
[coverage-image]: https://img.shields.io/codecov/c/github/stdlib-js/assert-has-int16array-support/main.svg
168+
[coverage-url]: https://codecov.io/github/stdlib-js/assert-has-int16array-support?branch=main
169+
170+
[dependencies-image]: https://img.shields.io/david/stdlib-js/assert-has-int16array-support
171+
[dependencies-url]: https://david-dm.org/stdlib-js/assert-has-int16array-support/main
172+
173+
[stdlib]: https://github.com/stdlib-js/stdlib
174+
175+
[stdlib-authors]: https://github.com/stdlib-js/stdlib/graphs/contributors
176+
177+
[stdlib-license]: https://raw.githubusercontent.com/stdlib-js/assert-has-int16array-support/main/LICENSE
178+
179+
[mdn-int16array]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Int16Array
180+
181+
</section>
182+
183+
<!-- /.links -->

‎benchmark/benchmark.js

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
/**
2+
* @license Apache-2.0
3+
*
4+
* Copyright (c) 2018 The Stdlib Authors.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
'use strict';
20+
21+
// MODULES //
22+
23+
var bench = require( '@stdlib/bench' );
24+
var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;
25+
var pkg = require( './../package.json' ).name;
26+
var hasInt16ArraySupport = require( './../lib' );
27+
28+
29+
// MAIN //
30+
31+
bench( pkg, function benchmark( b ) {
32+
var bool;
33+
var i;
34+
35+
b.tic();
36+
for ( i = 0; i < b.iterations; i++ ) {
37+
// Note: the following *could* be optimized away via loop-invariant code motion. If so, the entire loop will disappear.
38+
bool = hasInt16ArraySupport();
39+
if ( !isBoolean( bool ) ) {
40+
b.fail( 'should return a boolean' );
41+
}
42+
}
43+
b.toc();
44+
if ( !isBoolean( bool ) ) {
45+
b.fail( 'should return a boolean' );
46+
}
47+
b.pass( 'benchmark finished' );
48+
b.end();
49+
});

‎bin/cli

+60
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
#!/usr/bin/env node
2+
3+
/**
4+
* @license Apache-2.0
5+
*
6+
* Copyright (c) 2018 The Stdlib Authors.
7+
*
8+
* Licensed under the Apache License, Version 2.0 (the "License");
9+
* you may not use this file except in compliance with the License.
10+
* You may obtain a copy of the License at
11+
*
12+
* http://www.apache.org/licenses/LICENSE-2.0
13+
*
14+
* Unless required by applicable law or agreed to in writing, software
15+
* distributed under the License is distributed on an "AS IS" BASIS,
16+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17+
* See the License for the specific language governing permissions and
18+
* limitations under the License.
19+
*/
20+
21+
'use strict';
22+
23+
// MODULES //
24+
25+
var resolve = require( 'path' ).resolve;
26+
var readFileSync = require( '@stdlib/fs/read-file' ).sync;
27+
var CLI = require( '@stdlib/cli' );
28+
var detect = require( './../lib' );
29+
30+
31+
// MAIN //
32+
33+
/**
34+
* Main execution sequence.
35+
*
36+
* @private
37+
*/
38+
function main() {
39+
var flags;
40+
var cli;
41+
42+
// Create a command-line interface:
43+
cli = new CLI({
44+
'pkg': require( './../package.json' ),
45+
'options': require( './../etc/cli_opts.json' ),
46+
'help': readFileSync( resolve( __dirname, '..', 'docs', 'usage.txt' ), {
47+
'encoding': 'utf8'
48+
})
49+
});
50+
51+
// Get any provided command-line options:
52+
flags = cli.flags();
53+
if ( flags.help || flags.version ) {
54+
return;
55+
}
56+
57+
console.log( detect() ); // eslint-disable-line no-console
58+
}
59+
60+
main();

‎docs/repl.txt

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
2+
{{alias}}()
3+
Tests for native `Int16Array` support.
4+
5+
Returns
6+
-------
7+
bool: boolean
8+
Boolean indicating if an environment has `Int16Array` support.
9+
10+
Examples
11+
--------
12+
> var bool = {{alias}}()
13+
<boolean>
14+
15+
See Also
16+
--------
17+

‎docs/types/index.d.ts

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/*
2+
* @license Apache-2.0
3+
*
4+
* Copyright (c) 2019 The Stdlib Authors.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
// TypeScript Version: 2.0
20+
21+
/**
22+
* Tests for native `Int16Array` support.
23+
*
24+
* @returns boolean indicating if an environment has `Int16Array` support
25+
*
26+
* @example
27+
* var bool = hasInt16ArraySupport();
28+
* // returns <boolean>
29+
*/
30+
declare function hasInt16ArraySupport(): boolean;
31+
32+
33+
// EXPORTS //
34+
35+
export = hasInt16ArraySupport;

‎docs/types/test.ts

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/*
2+
* @license Apache-2.0
3+
*
4+
* Copyright (c) 2019 The Stdlib Authors.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
import hasInt16ArraySupport = require( './index' );
20+
21+
22+
// TESTS //
23+
24+
// The function returns a boolean...
25+
{
26+
hasInt16ArraySupport(); // $ExpectType boolean
27+
}
28+
29+
// The compiler throws an error if the function is provided arguments...
30+
{
31+
hasInt16ArraySupport( true ); // $ExpectError
32+
hasInt16ArraySupport( [], 123 ); // $ExpectError
33+
}

‎docs/usage.txt

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
2+
Usage: has-int16array-support [options]
3+
4+
Options:
5+
6+
-h, --help Print this message.
7+
-V, --version Print the package version.
8+

‎etc/cli_opts.json

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"boolean": [
3+
"help",
4+
"version"
5+
],
6+
"alias": {
7+
"help": [
8+
"h"
9+
],
10+
"version": [
11+
"V"
12+
]
13+
}
14+
}

‎examples/index.js

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/**
2+
* @license Apache-2.0
3+
*
4+
* Copyright (c) 2018 The Stdlib Authors.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
'use strict';
20+
21+
var hasInt16ArraySupport = require( './../lib' );
22+
23+
var bool = hasInt16ArraySupport();
24+
if ( bool ) {
25+
console.log( 'Environment has Int16Array support.' );
26+
} else {
27+
console.log( 'Environment lacks Int16Array support.' );
28+
}

‎lib/index.js

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/**
2+
* @license Apache-2.0
3+
*
4+
* Copyright (c) 2018 The Stdlib Authors.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
'use strict';
20+
21+
/**
22+
* Test for native `Int16Array` support.
23+
*
24+
* @module @stdlib/assert/has-int16array-support
25+
*
26+
* @example
27+
* var hasInt16ArraySupport = require( '@stdlib/assert-has-int16array-support' );
28+
*
29+
* var bool = hasInt16ArraySupport();
30+
* // returns <boolean>
31+
*/
32+
33+
// MODULES //
34+
35+
var hasInt16ArraySupport = require( './main.js' );
36+
37+
38+
// EXPORTS //
39+
40+
module.exports = hasInt16ArraySupport;

‎lib/int16array.js

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/**
2+
* @license Apache-2.0
3+
*
4+
* Copyright (c) 2018 The Stdlib Authors.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
'use strict';
20+
21+
// MAIN //
22+
23+
var main = ( typeof Int16Array === 'function' ) ? Int16Array : null; // eslint-disable-line stdlib/require-globals
24+
25+
26+
// EXPORTS //
27+
28+
module.exports = main;

‎lib/main.js

+66
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
/**
2+
* @license Apache-2.0
3+
*
4+
* Copyright (c) 2018 The Stdlib Authors.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
'use strict';
20+
21+
// MODULES //
22+
23+
var isInt16Array = require( '@stdlib/assert-is-int16array' );
24+
var INT16_MAX = require( '@stdlib/constants-int16-max' );
25+
var INT16_MIN = require( '@stdlib/constants-int16-min' );
26+
var GlobalInt16Array = require( './int16array.js' );
27+
28+
29+
// MAIN //
30+
31+
/**
32+
* Tests for native `Int16Array` support.
33+
*
34+
* @returns {boolean} boolean indicating if an environment has `Int16Array` support
35+
*
36+
* @example
37+
* var bool = hasInt16ArraySupport();
38+
* // returns <boolean>
39+
*/
40+
function hasInt16ArraySupport() {
41+
var bool;
42+
var arr;
43+
44+
if ( typeof GlobalInt16Array !== 'function' ) {
45+
return false;
46+
}
47+
// Test basic support...
48+
try {
49+
arr = new GlobalInt16Array( [ 1, 3.14, -3.14, INT16_MAX+1 ] );
50+
bool = (
51+
isInt16Array( arr ) &&
52+
arr[ 0 ] === 1 &&
53+
arr[ 1 ] === 3 && // truncation
54+
arr[ 2 ] === -3 && // truncation
55+
arr[ 3 ] === INT16_MIN // wrap around
56+
);
57+
} catch ( err ) { // eslint-disable-line no-unused-vars
58+
bool = false;
59+
}
60+
return bool;
61+
}
62+
63+
64+
// EXPORTS //
65+
66+
module.exports = hasInt16ArraySupport;

‎package.json

+101
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
{
2+
"name": "@stdlib/assert-has-int16array-support",
3+
"version": "0.0.0",
4+
"description": "Detect native Int16Array support.",
5+
"license": "Apache-2.0",
6+
"author": {
7+
"name": "The Stdlib Authors",
8+
"url": "https://github.com/stdlib-js/stdlib/graphs/contributors"
9+
},
10+
"contributors": [
11+
{
12+
"name": "The Stdlib Authors",
13+
"url": "https://github.com/stdlib-js/stdlib/graphs/contributors"
14+
}
15+
],
16+
"bin": {
17+
"has-int16array-support": "./bin/cli"
18+
},
19+
"main": "./lib",
20+
"directories": {
21+
"benchmark": "./benchmark",
22+
"bin": "./bin",
23+
"doc": "./docs",
24+
"example": "./examples",
25+
"lib": "./lib",
26+
"test": "./test"
27+
},
28+
"types": "./docs/types",
29+
"scripts": {
30+
"test": "make test",
31+
"test-cov": "make test-cov",
32+
"examples": "make examples"
33+
},
34+
"homepage": "https://github.com/stdlib-js/stdlib",
35+
"repository": {
36+
"type": "git",
37+
"url": "git://github.com/stdlib-js/assert-has-int16array-support.git"
38+
},
39+
"bugs": {
40+
"url": "https://github.com/stdlib-js/stdlib/issues"
41+
},
42+
"dependencies": {
43+
"@stdlib/assert-is-int16array": "^0.0.x",
44+
"@stdlib/cli": "^0.0.x",
45+
"@stdlib/constants-int16-max": "^0.0.x",
46+
"@stdlib/constants-int16-min": "^0.0.x",
47+
"@stdlib/fs-read-file": "^0.0.x"
48+
},
49+
"devDependencies": {
50+
"@stdlib/array-int16": "^0.0.x",
51+
"@stdlib/assert-is-boolean": "^0.0.x",
52+
"@stdlib/assert-is-browser": "^0.0.x",
53+
"@stdlib/assert-is-windows": "^0.0.x",
54+
"@stdlib/bench": "^0.0.x",
55+
"@stdlib/process-exec-path": "^0.0.x",
56+
"proxyquire": "^2.0.0",
57+
"tape": "git+https://github.com/kgryte/tape.git#fix/globby",
58+
"istanbul": "^0.4.1",
59+
"tap-spec": "5.x.x"
60+
},
61+
"engines": {
62+
"node": ">=0.10.0",
63+
"npm": ">2.7.0"
64+
},
65+
"os": [
66+
"aix",
67+
"darwin",
68+
"freebsd",
69+
"linux",
70+
"macos",
71+
"openbsd",
72+
"sunos",
73+
"win32",
74+
"windows"
75+
],
76+
"keywords": [
77+
"stdlib",
78+
"stdutils",
79+
"stdutil",
80+
"utilities",
81+
"utility",
82+
"utils",
83+
"util",
84+
"detect",
85+
"feature",
86+
"int16array",
87+
"es2015",
88+
"es6",
89+
"typed array",
90+
"typed-array",
91+
"support",
92+
"has",
93+
"native",
94+
"issupported",
95+
"cli"
96+
],
97+
"funding": {
98+
"type": "patreon",
99+
"url": "https://www.patreon.com/athan"
100+
}
101+
}

‎test/test.cli.js

+163
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,163 @@
1+
/**
2+
* @license Apache-2.0
3+
*
4+
* Copyright (c) 2018 The Stdlib Authors.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
'use strict';
20+
21+
// MODULES //
22+
23+
var resolve = require( 'path' ).resolve;
24+
var exec = require( 'child_process' ).exec;
25+
var tape = require( 'tape' );
26+
var IS_BROWSER = require( '@stdlib/assert-is-browser' );
27+
var IS_WINDOWS = require( '@stdlib/assert-is-windows' );
28+
var EXEC_PATH = require( '@stdlib/process-exec-path' );
29+
var readFileSync = require( '@stdlib/fs-read-file' ).sync;
30+
31+
32+
// VARIABLES //
33+
34+
var fpath = resolve( __dirname, '..', 'bin', 'cli' );
35+
var opts = {
36+
'skip': IS_BROWSER || IS_WINDOWS
37+
};
38+
39+
40+
// FIXTURES //
41+
42+
var PKG_VERSION = require( './../package.json' ).version;
43+
44+
45+
// TESTS //
46+
47+
tape( 'command-line interface', function test( t ) {
48+
t.ok( true, __filename );
49+
t.end();
50+
});
51+
52+
tape( 'when invoked with a `--help` flag, the command-line interface prints the help text to `stderr`', opts, function test( t ) {
53+
var expected;
54+
var cmd;
55+
56+
expected = readFileSync( resolve( __dirname, '..', 'docs', 'usage.txt' ), {
57+
'encoding': 'utf8'
58+
});
59+
cmd = [
60+
EXEC_PATH,
61+
fpath,
62+
'--help'
63+
];
64+
65+
exec( cmd.join( ' ' ), done );
66+
67+
function done( error, stdout, stderr ) {
68+
if ( error ) {
69+
t.fail( error.message );
70+
} else {
71+
t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' );
72+
t.strictEqual( stderr.toString(), expected+'\n', 'expected value' );
73+
}
74+
t.end();
75+
}
76+
});
77+
78+
tape( 'when invoked with a `-h` flag, the command-line interface prints the help text to `stderr`', opts, function test( t ) {
79+
var expected;
80+
var cmd;
81+
82+
expected = readFileSync( resolve( __dirname, '..', 'docs', 'usage.txt' ), {
83+
'encoding': 'utf8'
84+
});
85+
cmd = [
86+
EXEC_PATH,
87+
fpath,
88+
'-h'
89+
];
90+
91+
exec( cmd.join( ' ' ), done );
92+
93+
function done( error, stdout, stderr ) {
94+
if ( error ) {
95+
t.fail( error.message );
96+
} else {
97+
t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' );
98+
t.strictEqual( stderr.toString(), expected+'\n', 'expected value' );
99+
}
100+
t.end();
101+
}
102+
});
103+
104+
tape( 'when invoked with a `--version` flag, the command-line interface prints the version to `stderr`', opts, function test( t ) {
105+
var cmd = [
106+
EXEC_PATH,
107+
fpath,
108+
'--version'
109+
];
110+
111+
exec( cmd.join( ' ' ), done );
112+
113+
function done( error, stdout, stderr ) {
114+
if ( error ) {
115+
t.fail( error.message );
116+
} else {
117+
t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' );
118+
t.strictEqual( stderr.toString(), PKG_VERSION+'\n', 'expected value' );
119+
}
120+
t.end();
121+
}
122+
});
123+
124+
tape( 'when invoked with a `-V` flag, the command-line interface prints the version to `stderr`', opts, function test( t ) {
125+
var cmd = [
126+
EXEC_PATH,
127+
fpath,
128+
'-V'
129+
];
130+
131+
exec( cmd.join( ' ' ), done );
132+
133+
function done( error, stdout, stderr ) {
134+
if ( error ) {
135+
t.fail( error.message );
136+
} else {
137+
t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' );
138+
t.strictEqual( stderr.toString(), PKG_VERSION+'\n', 'expected value' );
139+
}
140+
t.end();
141+
}
142+
});
143+
144+
tape( 'the command-line interface prints either `true` or `false` to `stdout` indicating whether an environment provides native `Int16Array` support', opts, function test( t ) {
145+
var cmd = [
146+
EXEC_PATH,
147+
fpath
148+
];
149+
150+
exec( cmd.join( ' ' ), done );
151+
152+
function done( error, stdout, stderr ) {
153+
var str;
154+
if ( error ) {
155+
t.fail( error.message );
156+
} else {
157+
str = stdout.toString();
158+
t.strictEqual( str === 'true\n' || str === 'false\n', true, 'prints either `true` or `false` to `stdout`' );
159+
t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' );
160+
}
161+
t.end();
162+
}
163+
});

‎test/test.js

+134
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
/**
2+
* @license Apache-2.0
3+
*
4+
* Copyright (c) 2018 The Stdlib Authors.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
'use strict';
20+
21+
// MODULES //
22+
23+
var tape = require( 'tape' );
24+
var proxyquire = require( 'proxyquire' );
25+
var Int16Array = require( '@stdlib/array-int16' );
26+
var detect = require( './../lib' );
27+
28+
29+
// VARIABLES //
30+
31+
var hasInt16Array = ( typeof Int16Array === 'function' );
32+
33+
34+
// TESTS //
35+
36+
tape( 'main export is a function', function test( t ) {
37+
t.ok( true, __filename );
38+
t.strictEqual( typeof detect, 'function', 'main export is a function' );
39+
t.end();
40+
});
41+
42+
tape( 'feature detection result is a boolean', function test( t ) {
43+
t.strictEqual( typeof detect(), 'boolean', 'detection result is a boolean' );
44+
t.end();
45+
});
46+
47+
tape( 'if `Int16Array` is supported, detection result is `true`', function test( t ) {
48+
var mocked;
49+
if ( hasInt16Array ) {
50+
t.strictEqual( detect(), true, 'detection result is `true`' );
51+
} else {
52+
t.strictEqual( detect(), false, 'detection result is `false`' );
53+
}
54+
mocked = proxyquire( './../lib/main.js', {
55+
'./int16array.js': Mock,
56+
'@stdlib/assert/is-int16array': isArray
57+
});
58+
t.strictEqual( mocked(), true, 'detection result is `true` (mocked)' );
59+
60+
t.end();
61+
62+
function isArray() {
63+
return true;
64+
}
65+
66+
function Mock() {
67+
return [
68+
1,
69+
3,
70+
-3,
71+
-32768
72+
];
73+
}
74+
});
75+
76+
tape( 'if `Int16Array` is not supported, detection result is `false`', function test( t ) {
77+
var mocked;
78+
if ( hasInt16Array ) {
79+
t.strictEqual( detect(), true, 'detection result is `true`' );
80+
} else {
81+
t.strictEqual( detect(), false, 'detection result is `false`' );
82+
}
83+
mocked = proxyquire( './../lib/main.js', {
84+
'./int16array.js': {}
85+
});
86+
t.strictEqual( mocked(), false, 'detection result is `false`' );
87+
88+
mocked = proxyquire( './../lib/main.js', {
89+
'./int16array.js': Mock1
90+
});
91+
t.strictEqual( mocked(), false, 'detection result is `false`' );
92+
93+
mocked = proxyquire( './../lib/main.js', {
94+
'./int16array.js': Mock2,
95+
'@stdlib/assert/is-int16array': isArray
96+
});
97+
t.strictEqual( mocked(), false, 'detection result is `false`' );
98+
99+
mocked = proxyquire( './../lib/main.js', {
100+
'./int16array.js': Mock3,
101+
'@stdlib/assert/is-int16array': isArray
102+
});
103+
t.strictEqual( mocked(), false, 'detection result is `false`' );
104+
105+
mocked = proxyquire( './../lib/main.js', {
106+
'./int16array.js': Mock4
107+
});
108+
t.strictEqual( mocked(), false, 'detection result is `false`' );
109+
110+
t.end();
111+
112+
function isArray() {
113+
return true;
114+
}
115+
116+
function Mock1() {
117+
// Not a typed array:
118+
return [];
119+
}
120+
121+
function Mock2() {
122+
// Does not truncate...
123+
return [ 1, 3.14, -3.14, -32768 ];
124+
}
125+
126+
function Mock3() {
127+
// Does not wrap around...
128+
return [ 1, 3, -3, 32768 ];
129+
}
130+
131+
function Mock4() {
132+
throw new Error( 'beep' );
133+
}
134+
});

0 commit comments

Comments
 (0)
Please sign in to comment.