@stdlib/ndarray-zeros-like 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 CHANGED
@@ -1 +1 @@
1
- Copyright (c) 2016-2023 The Stdlib Authors.
1
+ Copyright (c) 2016-2024 The Stdlib Authors.
package/README.md CHANGED
@@ -172,6 +172,13 @@ for ( i = 0; i < dt.length; i++ ) {
172
172
 
173
173
  <section class="related">
174
174
 
175
+ * * *
176
+
177
+ ## See Also
178
+
179
+ - <span class="package-name">[`@stdlib/ndarray-empty-like`][@stdlib/ndarray/empty-like]</span><span class="delimiter">: </span><span class="description">create an uninitialized ndarray having the same shape and data type as a provided ndarray.</span>
180
+ - <span class="package-name">[`@stdlib/ndarray-zeros`][@stdlib/ndarray/zeros]</span><span class="delimiter">: </span><span class="description">create a zero-filled ndarray having a specified shape and data type.</span>
181
+
175
182
  </section>
176
183
 
177
184
  <!-- /.related -->
@@ -202,7 +209,7 @@ See [LICENSE][stdlib-license].
202
209
 
203
210
  ## Copyright
204
211
 
205
- Copyright &copy; 2016-2023. The Stdlib [Authors][stdlib-authors].
212
+ Copyright &copy; 2016-2024. The Stdlib [Authors][stdlib-authors].
206
213
 
207
214
  </section>
208
215
 
@@ -215,8 +222,8 @@ Copyright &copy; 2016-2023. The Stdlib [Authors][stdlib-authors].
215
222
  [npm-image]: http://img.shields.io/npm/v/@stdlib/ndarray-zeros-like.svg
216
223
  [npm-url]: https://npmjs.org/package/@stdlib/ndarray-zeros-like
217
224
 
218
- [test-image]: https://github.com/stdlib-js/ndarray-zeros-like/actions/workflows/test.yml/badge.svg?branch=v0.1.0
219
- [test-url]: https://github.com/stdlib-js/ndarray-zeros-like/actions/workflows/test.yml?query=branch:v0.1.0
225
+ [test-image]: https://github.com/stdlib-js/ndarray-zeros-like/actions/workflows/test.yml/badge.svg?branch=v0.2.0
226
+ [test-url]: https://github.com/stdlib-js/ndarray-zeros-like/actions/workflows/test.yml?query=branch:v0.2.0
220
227
 
221
228
  [coverage-image]: https://img.shields.io/codecov/c/github/stdlib-js/ndarray-zeros-like/main.svg
222
229
  [coverage-url]: https://codecov.io/github/stdlib-js/ndarray-zeros-like?branch=main
@@ -239,15 +246,26 @@ Copyright &copy; 2016-2023. The Stdlib [Authors][stdlib-authors].
239
246
  [es-module]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules
240
247
 
241
248
  [deno-url]: https://github.com/stdlib-js/ndarray-zeros-like/tree/deno
249
+ [deno-readme]: https://github.com/stdlib-js/ndarray-zeros-like/blob/deno/README.md
242
250
  [umd-url]: https://github.com/stdlib-js/ndarray-zeros-like/tree/umd
251
+ [umd-readme]: https://github.com/stdlib-js/ndarray-zeros-like/blob/umd/README.md
243
252
  [esm-url]: https://github.com/stdlib-js/ndarray-zeros-like/tree/esm
253
+ [esm-readme]: https://github.com/stdlib-js/ndarray-zeros-like/blob/esm/README.md
244
254
  [branches-url]: https://github.com/stdlib-js/ndarray-zeros-like/blob/main/branches.md
245
255
 
246
256
  [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/ndarray-zeros-like/main/LICENSE
247
257
 
248
- [@stdlib/ndarray/ctor]: https://www.npmjs.com/package/@stdlib/stdlib
258
+ [@stdlib/ndarray/ctor]: https://www.npmjs.com/package/@stdlib/ndarray-ctor
259
+
260
+ [@stdlib/ndarray/dtypes]: https://www.npmjs.com/package/@stdlib/ndarray-dtypes
261
+
262
+ <!-- <related-links> -->
263
+
264
+ [@stdlib/ndarray/empty-like]: https://www.npmjs.com/package/@stdlib/ndarray-empty-like
265
+
266
+ [@stdlib/ndarray/zeros]: https://www.npmjs.com/package/@stdlib/ndarray-zeros
249
267
 
250
- [@stdlib/ndarray/dtypes]: https://www.npmjs.com/package/@stdlib/stdlib
268
+ <!-- </related-links> -->
251
269
 
252
270
  </section>
253
271
 
package/SECURITY.md ADDED
@@ -0,0 +1,5 @@
1
+ # Security
2
+
3
+ > Policy for reporting security vulnerabilities.
4
+
5
+ See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security).
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
- "use strict";var l=function(a,e){return function(){return e||a((e={exports:{}}).exports,e),e.exports}};var f=l(function(k,m){
2
- var y=require('@stdlib/assert-is-ndarray-like/dist'),g=require('@stdlib/assert-is-plain-object/dist'),h=require('@stdlib/assert-is-nonnegative-integer-array/dist').primitives,t=require('@stdlib/assert-has-own-property/dist'),b=require('@stdlib/ndarray-base-shape2strides/dist'),q=require('@stdlib/ndarray-base-strides2offset/dist'),w=require('@stdlib/ndarray-base-buffer/dist'),c=require('@stdlib/ndarray-base-numel/dist'),E=require('@stdlib/ndarray-ctor/dist'),d=require('@stdlib/error-tools-fmtprodmsg/dist');function O(a){var e,i,n,p,s,v,o,u,r;if(!y(a))throw new TypeError(d('0kH5t',a));if(s={},arguments.length>1){if(e=arguments[1],!g(e))throw new TypeError(d('0kH2V',e));if(t(e,"dtype")?i=e.dtype:i=a.dtype,t(e,"shape")){if(r=e.shape,typeof r=="number"&&(r=[r]),!h(r))throw new TypeError(d('0kHDs',"shape",r))}else r=a.shape;t(e,"order")?n=e.order:n=a.order,t(e,"mode")&&(s.mode=e.mode),t(e,"submode")&&(s.submode=e.submode),t(e,"readonly")&&(s.readonly=e.readonly)}else i=a.dtype,r=a.shape,n=a.order;if(p=r.length,p>0?(o=c(r),o<0&&(o=0),u=b(r,n)):(o=1,u=[0]),v=w(i,o),v===null)throw new TypeError(d('0kH5L',i));return new E(i,v,r,u,q(r,u),n,s)}m.exports=O
3
- });var T=f();module.exports=T;
1
+ "use strict";var h=function(a,e){return function(){return e||a((e={exports:{}}).exports,e),e.exports}};var y=h(function(F,g){
2
+ var q=require('@stdlib/assert-is-ndarray-like/dist'),b=require('@stdlib/assert-is-plain-object/dist'),w=require('@stdlib/assert-is-nonnegative-integer-array/dist').primitives,t=require('@stdlib/assert-has-own-property/dist'),c=require('@stdlib/ndarray-base-shape2strides/dist'),O=require('@stdlib/ndarray-base-strides2offset/dist'),T=require('@stdlib/ndarray-base-buffer/dist'),E=require('@stdlib/ndarray-base-numel/dist'),m=require('@stdlib/ndarray-dtype/dist'),l=require('@stdlib/ndarray-shape/dist'),f=require('@stdlib/ndarray-order/dist'),j=require('@stdlib/ndarray-ctor/dist'),u=require('@stdlib/error-tools-fmtprodmsg/dist');function k(a){var e,i,n,p,s,v,d,o,r;if(!q(a))throw new TypeError(u('0kH5t',a));if(s={},arguments.length>1){if(e=arguments[1],!b(e))throw new TypeError(u('0kH2V',e));if(t(e,"dtype")?i=e.dtype:i=m(a),t(e,"shape")){if(r=e.shape,typeof r=="number"&&(r=[r]),!w(r))throw new TypeError(u('0kHDs',"shape",r))}else r=l(a);t(e,"order")?n=e.order:n=f(a),t(e,"mode")&&(s.mode=e.mode),t(e,"submode")&&(s.submode=e.submode),t(e,"readonly")&&(s.readonly=e.readonly)}else i=m(a),r=l(a),n=f(a);if(p=r.length,p>0?(d=E(r),o=c(r,n)):(d=1,o=[0]),v=T(i,d),v===null)throw new TypeError(u('0kH5L',i));return new j(i,v,r,o,O(r,o),n,s)}g.exports=k
3
+ });var V=y();module.exports=V;
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) 2022 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 isndarrayLike = require( '@stdlib/assert-is-ndarray-like' );\nvar isPlainObject = require( '@stdlib/assert-is-plain-object' );\nvar isNonNegativeIntegerArray = require( '@stdlib/assert-is-nonnegative-integer-array' ).primitives;\nvar hasOwnProp = require( '@stdlib/assert-has-own-property' );\nvar shape2strides = require( '@stdlib/ndarray-base-shape2strides' );\nvar strides2offset = require( '@stdlib/ndarray-base-strides2offset' );\nvar buffer = require( '@stdlib/ndarray-base-buffer' );\nvar numel = require( '@stdlib/ndarray-base-numel' );\nvar ndarray = require( '@stdlib/ndarray-ctor' );\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Creates a zero-filled ndarray having the same shape and data type as a provided ndarray.\n*\n* @param {ndarray} x - input array\n* @param {Options} [options] - function options\n* @param {string} [options.dtype] - output array data type (overrides the input array's inferred data type)\n* @param {string} [options.order] - specifies whether the output array should be 'row-major' (C-style) or 'column-major' (Fortran-style) (overrides the input array's inferred order)\n* @param {(NonNegativeIntegerArray|NonNegativeInteger)} [options.shape] - output array shape (overrides the input array's inferred shape)\n* @param {string} [options.mode=\"throw\"] - specifies how to handle indices which exceed array dimensions\n* @param {StringArray} [options.submode=[\"throw\"]] - specifies how to handle subscripts which exceed array dimensions on a per dimension basis\n* @param {boolean} [options.readonly=false] - boolean indicating whether an array should be read-only\n* @throws {TypeError} first argument must have a recognized data type\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} `dtype` option must be a supported ndarray data type\n* @throws {TypeError} `order` option must be a supported order\n* @throws {TypeError} `shape` option must be either a nonnegative integer or an array of nonnegative integers\n* @throws {TypeError} must provide valid options\n* @returns {ndarray} ndarray\n*\n* @example\n* var zeros = require( '@stdlib/ndarray-zeros' );\n*\n* var x = zeros( [ 2, 2 ] );\n* // returns <ndarray>\n*\n* var y = zerosLike( x );\n* // returns <ndarray>\n*\n* var sh = y.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = y.dtype;\n* // returns 'float64'\n*/\nfunction zerosLike( x ) {\n\tvar options;\n\tvar dtype;\n\tvar order;\n\tvar ndims;\n\tvar opts;\n\tvar buf;\n\tvar len;\n\tvar st;\n\tvar sh;\n\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an ndarray-like object. Value: `%s`.', x ) );\n\t}\n\topts = {};\n\tif ( arguments.length > 1 ) {\n\t\toptions = arguments[ 1 ];\n\t\tif ( !isPlainObject( options ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t\t}\n\t\tif ( hasOwnProp( options, 'dtype' ) ) {\n\t\t\tdtype = options.dtype;\n\t\t} else {\n\t\t\tdtype = x.dtype;\n\t\t}\n\t\tif ( hasOwnProp( options, 'shape' ) ) {\n\t\t\tsh = options.shape;\n\t\t\tif ( typeof sh === 'number' ) {\n\t\t\t\tsh = [ sh ];\n\t\t\t}\n\t\t\tif ( !isNonNegativeIntegerArray( sh ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid option. `%s` option must be a nonnegative integer or an array of nonnegative integers. Option: `%s`.', 'shape', sh ) );\n\t\t\t}\n\t\t} else {\n\t\t\tsh = x.shape;\n\t\t}\n\t\tif ( hasOwnProp( options, 'order' ) ) {\n\t\t\torder = options.order;\n\t\t} else {\n\t\t\torder = x.order;\n\t\t}\n\t\tif ( hasOwnProp( options, 'mode' ) ) {\n\t\t\topts.mode = options.mode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'submode' ) ) {\n\t\t\topts.submode = options.submode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'readonly' ) ) {\n\t\t\topts.readonly = options.readonly;\n\t\t}\n\t} else {\n\t\tdtype = x.dtype;\n\t\tsh = x.shape;\n\t\torder = x.order;\n\t}\n\tndims = sh.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( sh );\n\t\tif ( len < 0 ) {\n\t\t\tlen = 0; // note: we should only get here if an inferred shape is invalid (i.e., contains negative dimension sizes)\n\t\t}\n\t\tst = shape2strides( sh, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tbuf = buffer( dtype, len );\n\tif ( buf === null ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must have a recognized data type. Value: `%s`.', dtype ) );\n\t}\n\treturn new ndarray( dtype, buf, sh, st, strides2offset( sh, st ), order, opts ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nmodule.exports = zerosLike;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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 zero-filled ndarray having the same shape and data type as a provided ndarray.\n*\n* @module @stdlib/ndarray-zeros-like\n*\n* @example\n* var zeros = require( '@stdlib/ndarray-zeros' );\n* var zerosLike = require( '@stdlib/ndarray-zeros-like' );\n*\n* var x = zeros( [ 2, 2 ] );\n* // returns <ndarray>\n*\n* var y = zerosLike( x );\n* // returns <ndarray>\n*\n* var sh = y.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = y.dtype;\n* // returns 'float64'\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,EAAgB,QAAS,gCAAiC,EAC1DC,EAAgB,QAAS,gCAAiC,EAC1DC,EAA4B,QAAS,6CAA8C,EAAE,WACrFC,EAAa,QAAS,iCAAkC,EACxDC,EAAgB,QAAS,oCAAqC,EAC9DC,EAAiB,QAAS,qCAAsC,EAChEC,EAAS,QAAS,6BAA8B,EAChDC,EAAQ,QAAS,4BAA6B,EAC9CC,EAAU,QAAS,sBAAuB,EAC1CC,EAAS,QAAS,uBAAwB,EAuC9C,SAASC,EAAWC,EAAI,CACvB,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAEJ,GAAK,CAACpB,EAAeW,CAAE,EACtB,MAAM,IAAI,UAAWF,EAAQ,gFAAiFE,CAAE,CAAE,EAGnH,GADAK,EAAO,CAAC,EACH,UAAU,OAAS,EAAI,CAE3B,GADAJ,EAAU,UAAW,CAAE,EAClB,CAACX,EAAeW,CAAQ,EAC5B,MAAM,IAAI,UAAWH,EAAQ,qEAAsEG,CAAQ,CAAE,EAO9G,GALKT,EAAYS,EAAS,OAAQ,EACjCC,EAAQD,EAAQ,MAEhBC,EAAQF,EAAE,MAENR,EAAYS,EAAS,OAAQ,GAKjC,GAJAQ,EAAKR,EAAQ,MACR,OAAOQ,GAAO,WAClBA,EAAK,CAAEA,CAAG,GAEN,CAAClB,EAA2BkB,CAAG,EACnC,MAAM,IAAI,UAAWX,EAAQ,+GAAgH,QAASW,CAAG,CAAE,OAG5JA,EAAKT,EAAE,MAEHR,EAAYS,EAAS,OAAQ,EACjCE,EAAQF,EAAQ,MAEhBE,EAAQH,EAAE,MAENR,EAAYS,EAAS,MAAO,IAChCI,EAAK,KAAOJ,EAAQ,MAEhBT,EAAYS,EAAS,SAAU,IACnCI,EAAK,QAAUJ,EAAQ,SAEnBT,EAAYS,EAAS,UAAW,IACpCI,EAAK,SAAWJ,EAAQ,SAE1B,MACCC,EAAQF,EAAE,MACVS,EAAKT,EAAE,MACPG,EAAQH,EAAE,MAeX,GAbAI,EAAQK,EAAG,OACNL,EAAQ,GACZG,EAAMX,EAAOa,CAAG,EACXF,EAAM,IACVA,EAAM,GAEPC,EAAKf,EAAegB,EAAIN,CAAM,IAG9BI,EAAM,EACNC,EAAK,CAAE,CAAE,GAEVF,EAAMX,EAAQO,EAAOK,CAAI,EACpBD,IAAQ,KACZ,MAAM,IAAI,UAAWR,EAAQ,kFAAmFI,CAAM,CAAE,EAEzH,OAAO,IAAIL,EAASK,EAAOI,EAAKG,EAAID,EAAId,EAAgBe,EAAID,CAAG,EAAGL,EAAOE,CAAK,CAC/E,CAKAjB,EAAO,QAAUW,ICvGjB,IAAIW,EAAO,IAKX,OAAO,QAAUA",
6
- "names": ["require_main", "__commonJSMin", "exports", "module", "isndarrayLike", "isPlainObject", "isNonNegativeIntegerArray", "hasOwnProp", "shape2strides", "strides2offset", "buffer", "numel", "ndarray", "format", "zerosLike", "x", "options", "dtype", "order", "ndims", "opts", "buf", "len", "st", "sh", "main"]
4
+ "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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 isndarrayLike = require( '@stdlib/assert-is-ndarray-like' );\nvar isPlainObject = require( '@stdlib/assert-is-plain-object' );\nvar isNonNegativeIntegerArray = require( '@stdlib/assert-is-nonnegative-integer-array' ).primitives;\nvar hasOwnProp = require( '@stdlib/assert-has-own-property' );\nvar shape2strides = require( '@stdlib/ndarray-base-shape2strides' );\nvar strides2offset = require( '@stdlib/ndarray-base-strides2offset' );\nvar buffer = require( '@stdlib/ndarray-base-buffer' );\nvar numel = require( '@stdlib/ndarray-base-numel' );\nvar getDType = require( '@stdlib/ndarray-dtype' );\nvar getShape = require( '@stdlib/ndarray-shape' );\nvar getOrder = require( '@stdlib/ndarray-order' );\nvar ndarray = require( '@stdlib/ndarray-ctor' );\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Creates a zero-filled ndarray having the same shape and data type as a provided ndarray.\n*\n* @param {ndarray} x - input array\n* @param {Options} [options] - function options\n* @param {string} [options.dtype] - output array data type (overrides the input array's inferred data type)\n* @param {string} [options.order] - specifies whether the output array should be 'row-major' (C-style) or 'column-major' (Fortran-style) (overrides the input array's inferred order)\n* @param {(NonNegativeIntegerArray|NonNegativeInteger)} [options.shape] - output array shape (overrides the input array's inferred shape)\n* @param {string} [options.mode=\"throw\"] - specifies how to handle indices which exceed array dimensions\n* @param {StringArray} [options.submode=[\"throw\"]] - specifies how to handle subscripts which exceed array dimensions on a per dimension basis\n* @param {boolean} [options.readonly=false] - boolean indicating whether an array should be read-only\n* @throws {TypeError} first argument must have a recognized data type\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} `dtype` option must be a supported ndarray data type\n* @throws {TypeError} `order` option must be a supported order\n* @throws {TypeError} `shape` option must be either a nonnegative integer or an array of nonnegative integers\n* @throws {TypeError} must provide valid options\n* @returns {ndarray} ndarray\n*\n* @example\n* var zeros = require( '@stdlib/ndarray-zeros' );\n*\n* var x = zeros( [ 2, 2 ] );\n* // returns <ndarray>\n*\n* var y = zerosLike( x );\n* // returns <ndarray>\n*\n* var sh = y.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = y.dtype;\n* // returns 'float64'\n*/\nfunction zerosLike( x ) {\n\tvar options;\n\tvar dtype;\n\tvar order;\n\tvar ndims;\n\tvar opts;\n\tvar buf;\n\tvar len;\n\tvar st;\n\tvar sh;\n\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an ndarray-like object. Value: `%s`.', x ) );\n\t}\n\topts = {};\n\tif ( arguments.length > 1 ) {\n\t\toptions = arguments[ 1 ];\n\t\tif ( !isPlainObject( options ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t\t}\n\t\tif ( hasOwnProp( options, 'dtype' ) ) {\n\t\t\tdtype = options.dtype;\n\t\t} else {\n\t\t\tdtype = getDType( x );\n\t\t}\n\t\tif ( hasOwnProp( options, 'shape' ) ) {\n\t\t\tsh = options.shape;\n\t\t\tif ( typeof sh === 'number' ) {\n\t\t\t\tsh = [ sh ];\n\t\t\t}\n\t\t\tif ( !isNonNegativeIntegerArray( sh ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid option. `%s` option must be a nonnegative integer or an array of nonnegative integers. Option: `%s`.', 'shape', sh ) );\n\t\t\t}\n\t\t} else {\n\t\t\tsh = getShape( x );\n\t\t}\n\t\tif ( hasOwnProp( options, 'order' ) ) {\n\t\t\torder = options.order;\n\t\t} else {\n\t\t\torder = getOrder( x );\n\t\t}\n\t\tif ( hasOwnProp( options, 'mode' ) ) {\n\t\t\topts.mode = options.mode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'submode' ) ) {\n\t\t\topts.submode = options.submode;\n\t\t}\n\t\tif ( hasOwnProp( options, 'readonly' ) ) {\n\t\t\topts.readonly = options.readonly;\n\t\t}\n\t} else {\n\t\tdtype = getDType( x );\n\t\tsh = getShape( x );\n\t\torder = getOrder( x );\n\t}\n\tndims = sh.length;\n\tif ( ndims > 0 ) {\n\t\tlen = numel( sh );\n\t\tst = shape2strides( sh, order );\n\t} else {\n\t\t// For 0-dimensional arrays, the buffer should contain a single element...\n\t\tlen = 1;\n\t\tst = [ 0 ];\n\t}\n\tbuf = buffer( dtype, len );\n\tif ( buf === null ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must have a recognized data type. Value: `%s`.', dtype ) );\n\t}\n\treturn new ndarray( dtype, buf, sh, st, strides2offset( sh, st ), order, opts ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nmodule.exports = zerosLike;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 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 zero-filled ndarray having the same shape and data type as a provided ndarray.\n*\n* @module @stdlib/ndarray-zeros-like\n*\n* @example\n* var zeros = require( '@stdlib/ndarray-zeros' );\n* var zerosLike = require( '@stdlib/ndarray-zeros-like' );\n*\n* var x = zeros( [ 2, 2 ] );\n* // returns <ndarray>\n*\n* var y = zerosLike( x );\n* // returns <ndarray>\n*\n* var sh = y.shape;\n* // returns [ 2, 2 ]\n*\n* var dt = y.dtype;\n* // returns 'float64'\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,EAAgB,QAAS,gCAAiC,EAC1DC,EAAgB,QAAS,gCAAiC,EAC1DC,EAA4B,QAAS,6CAA8C,EAAE,WACrFC,EAAa,QAAS,iCAAkC,EACxDC,EAAgB,QAAS,oCAAqC,EAC9DC,EAAiB,QAAS,qCAAsC,EAChEC,EAAS,QAAS,6BAA8B,EAChDC,EAAQ,QAAS,4BAA6B,EAC9CC,EAAW,QAAS,uBAAwB,EAC5CC,EAAW,QAAS,uBAAwB,EAC5CC,EAAW,QAAS,uBAAwB,EAC5CC,EAAU,QAAS,sBAAuB,EAC1CC,EAAS,QAAS,uBAAwB,EAuC9C,SAASC,EAAWC,EAAI,CACvB,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAEJ,GAAK,CAACvB,EAAec,CAAE,EACtB,MAAM,IAAI,UAAWF,EAAQ,gFAAiFE,CAAE,CAAE,EAGnH,GADAK,EAAO,CAAC,EACH,UAAU,OAAS,EAAI,CAE3B,GADAJ,EAAU,UAAW,CAAE,EAClB,CAACd,EAAec,CAAQ,EAC5B,MAAM,IAAI,UAAWH,EAAQ,qEAAsEG,CAAQ,CAAE,EAO9G,GALKZ,EAAYY,EAAS,OAAQ,EACjCC,EAAQD,EAAQ,MAEhBC,EAAQR,EAAUM,CAAE,EAEhBX,EAAYY,EAAS,OAAQ,GAKjC,GAJAQ,EAAKR,EAAQ,MACR,OAAOQ,GAAO,WAClBA,EAAK,CAAEA,CAAG,GAEN,CAACrB,EAA2BqB,CAAG,EACnC,MAAM,IAAI,UAAWX,EAAQ,+GAAgH,QAASW,CAAG,CAAE,OAG5JA,EAAKd,EAAUK,CAAE,EAEbX,EAAYY,EAAS,OAAQ,EACjCE,EAAQF,EAAQ,MAEhBE,EAAQP,EAAUI,CAAE,EAEhBX,EAAYY,EAAS,MAAO,IAChCI,EAAK,KAAOJ,EAAQ,MAEhBZ,EAAYY,EAAS,SAAU,IACnCI,EAAK,QAAUJ,EAAQ,SAEnBZ,EAAYY,EAAS,UAAW,IACpCI,EAAK,SAAWJ,EAAQ,SAE1B,MACCC,EAAQR,EAAUM,CAAE,EACpBS,EAAKd,EAAUK,CAAE,EACjBG,EAAQP,EAAUI,CAAE,EAYrB,GAVAI,EAAQK,EAAG,OACNL,EAAQ,GACZG,EAAMd,EAAOgB,CAAG,EAChBD,EAAKlB,EAAemB,EAAIN,CAAM,IAG9BI,EAAM,EACNC,EAAK,CAAE,CAAE,GAEVF,EAAMd,EAAQU,EAAOK,CAAI,EACpBD,IAAQ,KACZ,MAAM,IAAI,UAAWR,EAAQ,kFAAmFI,CAAM,CAAE,EAEzH,OAAO,IAAIL,EAASK,EAAOI,EAAKG,EAAID,EAAIjB,EAAgBkB,EAAID,CAAG,EAAGL,EAAOE,CAAK,CAC/E,CAKApB,EAAO,QAAUc,ICvGjB,IAAIW,EAAO,IAKX,OAAO,QAAUA",
6
+ "names": ["require_main", "__commonJSMin", "exports", "module", "isndarrayLike", "isPlainObject", "isNonNegativeIntegerArray", "hasOwnProp", "shape2strides", "strides2offset", "buffer", "numel", "getDType", "getShape", "getOrder", "ndarray", "format", "zerosLike", "x", "options", "dtype", "order", "ndims", "opts", "buf", "len", "st", "sh", "main"]
7
7
  }
@@ -1,5 +1,3 @@
1
- // tslint:disable:max-file-line-count
2
-
3
1
  /*
4
2
  * @license Apache-2.0
5
3
  *
@@ -18,6 +16,8 @@
18
16
  * limitations under the License.
19
17
  */
20
18
 
19
+ /* eslint-disable max-lines */
20
+
21
21
  // TypeScript Version: 4.1
22
22
 
23
23
  /// <reference types="@stdlib/types"/>
@@ -243,7 +243,7 @@ interface OptionsWithDType extends Options {
243
243
  * @returns zero-filled array
244
244
  *
245
245
  * @example
246
- * var zeros = require( `@stdlib/ndarray/zeros` );
246
+ * var zeros = require( '@stdlib/ndarray-zeros' );
247
247
  *
248
248
  * var x = zeros( [ 2, 2 ], {
249
249
  * 'dtype': 'float64'
@@ -265,7 +265,7 @@ interface OptionsWithDType extends Options {
265
265
  * dt = y.dtype;
266
266
  * // returns 'float64'
267
267
  */
268
- declare function zerosLike( x: float64ndarray, options?: Options ): float64ndarray; // tslint:disable-line:max-line-length
268
+ declare function zerosLike( x: float64ndarray, options?: Options ): float64ndarray;
269
269
 
270
270
  /**
271
271
  * Creates a zero-filled array having the same shape and data type as a provided input ndarray.
@@ -280,7 +280,7 @@ declare function zerosLike( x: float64ndarray, options?: Options ): float64ndarr
280
280
  * @returns zero-filled array
281
281
  *
282
282
  * @example
283
- * var zeros = require( `@stdlib/ndarray/zeros` );
283
+ * var zeros = require( '@stdlib/ndarray-zeros' );
284
284
  *
285
285
  * var x = zeros( [ 2, 2 ], {
286
286
  * 'dtype': 'float32'
@@ -302,7 +302,7 @@ declare function zerosLike( x: float64ndarray, options?: Options ): float64ndarr
302
302
  * dt = y.dtype;
303
303
  * // returns 'float32'
304
304
  */
305
- declare function zerosLike( x: float32ndarray, options?: Options ): float32ndarray; // tslint:disable-line:max-line-length
305
+ declare function zerosLike( x: float32ndarray, options?: Options ): float32ndarray;
306
306
 
307
307
  /**
308
308
  * Creates a zero-filled array having the same shape and data type as a provided input ndarray.
@@ -317,7 +317,7 @@ declare function zerosLike( x: float32ndarray, options?: Options ): float32ndarr
317
317
  * @returns zero-filled array
318
318
  *
319
319
  * @example
320
- * var zeros = require( `@stdlib/ndarray/zeros` );
320
+ * var zeros = require( '@stdlib/ndarray-zeros' );
321
321
  *
322
322
  * var x = zeros( [ 2, 2 ], {
323
323
  * 'dtype': 'complex128'
@@ -339,7 +339,7 @@ declare function zerosLike( x: float32ndarray, options?: Options ): float32ndarr
339
339
  * dt = y.dtype;
340
340
  * // returns 'complex128'
341
341
  */
342
- declare function zerosLike( x: complex128ndarray, options?: Options ): complex128ndarray; // tslint:disable-line:max-line-length
342
+ declare function zerosLike( x: complex128ndarray, options?: Options ): complex128ndarray;
343
343
 
344
344
  /**
345
345
  * Creates a zero-filled array having the same shape and data type as a provided input ndarray.
@@ -354,7 +354,7 @@ declare function zerosLike( x: complex128ndarray, options?: Options ): complex12
354
354
  * @returns zero-filled array
355
355
  *
356
356
  * @example
357
- * var zeros = require( `@stdlib/ndarray/zeros` );
357
+ * var zeros = require( '@stdlib/ndarray-zeros' );
358
358
  *
359
359
  * var x = zeros( [ 2, 2 ], {
360
360
  * 'dtype': 'complex64'
@@ -376,7 +376,7 @@ declare function zerosLike( x: complex128ndarray, options?: Options ): complex12
376
376
  * dt = y.dtype;
377
377
  * // returns 'complex64'
378
378
  */
379
- declare function zerosLike( x: complex64ndarray, options?: Options ): complex64ndarray; // tslint:disable-line:max-line-length
379
+ declare function zerosLike( x: complex64ndarray, options?: Options ): complex64ndarray;
380
380
 
381
381
  /**
382
382
  * Creates a zero-filled array having the same shape and data type as a provided input ndarray.
@@ -391,7 +391,7 @@ declare function zerosLike( x: complex64ndarray, options?: Options ): complex64n
391
391
  * @returns zero-filled array
392
392
  *
393
393
  * @example
394
- * var zeros = require( `@stdlib/ndarray/zeros` );
394
+ * var zeros = require( '@stdlib/ndarray-zeros' );
395
395
  *
396
396
  * var x = zeros( [ 2, 2 ], {
397
397
  * 'dtype': 'int32'
@@ -428,7 +428,7 @@ declare function zerosLike( x: int32ndarray, options?: Options ): int32ndarray;
428
428
  * @returns zero-filled array
429
429
  *
430
430
  * @example
431
- * var zeros = require( `@stdlib/ndarray/zeros` );
431
+ * var zeros = require( '@stdlib/ndarray-zeros' );
432
432
  *
433
433
  * var x = zeros( [ 2, 2 ], {
434
434
  * 'dtype': 'int16'
@@ -465,7 +465,7 @@ declare function zerosLike( x: int16ndarray, options?: Options ): int16ndarray;
465
465
  * @returns zero-filled array
466
466
  *
467
467
  * @example
468
- * var zeros = require( `@stdlib/ndarray/zeros` );
468
+ * var zeros = require( '@stdlib/ndarray-zeros' );
469
469
  *
470
470
  * var x = zeros( [ 2, 2 ], {
471
471
  * 'dtype': 'int8'
@@ -502,7 +502,7 @@ declare function zerosLike( x: int8ndarray, options?: Options ): int8ndarray;
502
502
  * @returns zero-filled array
503
503
  *
504
504
  * @example
505
- * var zeros = require( `@stdlib/ndarray/zeros` );
505
+ * var zeros = require( '@stdlib/ndarray-zeros' );
506
506
  *
507
507
  * var x = zeros( [ 2, 2 ], {
508
508
  * 'dtype': 'uint32'
@@ -524,7 +524,7 @@ declare function zerosLike( x: int8ndarray, options?: Options ): int8ndarray;
524
524
  * dt = y.dtype;
525
525
  * // returns 'uint32'
526
526
  */
527
- declare function zerosLike( x: uint32ndarray, options?: Options ): uint32ndarray; // tslint:disable-line:max-line-length
527
+ declare function zerosLike( x: uint32ndarray, options?: Options ): uint32ndarray;
528
528
 
529
529
  /**
530
530
  * Creates a zero-filled array having the same shape and data type as a provided input ndarray.
@@ -539,7 +539,7 @@ declare function zerosLike( x: uint32ndarray, options?: Options ): uint32ndarray
539
539
  * @returns zero-filled array
540
540
  *
541
541
  * @example
542
- * var zeros = require( `@stdlib/ndarray/zeros` );
542
+ * var zeros = require( '@stdlib/ndarray-zeros' );
543
543
  *
544
544
  * var x = zeros( [ 2, 2 ], {
545
545
  * 'dtype': 'uint16'
@@ -561,7 +561,7 @@ declare function zerosLike( x: uint32ndarray, options?: Options ): uint32ndarray
561
561
  * dt = y.dtype;
562
562
  * // returns 'uint16'
563
563
  */
564
- declare function zerosLike( x: uint16ndarray, options?: Options ): uint16ndarray; // tslint:disable-line:max-line-length
564
+ declare function zerosLike( x: uint16ndarray, options?: Options ): uint16ndarray;
565
565
 
566
566
  /**
567
567
  * Creates a zero-filled array having the same shape and data type as a provided input ndarray.
@@ -576,7 +576,7 @@ declare function zerosLike( x: uint16ndarray, options?: Options ): uint16ndarray
576
576
  * @returns zero-filled array
577
577
  *
578
578
  * @example
579
- * var zeros = require( `@stdlib/ndarray/zeros` );
579
+ * var zeros = require( '@stdlib/ndarray-zeros' );
580
580
  *
581
581
  * var x = zeros( [ 2, 2 ], {
582
582
  * 'dtype': 'uint8'
@@ -613,7 +613,7 @@ declare function zerosLike( x: uint8ndarray, options?: Options ): uint8ndarray;
613
613
  * @returns zero-filled array
614
614
  *
615
615
  * @example
616
- * var zeros = require( `@stdlib/ndarray/zeros` );
616
+ * var zeros = require( '@stdlib/ndarray-zeros' );
617
617
  *
618
618
  * var x = zeros( [ 2, 2 ], {
619
619
  * 'dtype': 'uint8c'
@@ -635,7 +635,7 @@ declare function zerosLike( x: uint8ndarray, options?: Options ): uint8ndarray;
635
635
  * dt = y.dtype;
636
636
  * // returns 'uint8c'
637
637
  */
638
- declare function zerosLike( x: uint8cndarray, options?: Options ): uint8cndarray; // tslint:disable-line:max-line-length
638
+ declare function zerosLike( x: uint8cndarray, options?: Options ): uint8cndarray;
639
639
 
640
640
  /**
641
641
  * Creates a zero-filled double-precision floating-point array having the same shape as a provided input ndarray.
@@ -651,7 +651,7 @@ declare function zerosLike( x: uint8cndarray, options?: Options ): uint8cndarray
651
651
  * @returns zero-filled array
652
652
  *
653
653
  * @example
654
- * var zeros = require( `@stdlib/ndarray/zeros` );
654
+ * var zeros = require( '@stdlib/ndarray-zeros' );
655
655
  *
656
656
  * var x = zeros( [ 2, 2 ], {
657
657
  * 'dtype': 'generic'
@@ -675,7 +675,7 @@ declare function zerosLike( x: uint8cndarray, options?: Options ): uint8cndarray
675
675
  * dt = y.dtype;
676
676
  * // returns 'float64'
677
677
  */
678
- declare function zerosLike( x: ndarray, options: Float64Options ): float64ndarray; // tslint:disable-line:max-line-length
678
+ declare function zerosLike( x: ndarray, options: Float64Options ): float64ndarray;
679
679
 
680
680
  /**
681
681
  * Creates a zero-filled single-precision floating-point array having the same shape as a provided input ndarray.
@@ -691,7 +691,7 @@ declare function zerosLike( x: ndarray, options: Float64Options ): float64ndarra
691
691
  * @returns zero-filled array
692
692
  *
693
693
  * @example
694
- * var zeros = require( `@stdlib/ndarray/zeros` );
694
+ * var zeros = require( '@stdlib/ndarray-zeros' );
695
695
  *
696
696
  * var x = zeros( [ 2, 2 ], {
697
697
  * 'dtype': 'float64'
@@ -715,7 +715,7 @@ declare function zerosLike( x: ndarray, options: Float64Options ): float64ndarra
715
715
  * dt = y.dtype;
716
716
  * // returns 'float32'
717
717
  */
718
- declare function zerosLike( x: ndarray, options: Float32Options ): float32ndarray; // tslint:disable-line:max-line-length
718
+ declare function zerosLike( x: ndarray, options: Float32Options ): float32ndarray;
719
719
 
720
720
  /**
721
721
  * Creates a zero-filled double-precision complex floating-point array having the same shape as a provided input ndarray.
@@ -731,7 +731,7 @@ declare function zerosLike( x: ndarray, options: Float32Options ): float32ndarra
731
731
  * @returns zero-filled array
732
732
  *
733
733
  * @example
734
- * var zeros = require( `@stdlib/ndarray/zeros` );
734
+ * var zeros = require( '@stdlib/ndarray-zeros' );
735
735
  *
736
736
  * var x = zeros( [ 2, 2 ], {
737
737
  * 'dtype': 'float64'
@@ -755,7 +755,7 @@ declare function zerosLike( x: ndarray, options: Float32Options ): float32ndarra
755
755
  * dt = y.dtype;
756
756
  * // returns 'complex128'
757
757
  */
758
- declare function zerosLike( x: ndarray, options: Complex128Options ): complex128ndarray; // tslint:disable-line:max-line-length
758
+ declare function zerosLike( x: ndarray, options: Complex128Options ): complex128ndarray;
759
759
 
760
760
  /**
761
761
  * Creates a zero-filled single-precision complex floating-point array having the same shape as a provided input ndarray.
@@ -771,7 +771,7 @@ declare function zerosLike( x: ndarray, options: Complex128Options ): complex128
771
771
  * @returns zero-filled array
772
772
  *
773
773
  * @example
774
- * var zeros = require( `@stdlib/ndarray/zeros` );
774
+ * var zeros = require( '@stdlib/ndarray-zeros' );
775
775
  *
776
776
  * var x = zeros( [ 2, 2 ], {
777
777
  * 'dtype': 'float64'
@@ -795,7 +795,7 @@ declare function zerosLike( x: ndarray, options: Complex128Options ): complex128
795
795
  * dt = y.dtype;
796
796
  * // returns 'complex64'
797
797
  */
798
- declare function zerosLike( x: ndarray, options: Complex64Options ): complex64ndarray; // tslint:disable-line:max-line-length
798
+ declare function zerosLike( x: ndarray, options: Complex64Options ): complex64ndarray;
799
799
 
800
800
  /**
801
801
  * Creates a zero-filled 32-bit signed integer array having the same shape as a provided input ndarray.
@@ -811,7 +811,7 @@ declare function zerosLike( x: ndarray, options: Complex64Options ): complex64nd
811
811
  * @returns zero-filled array
812
812
  *
813
813
  * @example
814
- * var zeros = require( `@stdlib/ndarray/zeros` );
814
+ * var zeros = require( '@stdlib/ndarray-zeros' );
815
815
  *
816
816
  * var x = zeros( [ 2, 2 ], {
817
817
  * 'dtype': 'float64'
@@ -851,7 +851,7 @@ declare function zerosLike( x: ndarray, options: Int32Options ): int32ndarray;
851
851
  * @returns zero-filled array
852
852
  *
853
853
  * @example
854
- * var zeros = require( `@stdlib/ndarray/zeros` );
854
+ * var zeros = require( '@stdlib/ndarray-zeros' );
855
855
  *
856
856
  * var x = zeros( [ 2, 2 ], {
857
857
  * 'dtype': 'float64'
@@ -891,7 +891,7 @@ declare function zerosLike( x: ndarray, options: Int16Options ): int16ndarray;
891
891
  * @returns zero-filled array
892
892
  *
893
893
  * @example
894
- * var zeros = require( `@stdlib/ndarray/zeros` );
894
+ * var zeros = require( '@stdlib/ndarray-zeros' );
895
895
  *
896
896
  * var x = zeros( [ 2, 2 ], {
897
897
  * 'dtype': 'float64'
@@ -931,7 +931,7 @@ declare function zerosLike( x: ndarray, options: Int8Options ): int8ndarray;
931
931
  * @returns zero-filled array
932
932
  *
933
933
  * @example
934
- * var zeros = require( `@stdlib/ndarray/zeros` );
934
+ * var zeros = require( '@stdlib/ndarray-zeros' );
935
935
  *
936
936
  * var x = zeros( [ 2, 2 ], {
937
937
  * 'dtype': 'float64'
@@ -971,7 +971,7 @@ declare function zerosLike( x: ndarray, options: Uint32Options ): uint32ndarray;
971
971
  * @returns zero-filled array
972
972
  *
973
973
  * @example
974
- * var zeros = require( `@stdlib/ndarray/zeros` );
974
+ * var zeros = require( '@stdlib/ndarray-zeros' );
975
975
  *
976
976
  * var x = zeros( [ 2, 2 ], {
977
977
  * 'dtype': 'float64'
@@ -1011,7 +1011,7 @@ declare function zerosLike( x: ndarray, options: Uint16Options ): uint16ndarray;
1011
1011
  * @returns zero-filled array
1012
1012
  *
1013
1013
  * @example
1014
- * var zeros = require( `@stdlib/ndarray/zeros` );
1014
+ * var zeros = require( '@stdlib/ndarray-zeros' );
1015
1015
  *
1016
1016
  * var x = zeros( [ 2, 2 ], {
1017
1017
  * 'dtype': 'float64'
@@ -1051,7 +1051,7 @@ declare function zerosLike( x: ndarray, options: Uint8Options ): uint8ndarray;
1051
1051
  * @returns zero-filled array
1052
1052
  *
1053
1053
  * @example
1054
- * var zeros = require( `@stdlib/ndarray/zeros` );
1054
+ * var zeros = require( '@stdlib/ndarray-zeros' );
1055
1055
  *
1056
1056
  * var x = zeros( [ 2, 2 ], {
1057
1057
  * 'dtype': 'float64'
@@ -1091,7 +1091,7 @@ declare function zerosLike( x: ndarray, options: Uint8COptions ): uint8cndarray;
1091
1091
  * @returns zero-filled array
1092
1092
  *
1093
1093
  * @example
1094
- * var zeros = require( `@stdlib/ndarray/zeros` );
1094
+ * var zeros = require( '@stdlib/ndarray-zeros' );
1095
1095
  *
1096
1096
  * var x = zeros( [ 2, 2 ], {
1097
1097
  * 'dtype': 'float64'
@@ -1113,7 +1113,7 @@ declare function zerosLike( x: ndarray, options: Uint8COptions ): uint8cndarray;
1113
1113
  * dt = y.dtype;
1114
1114
  * // returns 'generic'
1115
1115
  */
1116
- declare function zerosLike( x: ndarray, options?: Options | OptionsWithDType ): typedndarray<number>; // tslint:disable-line:max-line-length
1116
+ declare function zerosLike( x: ndarray, options?: Options | OptionsWithDType ): typedndarray<number>;
1117
1117
 
1118
1118
 
1119
1119
  // EXPORTS //
package/lib/main.js CHANGED
@@ -28,6 +28,9 @@ var shape2strides = require( '@stdlib/ndarray-base-shape2strides' );
28
28
  var strides2offset = require( '@stdlib/ndarray-base-strides2offset' );
29
29
  var buffer = require( '@stdlib/ndarray-base-buffer' );
30
30
  var numel = require( '@stdlib/ndarray-base-numel' );
31
+ var getDType = require( '@stdlib/ndarray-dtype' );
32
+ var getShape = require( '@stdlib/ndarray-shape' );
33
+ var getOrder = require( '@stdlib/ndarray-order' );
31
34
  var ndarray = require( '@stdlib/ndarray-ctor' );
32
35
  var format = require( '@stdlib/string-format' );
33
36
 
@@ -91,7 +94,7 @@ function zerosLike( x ) {
91
94
  if ( hasOwnProp( options, 'dtype' ) ) {
92
95
  dtype = options.dtype;
93
96
  } else {
94
- dtype = x.dtype;
97
+ dtype = getDType( x );
95
98
  }
96
99
  if ( hasOwnProp( options, 'shape' ) ) {
97
100
  sh = options.shape;
@@ -102,12 +105,12 @@ function zerosLike( x ) {
102
105
  throw new TypeError( format( 'invalid option. `%s` option must be a nonnegative integer or an array of nonnegative integers. Option: `%s`.', 'shape', sh ) );
103
106
  }
104
107
  } else {
105
- sh = x.shape;
108
+ sh = getShape( x );
106
109
  }
107
110
  if ( hasOwnProp( options, 'order' ) ) {
108
111
  order = options.order;
109
112
  } else {
110
- order = x.order;
113
+ order = getOrder( x );
111
114
  }
112
115
  if ( hasOwnProp( options, 'mode' ) ) {
113
116
  opts.mode = options.mode;
@@ -119,16 +122,13 @@ function zerosLike( x ) {
119
122
  opts.readonly = options.readonly;
120
123
  }
121
124
  } else {
122
- dtype = x.dtype;
123
- sh = x.shape;
124
- order = x.order;
125
+ dtype = getDType( x );
126
+ sh = getShape( x );
127
+ order = getOrder( x );
125
128
  }
126
129
  ndims = sh.length;
127
130
  if ( ndims > 0 ) {
128
131
  len = numel( sh );
129
- if ( len < 0 ) {
130
- len = 0; // note: we should only get here if an inferred shape is invalid (i.e., contains negative dimension sizes)
131
- }
132
132
  st = shape2strides( sh, order );
133
133
  } else {
134
134
  // For 0-dimensional arrays, the buffer should contain a single element...
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stdlib/ndarray-zeros-like",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "description": "Create a zero-filled ndarray having the same shape and data type as a provided ndarray.",
5
5
  "license": "Apache-2.0",
6
6
  "author": {
@@ -37,42 +37,46 @@
37
37
  "url": "https://github.com/stdlib-js/stdlib/issues"
38
38
  },
39
39
  "dependencies": {
40
- "@stdlib/assert-has-own-property": "^0.1.0",
41
- "@stdlib/assert-is-ndarray-like": "^0.1.0",
42
- "@stdlib/assert-is-nonnegative-integer-array": "^0.1.0",
43
- "@stdlib/assert-is-plain-object": "^0.1.0",
44
- "@stdlib/ndarray-base-buffer": "^0.1.0",
45
- "@stdlib/ndarray-base-numel": "^0.1.0",
46
- "@stdlib/ndarray-base-shape2strides": "^0.1.0",
47
- "@stdlib/ndarray-base-strides2offset": "^0.1.0",
48
- "@stdlib/ndarray-ctor": "^0.1.0",
49
- "@stdlib/string-format": "^0.1.0",
50
- "@stdlib/types": "^0.1.0",
51
- "@stdlib/error-tools-fmtprodmsg": "^0.1.0"
40
+ "@stdlib/assert-has-own-property": "^0.2.0",
41
+ "@stdlib/assert-is-ndarray-like": "^0.2.0",
42
+ "@stdlib/assert-is-nonnegative-integer-array": "^0.2.0",
43
+ "@stdlib/assert-is-plain-object": "^0.2.0",
44
+ "@stdlib/ndarray-base-buffer": "^0.2.0",
45
+ "@stdlib/ndarray-base-numel": "^0.2.0",
46
+ "@stdlib/ndarray-base-shape2strides": "^0.2.0",
47
+ "@stdlib/ndarray-base-strides2offset": "^0.2.0",
48
+ "@stdlib/ndarray-ctor": "^0.2.0",
49
+ "@stdlib/ndarray-dtype": "^0.2.0",
50
+ "@stdlib/ndarray-order": "^0.2.0",
51
+ "@stdlib/ndarray-shape": "^0.2.0",
52
+ "@stdlib/string-format": "^0.2.0",
53
+ "@stdlib/types": "^0.3.1",
54
+ "@stdlib/error-tools-fmtprodmsg": "^0.2.0"
52
55
  },
53
56
  "devDependencies": {
54
57
  "@stdlib/array-complex128": "^0.1.0",
55
58
  "@stdlib/array-complex64": "^0.1.0",
56
- "@stdlib/array-float32": "^0.1.0",
57
- "@stdlib/array-float64": "^0.1.0",
58
- "@stdlib/array-int16": "^0.1.0",
59
- "@stdlib/array-int32": "^0.1.0",
60
- "@stdlib/array-int8": "^0.1.0",
61
- "@stdlib/array-uint16": "^0.1.0",
62
- "@stdlib/array-uint32": "^0.1.0",
63
- "@stdlib/array-uint8": "^0.1.0",
64
- "@stdlib/array-uint8c": "^0.1.0",
65
- "@stdlib/assert-instance-of": "^0.1.0",
66
- "@stdlib/bench": "^0.1.0",
67
- "@stdlib/math-base-special-pow": "^0.1.0",
59
+ "@stdlib/array-float32": "^0.2.0",
60
+ "@stdlib/array-float64": "^0.2.0",
61
+ "@stdlib/array-int16": "^0.2.0",
62
+ "@stdlib/array-int32": "^0.2.0",
63
+ "@stdlib/array-int8": "^0.2.0",
64
+ "@stdlib/array-uint16": "^0.2.0",
65
+ "@stdlib/array-uint32": "^0.2.0",
66
+ "@stdlib/array-uint8": "^0.2.0",
67
+ "@stdlib/array-uint8c": "^0.2.0",
68
+ "@stdlib/assert-instance-of": "^0.2.0",
69
+ "@stdlib/math-base-special-pow": "^0.2.0",
68
70
  "@stdlib/ndarray-base-zeros": "^0.1.0",
69
- "@stdlib/ndarray-dtypes": "^0.1.0",
71
+ "@stdlib/ndarray-dtypes": "^0.2.0",
70
72
  "@stdlib/ndarray-zeros": "^0.1.0",
71
- "@stdlib/strided-base-reinterpret-complex128": "^0.1.0",
72
- "@stdlib/strided-base-reinterpret-complex64": "^0.1.0",
73
+ "@stdlib/strided-base-reinterpret-complex128": "^0.2.0",
74
+ "@stdlib/strided-base-reinterpret-complex64": "^0.2.0",
73
75
  "tape": "git+https://github.com/kgryte/tape.git#fix/globby",
74
76
  "istanbul": "^0.4.1",
75
- "tap-min": "git+https://github.com/Planeshifter/tap-min.git"
77
+ "tap-min": "git+https://github.com/Planeshifter/tap-min.git",
78
+ "@stdlib/bench-harness": "^0.2.0",
79
+ "@stdlib/bench": "^0.3.1"
76
80
  },
77
81
  "engines": {
78
82
  "node": ">=0.10.0",
@@ -100,7 +104,8 @@
100
104
  "matrix",
101
105
  "fill",
102
106
  "filled",
103
- "zeros"
107
+ "zeros",
108
+ "numpy.zeros_like"
104
109
  ],
105
110
  "funding": {
106
111
  "type": "opencollective",
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