@stdlib/array-nans 0.0.1 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/NOTICE +1 -1
- package/README.md +39 -4
- package/SECURITY.md +5 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +5 -0
- package/dist/index.js.map +7 -0
- package/docs/types/index.d.ts +3 -3
- package/lib/main.js +8 -3
- package/package.json +27 -22
- package/docs/repl.txt +0 -37
- package/docs/types/test.ts +0 -70
package/NOTICE
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Copyright (c) 2016-
|
|
1
|
+
Copyright (c) 2016-2024 The Stdlib Authors.
|
package/README.md
CHANGED
|
@@ -18,6 +18,17 @@ limitations under the License.
|
|
|
18
18
|
|
|
19
19
|
-->
|
|
20
20
|
|
|
21
|
+
|
|
22
|
+
<details>
|
|
23
|
+
<summary>
|
|
24
|
+
About stdlib...
|
|
25
|
+
</summary>
|
|
26
|
+
<p>We believe in a future in which the web is a preferred environment for numerical computation. To help realize this future, we've built stdlib. stdlib is a standard library, with an emphasis on numerical and scientific computation, written in JavaScript (and C) for execution in browsers and in Node.js.</p>
|
|
27
|
+
<p>The library is fully decomposable, being architected in such a way that you can swap out and mix and match APIs and functionality to cater to your exact preferences and use cases.</p>
|
|
28
|
+
<p>When you use stdlib, you can be absolutely certain that you are using the most thorough, rigorous, well-written, studied, documented, tested, measured, and high-quality code out there.</p>
|
|
29
|
+
<p>To join us in bringing numerical computing to the web, get started by checking us out on <a href="https://github.com/stdlib-js/stdlib">GitHub</a>, and please consider <a href="https://opencollective.com/stdlib">financially supporting stdlib</a>. We greatly appreciate your continued support!</p>
|
|
30
|
+
</details>
|
|
31
|
+
|
|
21
32
|
# nans
|
|
22
33
|
|
|
23
34
|
[![NPM version][npm-image]][npm-url] [![Build Status][test-image]][test-url] [![Coverage Status][coverage-image]][coverage-url] <!-- [![dependencies][dependencies-image]][dependencies-url] -->
|
|
@@ -132,6 +143,15 @@ for ( i = 0; i < dt.length; i++ ) {
|
|
|
132
143
|
|
|
133
144
|
<section class="related">
|
|
134
145
|
|
|
146
|
+
* * *
|
|
147
|
+
|
|
148
|
+
## See Also
|
|
149
|
+
|
|
150
|
+
- <span class="package-name">[`@stdlib/array-full`][@stdlib/array/full]</span><span class="delimiter">: </span><span class="description">create a filled array having a specified length.</span>
|
|
151
|
+
- <span class="package-name">[`@stdlib/array-nans-like`][@stdlib/array/nans-like]</span><span class="delimiter">: </span><span class="description">create an array filled with NaNs and having the same length and data type as a provided array.</span>
|
|
152
|
+
- <span class="package-name">[`@stdlib/array-ones`][@stdlib/array/ones]</span><span class="delimiter">: </span><span class="description">create an array filled with ones and having a specified length.</span>
|
|
153
|
+
- <span class="package-name">[`@stdlib/array-zeros`][@stdlib/array/zeros]</span><span class="delimiter">: </span><span class="description">create a zero-filled array having a specified length.</span>
|
|
154
|
+
|
|
135
155
|
</section>
|
|
136
156
|
|
|
137
157
|
<!-- /.related -->
|
|
@@ -162,7 +182,7 @@ See [LICENSE][stdlib-license].
|
|
|
162
182
|
|
|
163
183
|
## Copyright
|
|
164
184
|
|
|
165
|
-
Copyright © 2016-
|
|
185
|
+
Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors].
|
|
166
186
|
|
|
167
187
|
</section>
|
|
168
188
|
|
|
@@ -175,8 +195,8 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors].
|
|
|
175
195
|
[npm-image]: http://img.shields.io/npm/v/@stdlib/array-nans.svg
|
|
176
196
|
[npm-url]: https://npmjs.org/package/@stdlib/array-nans
|
|
177
197
|
|
|
178
|
-
[test-image]: https://github.com/stdlib-js/array-nans/actions/workflows/test.yml/badge.svg?branch=v0.0
|
|
179
|
-
[test-url]: https://github.com/stdlib-js/array-nans/actions/workflows/test.yml?query=branch:v0.0
|
|
198
|
+
[test-image]: https://github.com/stdlib-js/array-nans/actions/workflows/test.yml/badge.svg?branch=v0.2.0
|
|
199
|
+
[test-url]: https://github.com/stdlib-js/array-nans/actions/workflows/test.yml?query=branch:v0.2.0
|
|
180
200
|
|
|
181
201
|
[coverage-image]: https://img.shields.io/codecov/c/github/stdlib-js/array-nans/main.svg
|
|
182
202
|
[coverage-url]: https://codecov.io/github/stdlib-js/array-nans?branch=main
|
|
@@ -189,7 +209,7 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors].
|
|
|
189
209
|
-->
|
|
190
210
|
|
|
191
211
|
[chat-image]: https://img.shields.io/gitter/room/stdlib-js/stdlib.svg
|
|
192
|
-
[chat-url]: https://gitter.im
|
|
212
|
+
[chat-url]: https://app.gitter.im/#/room/#stdlib-js_stdlib:gitter.im
|
|
193
213
|
|
|
194
214
|
[stdlib]: https://github.com/stdlib-js/stdlib
|
|
195
215
|
|
|
@@ -199,14 +219,29 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors].
|
|
|
199
219
|
[es-module]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules
|
|
200
220
|
|
|
201
221
|
[deno-url]: https://github.com/stdlib-js/array-nans/tree/deno
|
|
222
|
+
[deno-readme]: https://github.com/stdlib-js/array-nans/blob/deno/README.md
|
|
202
223
|
[umd-url]: https://github.com/stdlib-js/array-nans/tree/umd
|
|
224
|
+
[umd-readme]: https://github.com/stdlib-js/array-nans/blob/umd/README.md
|
|
203
225
|
[esm-url]: https://github.com/stdlib-js/array-nans/tree/esm
|
|
226
|
+
[esm-readme]: https://github.com/stdlib-js/array-nans/blob/esm/README.md
|
|
204
227
|
[branches-url]: https://github.com/stdlib-js/array-nans/blob/main/branches.md
|
|
205
228
|
|
|
206
229
|
[stdlib-license]: https://raw.githubusercontent.com/stdlib-js/array-nans/main/LICENSE
|
|
207
230
|
|
|
208
231
|
[mdn-typed-array]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray
|
|
209
232
|
|
|
233
|
+
<!-- <related-links> -->
|
|
234
|
+
|
|
235
|
+
[@stdlib/array/full]: https://www.npmjs.com/package/@stdlib/array-full
|
|
236
|
+
|
|
237
|
+
[@stdlib/array/nans-like]: https://www.npmjs.com/package/@stdlib/array-nans-like
|
|
238
|
+
|
|
239
|
+
[@stdlib/array/ones]: https://www.npmjs.com/package/@stdlib/array-ones
|
|
240
|
+
|
|
241
|
+
[@stdlib/array/zeros]: https://www.npmjs.com/package/@stdlib/array-zeros
|
|
242
|
+
|
|
243
|
+
<!-- </related-links> -->
|
|
244
|
+
|
|
210
245
|
</section>
|
|
211
246
|
|
|
212
247
|
<!-- /.links -->
|
package/SECURITY.md
ADDED
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
"use strict";var o=function(a,e){return function(){return e||a((e={exports:{}}).exports,e),e.exports}};var n=o(function(_,t){
|
|
2
|
+
var u=require('@stdlib/array-base-assert-contains/dist').factory,l=require('@stdlib/complex-float64/dist'),s=require('@stdlib/complex-float32/dist'),v=require('@stdlib/array-full/dist'),f=require('@stdlib/array-defaults/dist'),p=require('@stdlib/array-dtypes/dist'),m=require('@stdlib/error-tools-fmtprodmsg/dist'),g=new l(NaN,NaN),N=new s(NaN,NaN),i=p("floating_point_and_generic"),c=u(i),d=f.get("dtypes.real_floating_point");function q(a){var e,r;if(arguments.length>1){if(e=arguments[1],!c(e))throw new TypeError(m('1ZnDQ',i.join('", "'),e))}else e=d;return e==="complex128"?r=g:e==="complex64"?r=N:r=NaN,v(a,r,e)}t.exports=q
|
|
3
|
+
});var x=n();module.exports=x;
|
|
4
|
+
/** @license Apache-2.0 */
|
|
5
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../lib/main.js", "../lib/index.js"],
|
|
4
|
+
"sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar contains = require( '@stdlib/array-base-assert-contains' ).factory;\nvar Complex128 = require( '@stdlib/complex-float64' );\nvar Complex64 = require( '@stdlib/complex-float32' );\nvar full = require( '@stdlib/array-full' );\nvar defaults = require( '@stdlib/array-defaults' );\nvar dtypes = require( '@stdlib/array-dtypes' );\nvar format = require( '@stdlib/string-format' );\n\n\n// VARIABLES //\n\nvar Z128 = new Complex128( NaN, NaN );\nvar Z64 = new Complex64( NaN, NaN );\nvar DTYPES = dtypes( 'floating_point_and_generic' );\nvar isValidDType = contains( DTYPES );\nvar DEFAULT_DTYPE = defaults.get( 'dtypes.real_floating_point' );\n\n\n// MAIN //\n\n/**\n* Creates an array filled with NaNs and having a specified length.\n*\n* @param {NonNegativeInteger} length - array length\n* @param {string} [dtype=\"float64\"] - data type\n* @throws {TypeError} first argument must be a nonnegative integer\n* @throws {TypeError} second argument must be a supported data type\n* @returns {(TypedArray|Array|ComplexArray)} array or typed array\n*\n* @example\n* var arr = nans( 2 );\n* // returns <Float64Array>[ NaN, NaN ]\n*\n* @example\n* var arr = nans( 2, 'float32' );\n* // returns <Float32Array>[ NaN, NaN ]\n*/\nfunction nans( length ) {\n\tvar dtype;\n\tvar value;\n\n\tif ( arguments.length > 1 ) {\n\t\tdtype = arguments[ 1 ];\n\t\tif ( !isValidDType( dtype ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Second argument must be one of the following: \"%s\". Value: `%s`.', DTYPES.join( '\", \"' ), dtype ) );\n\t\t}\n\t} else {\n\t\tdtype = DEFAULT_DTYPE;\n\t}\n\tif ( dtype === 'complex128' ) {\n\t\tvalue = Z128;\n\t} else if ( dtype === 'complex64' ) {\n\t\tvalue = Z64;\n\t} else {\n\t\tvalue = NaN;\n\t}\n\treturn full( length, value, dtype );\n}\n\n\n// EXPORTS //\n\nmodule.exports = nans;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create an array filled with NaNs and having a specified length.\n*\n* @module @stdlib/array-nans\n*\n* @example\n* var nans = require( '@stdlib/array-nans' );\n*\n* var arr = nans( 2 );\n* // returns <Float64Array>[ NaN, NaN ]\n*\n* @example\n* var nans = require( '@stdlib/array-nans' );\n*\n* var arr = nans( 2, 'float32' );\n* // returns <Float32Array>[ NaN, NaN ]\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"],
|
|
5
|
+
"mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAW,QAAS,oCAAqC,EAAE,QAC3DC,EAAa,QAAS,yBAA0B,EAChDC,EAAY,QAAS,yBAA0B,EAC/CC,EAAO,QAAS,oBAAqB,EACrCC,EAAW,QAAS,wBAAyB,EAC7CC,EAAS,QAAS,sBAAuB,EACzCC,EAAS,QAAS,uBAAwB,EAK1CC,EAAO,IAAIN,EAAY,IAAK,GAAI,EAChCO,EAAM,IAAIN,EAAW,IAAK,GAAI,EAC9BO,EAASJ,EAAQ,4BAA6B,EAC9CK,EAAeV,EAAUS,CAAO,EAChCE,EAAgBP,EAAS,IAAK,4BAA6B,EAsB/D,SAASQ,EAAMC,EAAS,CACvB,IAAIC,EACAC,EAEJ,GAAK,UAAU,OAAS,GAEvB,GADAD,EAAQ,UAAW,CAAE,EAChB,CAACJ,EAAcI,CAAM,EACzB,MAAM,IAAI,UAAWR,EAAQ,qFAAsFG,EAAO,KAAM,MAAO,EAAGK,CAAM,CAAE,OAGnJA,EAAQH,EAET,OAAKG,IAAU,aACdC,EAAQR,EACGO,IAAU,YACrBC,EAAQP,EAERO,EAAQ,IAEFZ,EAAMU,EAAQE,EAAOD,CAAM,CACnC,CAKAf,EAAO,QAAUa,IC5CjB,IAAII,EAAO,IAKX,OAAO,QAAUA",
|
|
6
|
+
"names": ["require_main", "__commonJSMin", "exports", "module", "contains", "Complex128", "Complex64", "full", "defaults", "dtypes", "format", "Z128", "Z64", "DTYPES", "isValidDType", "DEFAULT_DTYPE", "nans", "length", "dtype", "value", "main"]
|
|
7
|
+
}
|
package/docs/types/index.d.ts
CHANGED
|
@@ -16,16 +16,16 @@
|
|
|
16
16
|
* limitations under the License.
|
|
17
17
|
*/
|
|
18
18
|
|
|
19
|
-
// TypeScript Version:
|
|
19
|
+
// TypeScript Version: 4.1
|
|
20
20
|
|
|
21
21
|
/// <reference types="@stdlib/types"/>
|
|
22
22
|
|
|
23
|
-
import { Complex128Array, Complex64Array,
|
|
23
|
+
import { Complex128Array, Complex64Array, FloatingPointDataType } from '@stdlib/types/array';
|
|
24
24
|
|
|
25
25
|
/**
|
|
26
26
|
* Data type.
|
|
27
27
|
*/
|
|
28
|
-
type DataType =
|
|
28
|
+
type DataType = FloatingPointDataType | 'generic';
|
|
29
29
|
|
|
30
30
|
/**
|
|
31
31
|
* Creates an array filled with NaNs and having a specified length.
|
package/lib/main.js
CHANGED
|
@@ -20,9 +20,12 @@
|
|
|
20
20
|
|
|
21
21
|
// MODULES //
|
|
22
22
|
|
|
23
|
+
var contains = require( '@stdlib/array-base-assert-contains' ).factory;
|
|
23
24
|
var Complex128 = require( '@stdlib/complex-float64' );
|
|
24
25
|
var Complex64 = require( '@stdlib/complex-float32' );
|
|
25
26
|
var full = require( '@stdlib/array-full' );
|
|
27
|
+
var defaults = require( '@stdlib/array-defaults' );
|
|
28
|
+
var dtypes = require( '@stdlib/array-dtypes' );
|
|
26
29
|
var format = require( '@stdlib/string-format' );
|
|
27
30
|
|
|
28
31
|
|
|
@@ -30,7 +33,9 @@ var format = require( '@stdlib/string-format' );
|
|
|
30
33
|
|
|
31
34
|
var Z128 = new Complex128( NaN, NaN );
|
|
32
35
|
var Z64 = new Complex64( NaN, NaN );
|
|
33
|
-
var DTYPES =
|
|
36
|
+
var DTYPES = dtypes( 'floating_point_and_generic' );
|
|
37
|
+
var isValidDType = contains( DTYPES );
|
|
38
|
+
var DEFAULT_DTYPE = defaults.get( 'dtypes.real_floating_point' );
|
|
34
39
|
|
|
35
40
|
|
|
36
41
|
// MAIN //
|
|
@@ -58,11 +63,11 @@ function nans( length ) {
|
|
|
58
63
|
|
|
59
64
|
if ( arguments.length > 1 ) {
|
|
60
65
|
dtype = arguments[ 1 ];
|
|
61
|
-
if (
|
|
66
|
+
if ( !isValidDType( dtype ) ) {
|
|
62
67
|
throw new TypeError( format( 'invalid argument. Second argument must be one of the following: "%s". Value: `%s`.', DTYPES.join( '", "' ), dtype ) );
|
|
63
68
|
}
|
|
64
69
|
} else {
|
|
65
|
-
dtype =
|
|
70
|
+
dtype = DEFAULT_DTYPE;
|
|
66
71
|
}
|
|
67
72
|
if ( dtype === 'complex128' ) {
|
|
68
73
|
value = Z128;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stdlib/array-nans",
|
|
3
|
-
"version": "0.0
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Create an array filled with NaNs and having a specified length.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": {
|
|
@@ -37,31 +37,36 @@
|
|
|
37
37
|
"url": "https://github.com/stdlib-js/stdlib/issues"
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@stdlib/array-
|
|
41
|
-
"@stdlib/
|
|
42
|
-
"@stdlib/
|
|
43
|
-
"@stdlib/
|
|
44
|
-
"@stdlib/
|
|
40
|
+
"@stdlib/array-base-assert-contains": "^0.2.0",
|
|
41
|
+
"@stdlib/array-defaults": "^0.2.0",
|
|
42
|
+
"@stdlib/array-dtypes": "^0.2.0",
|
|
43
|
+
"@stdlib/array-full": "^0.2.0",
|
|
44
|
+
"@stdlib/complex-float32": "^0.2.0",
|
|
45
|
+
"@stdlib/complex-float64": "^0.2.0",
|
|
46
|
+
"@stdlib/string-format": "^0.2.0",
|
|
47
|
+
"@stdlib/types": "^0.3.1",
|
|
48
|
+
"@stdlib/error-tools-fmtprodmsg": "^0.2.0"
|
|
45
49
|
},
|
|
46
50
|
"devDependencies": {
|
|
47
|
-
"@stdlib/array-complex128": "^0.0
|
|
48
|
-
"@stdlib/array-complex64": "^0.0
|
|
49
|
-
"@stdlib/array-float32": "^0.0
|
|
50
|
-
"@stdlib/array-float64": "^0.0
|
|
51
|
-
"@stdlib/array-typed-float-dtypes": "^0.0
|
|
52
|
-
"@stdlib/assert-instance-of": "^0.0
|
|
53
|
-
"@stdlib/assert-is-array": "^0.0
|
|
54
|
-
"@stdlib/assert-is-typed-array": "^0.0
|
|
55
|
-
"@stdlib/assert-is-typed-array-like": "^0.0
|
|
56
|
-
"@stdlib/
|
|
57
|
-
"@stdlib/math-base-assert-is-
|
|
58
|
-
"@stdlib/math-base-
|
|
59
|
-
"@stdlib/
|
|
60
|
-
"@stdlib/strided-base-reinterpret-
|
|
61
|
-
"@stdlib/strided-base-reinterpret-complex64": "^0.0.2",
|
|
51
|
+
"@stdlib/array-complex128": "^0.1.0",
|
|
52
|
+
"@stdlib/array-complex64": "^0.1.0",
|
|
53
|
+
"@stdlib/array-float32": "^0.2.0",
|
|
54
|
+
"@stdlib/array-float64": "^0.2.0",
|
|
55
|
+
"@stdlib/array-typed-float-dtypes": "^0.2.0",
|
|
56
|
+
"@stdlib/assert-instance-of": "^0.2.0",
|
|
57
|
+
"@stdlib/assert-is-array": "^0.2.0",
|
|
58
|
+
"@stdlib/assert-is-typed-array": "^0.2.0",
|
|
59
|
+
"@stdlib/assert-is-typed-array-like": "^0.2.0",
|
|
60
|
+
"@stdlib/math-base-assert-is-nan": "^0.2.0",
|
|
61
|
+
"@stdlib/math-base-assert-is-nanf": "^0.2.0",
|
|
62
|
+
"@stdlib/math-base-special-pow": "^0.2.0",
|
|
63
|
+
"@stdlib/strided-base-reinterpret-complex128": "^0.2.0",
|
|
64
|
+
"@stdlib/strided-base-reinterpret-complex64": "^0.2.0",
|
|
62
65
|
"tape": "git+https://github.com/kgryte/tape.git#fix/globby",
|
|
63
66
|
"istanbul": "^0.4.1",
|
|
64
|
-
"tap-min": "git+https://github.com/Planeshifter/tap-min.git"
|
|
67
|
+
"tap-min": "git+https://github.com/Planeshifter/tap-min.git",
|
|
68
|
+
"@stdlib/bench-harness": "^0.2.0",
|
|
69
|
+
"@stdlib/bench": "^0.3.1"
|
|
65
70
|
},
|
|
66
71
|
"engines": {
|
|
67
72
|
"node": ">=0.10.0",
|
package/docs/repl.txt
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
{{alias}}( length[, dtype] )
|
|
3
|
-
Returns an array filled with NaNs and having a specified length.
|
|
4
|
-
|
|
5
|
-
The function supports the following data types:
|
|
6
|
-
|
|
7
|
-
- float64: double-precision floating-point numbers (IEEE 754)
|
|
8
|
-
- float32: single-precision floating-point numbers (IEEE 754)
|
|
9
|
-
- complex128: double-precision complex floating-point numbers
|
|
10
|
-
- complex64: single-precision complex floating-point numbers
|
|
11
|
-
- generic: generic JavaScript values
|
|
12
|
-
|
|
13
|
-
The default array data type is `float64`.
|
|
14
|
-
|
|
15
|
-
Parameters
|
|
16
|
-
----------
|
|
17
|
-
length: integer
|
|
18
|
-
Array length.
|
|
19
|
-
|
|
20
|
-
dtype: string (optional)
|
|
21
|
-
Data type. Default: 'float64'.
|
|
22
|
-
|
|
23
|
-
Returns
|
|
24
|
-
-------
|
|
25
|
-
out: TypedArray|Array
|
|
26
|
-
Output array.
|
|
27
|
-
|
|
28
|
-
Examples
|
|
29
|
-
--------
|
|
30
|
-
> var arr = {{alias}}( 2 )
|
|
31
|
-
<Float64Array>[ NaN, NaN ]
|
|
32
|
-
> arr = {{alias}}( 2, 'float32' )
|
|
33
|
-
<Float32Array>[ NaN, NaN ]
|
|
34
|
-
|
|
35
|
-
See Also
|
|
36
|
-
--------
|
|
37
|
-
|
package/docs/types/test.ts
DELETED
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* @license Apache-2.0
|
|
3
|
-
*
|
|
4
|
-
* Copyright (c) 2023 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 nans = require( './index' );
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
// TESTS //
|
|
23
|
-
|
|
24
|
-
// The function returns an array or typed array...
|
|
25
|
-
{
|
|
26
|
-
nans( 10 ); // $ExpectType Float64Array
|
|
27
|
-
nans( 10, 'float64' ); // $ExpectType Float64Array
|
|
28
|
-
nans( 10, 'float32' ); // $ExpectType Float32Array
|
|
29
|
-
nans( 10, 'complex128' ); // $ExpectType Complex128Array
|
|
30
|
-
nans( 10, 'complex64' ); // $ExpectType Complex64Array
|
|
31
|
-
nans( 10, 'generic' ); // $ExpectType number[]
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
// The compiler throws an error if the function is not provided a number for the first argument...
|
|
35
|
-
{
|
|
36
|
-
nans( '5' ); // $ExpectError
|
|
37
|
-
nans( false ); // $ExpectError
|
|
38
|
-
nans( true ); // $ExpectError
|
|
39
|
-
nans( null ); // $ExpectError
|
|
40
|
-
nans( undefined ); // $ExpectError
|
|
41
|
-
nans( [] ); // $ExpectError
|
|
42
|
-
nans( {} ); // $ExpectError
|
|
43
|
-
nans( ( x: number ): number => x ); // $ExpectError
|
|
44
|
-
|
|
45
|
-
nans( '5', 'float32' ); // $ExpectError
|
|
46
|
-
nans( false, 'float32' ); // $ExpectError
|
|
47
|
-
nans( true, 'float32' ); // $ExpectError
|
|
48
|
-
nans( null, 'float32' ); // $ExpectError
|
|
49
|
-
nans( undefined, 'float32' ); // $ExpectError
|
|
50
|
-
nans( [], 'float32' ); // $ExpectError
|
|
51
|
-
nans( {}, 'float32' ); // $ExpectError
|
|
52
|
-
nans( ( x: number ): number => x, 'float32' ); // $ExpectError
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
// The compiler throws an error if the function is provided a second argument which is an unrecognized/unsupported data type...
|
|
56
|
-
{
|
|
57
|
-
nans( 10, '10' ); // $ExpectError
|
|
58
|
-
nans( 10, 10 ); // $ExpectError
|
|
59
|
-
nans( 10, false ); // $ExpectError
|
|
60
|
-
nans( 10, true ); // $ExpectError
|
|
61
|
-
nans( 10, null ); // $ExpectError
|
|
62
|
-
nans( 10, [] ); // $ExpectError
|
|
63
|
-
nans( 10, {} ); // $ExpectError
|
|
64
|
-
nans( 10, ( x: number ): number => x ); // $ExpectError
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
// The compiler throws an error if the function is provided an unsupported number of arguments...
|
|
68
|
-
{
|
|
69
|
-
nans( 10, 'float64', 1 ); // $ExpectError
|
|
70
|
-
}
|