@stdlib/ndarray-base-buffer 0.2.1 → 0.3.1
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 +16 -26
- package/dist/index.js +3 -5
- package/dist/index.js.map +4 -4
- package/docs/types/index.d.ts +3 -3
- package/lib/index.js +1 -1
- package/lib/main.js +13 -28
- package/package.json +7 -5
- package/lib/zeros.js +0 -45
package/NOTICE
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Copyright (c) 2016-
|
|
1
|
+
Copyright (c) 2016-2026 The Stdlib Authors.
|
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
@license Apache-2.0
|
|
4
4
|
|
|
5
|
-
Copyright (c)
|
|
5
|
+
Copyright (c) 2024 The Stdlib Authors.
|
|
6
6
|
|
|
7
7
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
8
8
|
you may not use this file except in compliance with the License.
|
|
@@ -33,7 +33,7 @@ limitations under the License.
|
|
|
33
33
|
|
|
34
34
|
[![NPM version][npm-image]][npm-url] [![Build Status][test-image]][test-url] [![Coverage Status][coverage-image]][coverage-url] <!-- [![dependencies][dependencies-image]][dependencies-url] -->
|
|
35
35
|
|
|
36
|
-
> Create a
|
|
36
|
+
> Create a contiguous linear ndarray data buffer.
|
|
37
37
|
|
|
38
38
|
<!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. -->
|
|
39
39
|
|
|
@@ -65,30 +65,14 @@ var buffer = require( '@stdlib/ndarray-base-buffer' );
|
|
|
65
65
|
|
|
66
66
|
#### buffer( dtype, size )
|
|
67
67
|
|
|
68
|
-
Returns a
|
|
68
|
+
Returns a contiguous linear ndarray data buffer having a specified [data type][@stdlib/ndarray/dtypes].
|
|
69
69
|
|
|
70
70
|
```javascript
|
|
71
71
|
var buf = buffer( 'float64', 3 );
|
|
72
72
|
// returns <Float64Array>[ 0.0, 0.0, 0.0 ]
|
|
73
73
|
```
|
|
74
74
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
- `binary`: binary.
|
|
78
|
-
- `complex64`: single-precision complex floating-point numbers.
|
|
79
|
-
- `complex128`: double-precision complex floating-point numbers.
|
|
80
|
-
- `float32`: single-precision floating-point numbers.
|
|
81
|
-
- `float64`: double-precision floating-point numbers.
|
|
82
|
-
- `generic`: values of any type.
|
|
83
|
-
- `int16`: signed 16-bit integers.
|
|
84
|
-
- `int32`: signed 32-bit integers.
|
|
85
|
-
- `int8`: signed 8-bit integers.
|
|
86
|
-
- `uint16`: unsigned 16-bit integers.
|
|
87
|
-
- `uint32`: unsigned 32-bit integers.
|
|
88
|
-
- `uint8`: unsigned 8-bit integers.
|
|
89
|
-
- `uint8c`: unsigned clamped 8-bit integers.
|
|
90
|
-
|
|
91
|
-
If provided an unknown or unsupported data type, the function returns `null`.
|
|
75
|
+
If provided an unknown or unsupported [data type][@stdlib/ndarray/dtypes], the function returns `null`.
|
|
92
76
|
|
|
93
77
|
```javascript
|
|
94
78
|
var buf = buffer( 'float', 3 );
|
|
@@ -103,6 +87,10 @@ var buf = buffer( 'float', 3 );
|
|
|
103
87
|
|
|
104
88
|
<section class="notes">
|
|
105
89
|
|
|
90
|
+
## Notes
|
|
91
|
+
|
|
92
|
+
- When provided a numeric [data type][@stdlib/ndarray/dtypes], "generic", or "binary", the function returns a zero-filled contiguous linear ndarray data buffer.
|
|
93
|
+
|
|
106
94
|
</section>
|
|
107
95
|
|
|
108
96
|
<!-- /.notes -->
|
|
@@ -120,9 +108,9 @@ var dtypes = require( '@stdlib/ndarray-dtypes' );
|
|
|
120
108
|
var buffer = require( '@stdlib/ndarray-base-buffer' );
|
|
121
109
|
|
|
122
110
|
var DTYPES = dtypes();
|
|
111
|
+
|
|
123
112
|
var buf;
|
|
124
113
|
var i;
|
|
125
|
-
|
|
126
114
|
for ( i = 0; i < DTYPES.length; i++ ) {
|
|
127
115
|
buf = buffer( DTYPES[ i ], 10 );
|
|
128
116
|
console.log( buf );
|
|
@@ -175,7 +163,7 @@ See [LICENSE][stdlib-license].
|
|
|
175
163
|
|
|
176
164
|
## Copyright
|
|
177
165
|
|
|
178
|
-
Copyright © 2016-
|
|
166
|
+
Copyright © 2016-2026. The Stdlib [Authors][stdlib-authors].
|
|
179
167
|
|
|
180
168
|
</section>
|
|
181
169
|
|
|
@@ -188,8 +176,8 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors].
|
|
|
188
176
|
[npm-image]: http://img.shields.io/npm/v/@stdlib/ndarray-base-buffer.svg
|
|
189
177
|
[npm-url]: https://npmjs.org/package/@stdlib/ndarray-base-buffer
|
|
190
178
|
|
|
191
|
-
[test-image]: https://github.com/stdlib-js/ndarray-base-buffer/actions/workflows/test.yml/badge.svg?branch=v0.
|
|
192
|
-
[test-url]: https://github.com/stdlib-js/ndarray-base-buffer/actions/workflows/test.yml?query=branch:v0.
|
|
179
|
+
[test-image]: https://github.com/stdlib-js/ndarray-base-buffer/actions/workflows/test.yml/badge.svg?branch=v0.3.1
|
|
180
|
+
[test-url]: https://github.com/stdlib-js/ndarray-base-buffer/actions/workflows/test.yml?query=branch:v0.3.1
|
|
193
181
|
|
|
194
182
|
[coverage-image]: https://img.shields.io/codecov/c/github/stdlib-js/ndarray-base-buffer/main.svg
|
|
195
183
|
[coverage-url]: https://codecov.io/github/stdlib-js/ndarray-base-buffer?branch=main
|
|
@@ -201,8 +189,8 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors].
|
|
|
201
189
|
|
|
202
190
|
-->
|
|
203
191
|
|
|
204
|
-
[chat-image]: https://img.shields.io/
|
|
205
|
-
[chat-url]: https://
|
|
192
|
+
[chat-image]: https://img.shields.io/badge/zulip-join_chat-brightgreen.svg
|
|
193
|
+
[chat-url]: https://stdlib.zulipchat.com
|
|
206
194
|
|
|
207
195
|
[stdlib]: https://github.com/stdlib-js/stdlib
|
|
208
196
|
|
|
@@ -221,6 +209,8 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors].
|
|
|
221
209
|
|
|
222
210
|
[stdlib-license]: https://raw.githubusercontent.com/stdlib-js/ndarray-base-buffer/main/LICENSE
|
|
223
211
|
|
|
212
|
+
[@stdlib/ndarray/dtypes]: https://www.npmjs.com/package/@stdlib/ndarray-dtypes
|
|
213
|
+
|
|
224
214
|
</section>
|
|
225
215
|
|
|
226
216
|
<!-- /.links -->
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
"use strict";var
|
|
2
|
-
function o(e){var
|
|
3
|
-
});var
|
|
4
|
-
var c=require('@stdlib/ndarray-base-buffer-ctors/dist'),s=require('@stdlib/buffer-alloc-unsafe/dist'),v=i();function b(e){var r,n;for(r=[],n=0;n<e;n++)r.push(0);return r}function l(e){return v(s(e))}function q(e,r){var n=c(e);return n?new n(r):null}function g(e,r){return e==="generic"?b(r):e==="binary"?l(r):q(e,r)}f.exports=g
|
|
5
|
-
});var p=a();module.exports=p;
|
|
1
|
+
"use strict";var i=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var t=i(function(p,n){
|
|
2
|
+
var a=require('@stdlib/ndarray-base-dtype-resolve-str/dist'),f=require('@stdlib/ndarray-base-buffer-ctors/dist'),o=require('@stdlib/buffer-alloc-unsafe/dist'),v=require('@stdlib/array-base-zeros/dist'),c=require('@stdlib/array-base-fill/dist');function l(e){return c(o(e),0,0,e)}function s(e,r){var u=f(e);return u?new u(r):null}function q(e,r){var u=a(e);return u==="generic"?v(r):u==="binary"?l(r):s(e,r)}n.exports=q
|
|
3
|
+
});var b=t();module.exports=b;
|
|
6
4
|
/** @license Apache-2.0 */
|
|
7
5
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../lib/
|
|
4
|
-
"sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 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//
|
|
5
|
-
"mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,
|
|
6
|
-
"names": ["
|
|
3
|
+
"sources": ["../lib/main.js", "../lib/index.js"],
|
|
4
|
+
"sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 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 resolveStr = require( '@stdlib/ndarray-base-dtype-resolve-str' );\nvar bufferCtors = require( '@stdlib/ndarray-base-buffer-ctors' );\nvar allocUnsafe = require( '@stdlib/buffer-alloc-unsafe' );\nvar zeros = require( '@stdlib/array-base-zeros' );\nvar fill = require( '@stdlib/array-base-fill' );\n\n\n// FUNCTIONS //\n\n/**\n* Returns a zero-filled binary buffer.\n*\n* @private\n* @param {NonNegativeInteger} size - buffer size\n* @returns {Buffer} zero-filled binary buffer\n*/\nfunction binary( size ) {\n\treturn fill( allocUnsafe( size ), 0, 0, size );\n}\n\n/**\n* Returns a typed array.\n*\n* @private\n* @param {*} dtype - data type\n* @param {NonNegativeInteger} size - buffer size\n* @returns {(TypedArray|null)} typed array\n*/\nfunction typedarray( dtype, size ) {\n\tvar ctor = bufferCtors( dtype );\n\tif ( ctor ) {\n\t\treturn new ctor( size );\n\t}\n\treturn null;\n}\n\n\n// MAIN //\n\n/**\n* Returns a contiguous linear ndarray data buffer.\n*\n* @param {*} dtype - data type\n* @param {NonNegativeInteger} size - buffer size\n* @returns {(Array|TypedArray|Buffer|null)} data buffer\n*\n* @example\n* var buf = buffer( 'float64', 3 );\n* // returns <Float64Array>[ 0.0, 0.0, 0.0 ]\n*/\nfunction buffer( dtype, size ) {\n\tvar dt = resolveStr( dtype );\n\tif ( dt === 'generic' ) {\n\t\treturn zeros( size );\n\t}\n\tif ( dt === 'binary' ) {\n\t\treturn binary( size );\n\t}\n\treturn typedarray( dtype, size );\n}\n\n\n// EXPORTS //\n\nmodule.exports = buffer;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 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 a contiguous linear ndarray data buffer.\n*\n* @module @stdlib/ndarray-base-buffer\n*\n* @example\n* var buffer = require( '@stdlib/ndarray-base-buffer' );\n*\n* var buf = buffer( 'float64', 3 );\n* // returns <Float64Array>[ 0.0, 0.0, 0.0 ]\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,wCAAyC,EAC/DC,EAAc,QAAS,mCAAoC,EAC3DC,EAAc,QAAS,6BAA8B,EACrDC,EAAQ,QAAS,0BAA2B,EAC5CC,EAAO,QAAS,yBAA0B,EAY9C,SAASC,EAAQC,EAAO,CACvB,OAAOF,EAAMF,EAAaI,CAAK,EAAG,EAAG,EAAGA,CAAK,CAC9C,CAUA,SAASC,EAAYC,EAAOF,EAAO,CAClC,IAAIG,EAAOR,EAAaO,CAAM,EAC9B,OAAKC,EACG,IAAIA,EAAMH,CAAK,EAEhB,IACR,CAgBA,SAASI,EAAQF,EAAOF,EAAO,CAC9B,IAAIK,EAAKX,EAAYQ,CAAM,EAC3B,OAAKG,IAAO,UACJR,EAAOG,CAAK,EAEfK,IAAO,SACJN,EAAQC,CAAK,EAEdC,EAAYC,EAAOF,CAAK,CAChC,CAKAP,EAAO,QAAUW,ICpDjB,IAAIE,EAAO,IAKX,OAAO,QAAUA",
|
|
6
|
+
"names": ["require_main", "__commonJSMin", "exports", "module", "resolveStr", "bufferCtors", "allocUnsafe", "zeros", "fill", "binary", "size", "typedarray", "dtype", "ctor", "buffer", "dt", "main"]
|
|
7
7
|
}
|
package/docs/types/index.d.ts
CHANGED
|
@@ -22,16 +22,16 @@
|
|
|
22
22
|
/// <reference types="node"/>
|
|
23
23
|
|
|
24
24
|
import { Buffer } from 'buffer';
|
|
25
|
-
import { TypedArray } from '@stdlib/types/array';
|
|
25
|
+
import { TypedArray, ComplexTypedArray, BooleanTypedArray } from '@stdlib/types/array';
|
|
26
26
|
import { DataType } from '@stdlib/types/ndarray';
|
|
27
27
|
|
|
28
28
|
/**
|
|
29
29
|
* Array or typed array.
|
|
30
30
|
*/
|
|
31
|
-
type ArrayOrBufferOrTypedArray = Array<any> | TypedArray | Buffer | null;
|
|
31
|
+
type ArrayOrBufferOrTypedArray = Array<any> | TypedArray | ComplexTypedArray | BooleanTypedArray | Buffer | null;
|
|
32
32
|
|
|
33
33
|
/**
|
|
34
|
-
* Returns a
|
|
34
|
+
* Returns a contiguous linear ndarray data buffer.
|
|
35
35
|
*
|
|
36
36
|
* @param dtype - data type
|
|
37
37
|
* @param size - buffer size
|
package/lib/index.js
CHANGED
package/lib/main.js
CHANGED
|
@@ -20,31 +20,15 @@
|
|
|
20
20
|
|
|
21
21
|
// MODULES //
|
|
22
22
|
|
|
23
|
+
var resolveStr = require( '@stdlib/ndarray-base-dtype-resolve-str' );
|
|
23
24
|
var bufferCtors = require( '@stdlib/ndarray-base-buffer-ctors' );
|
|
24
25
|
var allocUnsafe = require( '@stdlib/buffer-alloc-unsafe' );
|
|
25
|
-
var zeros = require( '
|
|
26
|
+
var zeros = require( '@stdlib/array-base-zeros' );
|
|
27
|
+
var fill = require( '@stdlib/array-base-fill' );
|
|
26
28
|
|
|
27
29
|
|
|
28
30
|
// FUNCTIONS //
|
|
29
31
|
|
|
30
|
-
/**
|
|
31
|
-
* Returns a zero-filled generic array.
|
|
32
|
-
*
|
|
33
|
-
* @private
|
|
34
|
-
* @param {NonNegativeInteger} size - buffer size
|
|
35
|
-
* @returns {Array} zero-filled generic array
|
|
36
|
-
*/
|
|
37
|
-
function generic( size ) {
|
|
38
|
-
var buf;
|
|
39
|
-
var i;
|
|
40
|
-
|
|
41
|
-
buf = [];
|
|
42
|
-
for ( i = 0; i < size; i++ ) {
|
|
43
|
-
buf.push( 0 );
|
|
44
|
-
}
|
|
45
|
-
return buf;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
32
|
/**
|
|
49
33
|
* Returns a zero-filled binary buffer.
|
|
50
34
|
*
|
|
@@ -53,16 +37,16 @@ function generic( size ) {
|
|
|
53
37
|
* @returns {Buffer} zero-filled binary buffer
|
|
54
38
|
*/
|
|
55
39
|
function binary( size ) {
|
|
56
|
-
return
|
|
40
|
+
return fill( allocUnsafe( size ), 0, 0, size );
|
|
57
41
|
}
|
|
58
42
|
|
|
59
43
|
/**
|
|
60
|
-
* Returns a
|
|
44
|
+
* Returns a typed array.
|
|
61
45
|
*
|
|
62
46
|
* @private
|
|
63
|
-
* @param {
|
|
47
|
+
* @param {*} dtype - data type
|
|
64
48
|
* @param {NonNegativeInteger} size - buffer size
|
|
65
|
-
* @returns {(TypedArray|null)}
|
|
49
|
+
* @returns {(TypedArray|null)} typed array
|
|
66
50
|
*/
|
|
67
51
|
function typedarray( dtype, size ) {
|
|
68
52
|
var ctor = bufferCtors( dtype );
|
|
@@ -76,9 +60,9 @@ function typedarray( dtype, size ) {
|
|
|
76
60
|
// MAIN //
|
|
77
61
|
|
|
78
62
|
/**
|
|
79
|
-
* Returns a
|
|
63
|
+
* Returns a contiguous linear ndarray data buffer.
|
|
80
64
|
*
|
|
81
|
-
* @param {
|
|
65
|
+
* @param {*} dtype - data type
|
|
82
66
|
* @param {NonNegativeInteger} size - buffer size
|
|
83
67
|
* @returns {(Array|TypedArray|Buffer|null)} data buffer
|
|
84
68
|
*
|
|
@@ -87,10 +71,11 @@ function typedarray( dtype, size ) {
|
|
|
87
71
|
* // returns <Float64Array>[ 0.0, 0.0, 0.0 ]
|
|
88
72
|
*/
|
|
89
73
|
function buffer( dtype, size ) {
|
|
90
|
-
|
|
91
|
-
|
|
74
|
+
var dt = resolveStr( dtype );
|
|
75
|
+
if ( dt === 'generic' ) {
|
|
76
|
+
return zeros( size );
|
|
92
77
|
}
|
|
93
|
-
if (
|
|
78
|
+
if ( dt === 'binary' ) {
|
|
94
79
|
return binary( size );
|
|
95
80
|
}
|
|
96
81
|
return typedarray( dtype, size );
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stdlib/ndarray-base-buffer",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "Create a
|
|
3
|
+
"version": "0.3.1",
|
|
4
|
+
"description": "Create a contiguous linear ndarray data buffer.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": {
|
|
7
7
|
"name": "The Stdlib Authors",
|
|
@@ -30,8 +30,11 @@
|
|
|
30
30
|
"url": "https://github.com/stdlib-js/stdlib/issues"
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@stdlib/
|
|
34
|
-
"@stdlib/
|
|
33
|
+
"@stdlib/array-base-fill": "^0.1.0",
|
|
34
|
+
"@stdlib/array-base-zeros": "^0.2.3",
|
|
35
|
+
"@stdlib/buffer-alloc-unsafe": "^0.2.3",
|
|
36
|
+
"@stdlib/ndarray-base-buffer-ctors": "^0.4.0",
|
|
37
|
+
"@stdlib/ndarray-base-dtype-resolve-str": "^0.3.1"
|
|
35
38
|
},
|
|
36
39
|
"devDependencies": {},
|
|
37
40
|
"engines": {
|
|
@@ -67,7 +70,6 @@
|
|
|
67
70
|
"utils",
|
|
68
71
|
"util"
|
|
69
72
|
],
|
|
70
|
-
"__stdlib__": {},
|
|
71
73
|
"funding": {
|
|
72
74
|
"type": "opencollective",
|
|
73
75
|
"url": "https://opencollective.com/stdlib"
|
package/lib/zeros.js
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
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
|
-
/**
|
|
24
|
-
* Fills an array-like object with zeros.
|
|
25
|
-
*
|
|
26
|
-
* @private
|
|
27
|
-
* @param {(Array|TypedArray|Buffer)} v - array-like object to fill
|
|
28
|
-
* @returns {(Array|TypedArray|Buffer)} input value
|
|
29
|
-
*
|
|
30
|
-
* @example
|
|
31
|
-
* var arr = zeros( new Array( 2 ) );
|
|
32
|
-
* // returns [ 0, 0 ]
|
|
33
|
-
*/
|
|
34
|
-
function zeros( v ) {
|
|
35
|
-
var i;
|
|
36
|
-
for ( i = 0; i < v.length; i++ ) {
|
|
37
|
-
v[ i ] = 0;
|
|
38
|
-
}
|
|
39
|
-
return v;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
// EXPORTS //
|
|
44
|
-
|
|
45
|
-
module.exports = zeros;
|