@stdlib/array-nans 0.1.0 → 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 +27 -3
- package/SECURITY.md +5 -0
- package/dist/index.js +3 -3
- package/dist/index.js.map +3 -3
- package/docs/types/index.d.ts +2 -2
- package/lib/main.js +8 -3
- package/package.json +25 -21
- package/CITATION.cff +0 -30
package/NOTICE
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Copyright (c) 2016-
|
|
1
|
+
Copyright (c) 2016-2024 The Stdlib Authors.
|
package/README.md
CHANGED
|
@@ -143,6 +143,15 @@ for ( i = 0; i < dt.length; i++ ) {
|
|
|
143
143
|
|
|
144
144
|
<section class="related">
|
|
145
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
|
+
|
|
146
155
|
</section>
|
|
147
156
|
|
|
148
157
|
<!-- /.related -->
|
|
@@ -173,7 +182,7 @@ See [LICENSE][stdlib-license].
|
|
|
173
182
|
|
|
174
183
|
## Copyright
|
|
175
184
|
|
|
176
|
-
Copyright © 2016-
|
|
185
|
+
Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors].
|
|
177
186
|
|
|
178
187
|
</section>
|
|
179
188
|
|
|
@@ -186,8 +195,8 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors].
|
|
|
186
195
|
[npm-image]: http://img.shields.io/npm/v/@stdlib/array-nans.svg
|
|
187
196
|
[npm-url]: https://npmjs.org/package/@stdlib/array-nans
|
|
188
197
|
|
|
189
|
-
[test-image]: https://github.com/stdlib-js/array-nans/actions/workflows/test.yml/badge.svg?branch=v0.
|
|
190
|
-
[test-url]: https://github.com/stdlib-js/array-nans/actions/workflows/test.yml?query=branch:v0.
|
|
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
|
|
191
200
|
|
|
192
201
|
[coverage-image]: https://img.shields.io/codecov/c/github/stdlib-js/array-nans/main.svg
|
|
193
202
|
[coverage-url]: https://codecov.io/github/stdlib-js/array-nans?branch=main
|
|
@@ -210,14 +219,29 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors].
|
|
|
210
219
|
[es-module]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules
|
|
211
220
|
|
|
212
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
|
|
213
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
|
|
214
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
|
|
215
227
|
[branches-url]: https://github.com/stdlib-js/array-nans/blob/main/branches.md
|
|
216
228
|
|
|
217
229
|
[stdlib-license]: https://raw.githubusercontent.com/stdlib-js/array-nans/main/LICENSE
|
|
218
230
|
|
|
219
231
|
[mdn-typed-array]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray
|
|
220
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
|
+
|
|
221
245
|
</section>
|
|
222
246
|
|
|
223
247
|
<!-- /.links -->
|
package/SECURITY.md
ADDED
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
"use strict";var
|
|
2
|
-
var
|
|
3
|
-
});var
|
|
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
4
|
/** @license Apache-2.0 */
|
|
5
5
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
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 =
|
|
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,
|
|
6
|
-
"names": ["require_main", "__commonJSMin", "exports", "module", "Complex128", "Complex64", "full", "format", "Z128", "Z64", "DTYPES", "nans", "length", "dtype", "value", "main"]
|
|
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
7
|
}
|
package/docs/types/index.d.ts
CHANGED
|
@@ -20,12 +20,12 @@
|
|
|
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.
|
|
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,32 +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/
|
|
45
|
-
"@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"
|
|
46
49
|
},
|
|
47
50
|
"devDependencies": {
|
|
48
51
|
"@stdlib/array-complex128": "^0.1.0",
|
|
49
52
|
"@stdlib/array-complex64": "^0.1.0",
|
|
50
|
-
"@stdlib/array-float32": "^0.
|
|
51
|
-
"@stdlib/array-float64": "^0.
|
|
52
|
-
"@stdlib/array-typed-float-dtypes": "^0.
|
|
53
|
-
"@stdlib/assert-instance-of": "^0.
|
|
54
|
-
"@stdlib/assert-is-array": "^0.
|
|
55
|
-
"@stdlib/assert-is-typed-array": "^0.
|
|
56
|
-
"@stdlib/assert-is-typed-array-like": "^0.
|
|
57
|
-
"@stdlib/
|
|
58
|
-
"@stdlib/math-base-assert-is-
|
|
59
|
-
"@stdlib/math-base-
|
|
60
|
-
"@stdlib/
|
|
61
|
-
"@stdlib/strided-base-reinterpret-
|
|
62
|
-
"@stdlib/strided-base-reinterpret-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",
|
|
63
65
|
"tape": "git+https://github.com/kgryte/tape.git#fix/globby",
|
|
64
66
|
"istanbul": "^0.4.1",
|
|
65
|
-
"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"
|
|
66
70
|
},
|
|
67
71
|
"engines": {
|
|
68
72
|
"node": ">=0.10.0",
|
package/CITATION.cff
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
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
|