@stdlib/array-nans 0.0.1 → 0.1.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/CITATION.cff +30 -0
- package/README.md +14 -3
- 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 +1 -1
- package/package.json +22 -21
- package/docs/repl.txt +0 -37
- package/docs/types/test.ts +0 -70
package/CITATION.cff
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
cff-version: 1.2.0
|
|
2
|
+
title: stdlib
|
|
3
|
+
message: >-
|
|
4
|
+
If you use this software, please cite it using the
|
|
5
|
+
metadata from this file.
|
|
6
|
+
|
|
7
|
+
type: software
|
|
8
|
+
|
|
9
|
+
authors:
|
|
10
|
+
- name: The Stdlib Authors
|
|
11
|
+
url: https://github.com/stdlib-js/stdlib/graphs/contributors
|
|
12
|
+
|
|
13
|
+
repository-code: https://github.com/stdlib-js/stdlib
|
|
14
|
+
url: https://stdlib.io
|
|
15
|
+
|
|
16
|
+
abstract: |
|
|
17
|
+
Standard library for JavaScript and Node.js.
|
|
18
|
+
|
|
19
|
+
keywords:
|
|
20
|
+
- JavaScript
|
|
21
|
+
- Node.js
|
|
22
|
+
- TypeScript
|
|
23
|
+
- standard library
|
|
24
|
+
- scientific computing
|
|
25
|
+
- numerical computing
|
|
26
|
+
- statistical computing
|
|
27
|
+
|
|
28
|
+
license: Apache-2.0 AND BSL-1.0
|
|
29
|
+
|
|
30
|
+
date-released: 2016
|
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] -->
|
|
@@ -175,8 +186,8 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors].
|
|
|
175
186
|
[npm-image]: http://img.shields.io/npm/v/@stdlib/array-nans.svg
|
|
176
187
|
[npm-url]: https://npmjs.org/package/@stdlib/array-nans
|
|
177
188
|
|
|
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
|
|
189
|
+
[test-image]: https://github.com/stdlib-js/array-nans/actions/workflows/test.yml/badge.svg?branch=v0.1.0
|
|
190
|
+
[test-url]: https://github.com/stdlib-js/array-nans/actions/workflows/test.yml?query=branch:v0.1.0
|
|
180
191
|
|
|
181
192
|
[coverage-image]: https://img.shields.io/codecov/c/github/stdlib-js/array-nans/main.svg
|
|
182
193
|
[coverage-url]: https://codecov.io/github/stdlib-js/array-nans?branch=main
|
|
@@ -189,7 +200,7 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors].
|
|
|
189
200
|
-->
|
|
190
201
|
|
|
191
202
|
[chat-image]: https://img.shields.io/gitter/room/stdlib-js/stdlib.svg
|
|
192
|
-
[chat-url]: https://gitter.im
|
|
203
|
+
[chat-url]: https://app.gitter.im/#/room/#stdlib-js_stdlib:gitter.im
|
|
193
204
|
|
|
194
205
|
[stdlib]: https://github.com/stdlib-js/stdlib
|
|
195
206
|
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
"use strict";var l=function(a,e){return function(){return e||a((e={exports:{}}).exports,e),e.exports}};var t=l(function(x,o){
|
|
2
|
+
var i=require('@stdlib/complex-float64/dist'),u=require('@stdlib/complex-float32/dist'),s=require('@stdlib/array-full/dist'),f=require('@stdlib/error-tools-fmtprodmsg/dist'),m=new i(NaN,NaN),v=new u(NaN,NaN),n=["float64","float32","complex128","complex64","generic"];function p(a){var e,r;if(arguments.length>1){if(e=arguments[1],n.indexOf(e)===-1)throw new TypeError(f('1ZnDQ',n.join('", "'),e))}else e="float64";return e==="complex128"?r=m:e==="complex64"?r=v:r=NaN,s(a,r,e)}o.exports=p
|
|
3
|
+
});var N=t();module.exports=N;
|
|
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 Complex128 = require( '@stdlib/complex-float64' );\nvar Complex64 = require( '@stdlib/complex-float32' );\nvar full = require( '@stdlib/array-full' );\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 = [ 'float64', 'float32', 'complex128', 'complex64', 'generic' ];\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 ( DTYPES.indexOf( dtype ) === -1 ) {\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 = 'float64';\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,EAAa,QAAS,yBAA0B,EAChDC,EAAY,QAAS,yBAA0B,EAC/CC,EAAO,QAAS,oBAAqB,EACrCC,EAAS,QAAS,uBAAwB,EAK1CC,EAAO,IAAIJ,EAAY,IAAK,GAAI,EAChCK,EAAM,IAAIJ,EAAW,IAAK,GAAI,EAC9BK,EAAS,CAAE,UAAW,UAAW,aAAc,YAAa,SAAU,EAsB1E,SAASC,EAAMC,EAAS,CACvB,IAAIC,EACAC,EAEJ,GAAK,UAAU,OAAS,GAEvB,GADAD,EAAQ,UAAW,CAAE,EAChBH,EAAO,QAASG,CAAM,IAAM,GAChC,MAAM,IAAI,UAAWN,EAAQ,qFAAsFG,EAAO,KAAM,MAAO,EAAGG,CAAM,CAAE,OAGnJA,EAAQ,UAET,OAAKA,IAAU,aACdC,EAAQN,EACGK,IAAU,YACrBC,EAAQL,EAERK,EAAQ,IAEFR,EAAMM,EAAQE,EAAOD,CAAM,CACnC,CAKAV,EAAO,QAAUQ,ICvCjB,IAAII,EAAO,IAKX,OAAO,QAAUA",
|
|
6
|
+
"names": ["require_main", "__commonJSMin", "exports", "module", "Complex128", "Complex64", "full", "format", "Z128", "Z64", "DTYPES", "nans", "length", "dtype", "value", "main"]
|
|
7
|
+
}
|
package/docs/types/index.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stdlib/array-nans",
|
|
3
|
-
"version": "0.0
|
|
3
|
+
"version": "0.1.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,28 +37,29 @@
|
|
|
37
37
|
"url": "https://github.com/stdlib-js/stdlib/issues"
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@stdlib/array-full": "^0.0
|
|
41
|
-
"@stdlib/complex-float32": "^0.0
|
|
42
|
-
"@stdlib/complex-float64": "^0.0
|
|
43
|
-
"@stdlib/string-format": "^0.0
|
|
44
|
-
"@stdlib/types": "^0.0
|
|
40
|
+
"@stdlib/array-full": "^0.1.0",
|
|
41
|
+
"@stdlib/complex-float32": "^0.1.0",
|
|
42
|
+
"@stdlib/complex-float64": "^0.1.0",
|
|
43
|
+
"@stdlib/string-format": "^0.1.0",
|
|
44
|
+
"@stdlib/types": "^0.1.0",
|
|
45
|
+
"@stdlib/error-tools-fmtprodmsg": "^0.1.0"
|
|
45
46
|
},
|
|
46
47
|
"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/bench": "^0.0
|
|
57
|
-
"@stdlib/math-base-assert-is-nan": "^0.0
|
|
58
|
-
"@stdlib/math-base-assert-is-nanf": "^0.0
|
|
59
|
-
"@stdlib/math-base-special-pow": "^0.0
|
|
60
|
-
"@stdlib/strided-base-reinterpret-complex128": "^0.0
|
|
61
|
-
"@stdlib/strided-base-reinterpret-complex64": "^0.0
|
|
48
|
+
"@stdlib/array-complex128": "^0.1.0",
|
|
49
|
+
"@stdlib/array-complex64": "^0.1.0",
|
|
50
|
+
"@stdlib/array-float32": "^0.1.0",
|
|
51
|
+
"@stdlib/array-float64": "^0.1.0",
|
|
52
|
+
"@stdlib/array-typed-float-dtypes": "^0.1.0",
|
|
53
|
+
"@stdlib/assert-instance-of": "^0.1.0",
|
|
54
|
+
"@stdlib/assert-is-array": "^0.1.0",
|
|
55
|
+
"@stdlib/assert-is-typed-array": "^0.1.0",
|
|
56
|
+
"@stdlib/assert-is-typed-array-like": "^0.1.0",
|
|
57
|
+
"@stdlib/bench": "^0.1.0",
|
|
58
|
+
"@stdlib/math-base-assert-is-nan": "^0.1.0",
|
|
59
|
+
"@stdlib/math-base-assert-is-nanf": "^0.1.0",
|
|
60
|
+
"@stdlib/math-base-special-pow": "^0.1.0",
|
|
61
|
+
"@stdlib/strided-base-reinterpret-complex128": "^0.1.0",
|
|
62
|
+
"@stdlib/strided-base-reinterpret-complex64": "^0.1.0",
|
|
62
63
|
"tape": "git+https://github.com/kgryte/tape.git#fix/globby",
|
|
63
64
|
"istanbul": "^0.4.1",
|
|
64
65
|
"tap-min": "git+https://github.com/Planeshifter/tap-min.git"
|
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
|
-
}
|