diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 9764f5d..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-01-01T05:22:28.274Z diff --git a/NOTICE b/NOTICE index f7aca1b..e6e7482 100644 --- a/NOTICE +++ b/NOTICE @@ -1 +1 @@ -Copyright (c) 2016-2023 The Stdlib Authors. +Copyright (c) 2016-2024 The Stdlib Authors. diff --git a/dist/index.js b/dist/index.js index 3f137e5..0fe6639 100644 --- a/dist/index.js +++ b/dist/index.js @@ -1,5 +1,5 @@ -"use strict";var u=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var n=u(function(f,a){ -var s=require('@stdlib/assert-is-nonnegative-integer/dist').isPrimitive,o=require('@stdlib/array-ctors/dist'),v=require('@stdlib/array-base-zeros/dist'),i=require('@stdlib/error-tools-fmtprodmsg/dist');function g(e){var r,t;if(!s(e))throw new TypeError(i('02Z2d',e));if(arguments.length>1?r=arguments[1]:r="float64",r==="generic")return v(e);if(t=o(r),t===null)throw new TypeError(i('02Z37',r));return new t(e)}a.exports=g -});var m=n();module.exports=m; +"use strict";var u=function(r,e){return function(){return e||r((e={exports:{}}).exports,e),e.exports}};var n=u(function(l,i){ +var s=require('@stdlib/assert-is-nonnegative-integer/dist').isPrimitive,o=require('@stdlib/array-ctors/dist'),v=require('@stdlib/array-base-zeros/dist'),g=require('@stdlib/array-defaults/dist'),a=require('@stdlib/error-tools-fmtprodmsg/dist'),m=g.get("dtypes.default");function d(r){var e,t;if(!s(r))throw new TypeError(a('02Z2d',r));if(arguments.length>1?e=arguments[1]:e=m,e==="generic")return v(r);if(t=o(e),t===null)throw new TypeError(a('02Z37',e));return new t(r)}i.exports=d +});var c=n();module.exports=c; /** @license Apache-2.0 */ //# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map index 770816d..1a76d89 100644 --- a/dist/index.js.map +++ b/dist/index.js.map @@ -1,7 +1,7 @@ { "version": 3, "sources": ["../lib/main.js", "../lib/index.js"], - "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 isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive;\nvar ctors = require( '@stdlib/array-ctors' );\nvar gzeros = require( '@stdlib/array-base-zeros' );\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Creates a zero-filled array 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 recognized data type\n* @returns {(TypedArray|Array|ComplexArray)} array or typed array\n*\n* @example\n* var arr = zeros( 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = zeros( 2, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*/\nfunction zeros( length ) {\n\tvar dtype;\n\tvar ctor;\n\tif ( !isNonNegativeInteger( length ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a nonnegative integer. Value: `%s`.', length ) );\n\t}\n\tif ( arguments.length > 1 ) {\n\t\tdtype = arguments[ 1 ];\n\t} else {\n\t\tdtype = 'float64';\n\t}\n\tif ( dtype === 'generic' ) {\n\t\treturn gzeros( length );\n\t}\n\tctor = ctors( dtype );\n\tif ( ctor === null ) {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument must be a recognized data type. Value: `%s`.', dtype ) );\n\t}\n\treturn new ctor( length ); // WARNING: we assume that, apart from 'generic', the constructors for supported array data types are zero-filled by default\n}\n\n\n// EXPORTS //\n\nmodule.exports = zeros;\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 array having a specified length.\n*\n* @module @stdlib/array-zeros\n*\n* @example\n* var zeros = require( '@stdlib/array-zeros' );\n*\n* var arr = zeros( 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var zeros = require( '@stdlib/array-zeros' );\n*\n* var arr = zeros( 2, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAuB,QAAS,uCAAwC,EAAE,YAC1EC,EAAQ,QAAS,qBAAsB,EACvCC,EAAS,QAAS,0BAA2B,EAC7CC,EAAS,QAAS,uBAAwB,EAsB9C,SAASC,EAAOC,EAAS,CACxB,IAAIC,EACAC,EACJ,GAAK,CAACP,EAAsBK,CAAO,EAClC,MAAM,IAAI,UAAWF,EAAQ,+EAAgFE,CAAO,CAAE,EAOvH,GALK,UAAU,OAAS,EACvBC,EAAQ,UAAW,CAAE,EAErBA,EAAQ,UAEJA,IAAU,UACd,OAAOJ,EAAQG,CAAO,EAGvB,GADAE,EAAON,EAAOK,CAAM,EACfC,IAAS,KACb,MAAM,IAAI,UAAWJ,EAAQ,iFAAkFG,CAAM,CAAE,EAExH,OAAO,IAAIC,EAAMF,CAAO,CACzB,CAKAN,EAAO,QAAUK,IC/BjB,IAAII,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isNonNegativeInteger", "ctors", "gzeros", "format", "zeros", "length", "dtype", "ctor", "main"] + "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 isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive;\nvar ctors = require( '@stdlib/array-ctors' );\nvar gzeros = require( '@stdlib/array-base-zeros' );\nvar defaults = require( '@stdlib/array-defaults' );\nvar format = require( '@stdlib/string-format' );\n\n\n// VARIABLES //\n\nvar DEFAULT_DTYPE = defaults.get( 'dtypes.default' );\n\n\n// MAIN //\n\n/**\n* Creates a zero-filled array 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 recognized data type\n* @returns {(TypedArray|Array|ComplexArray)} array or typed array\n*\n* @example\n* var arr = zeros( 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var arr = zeros( 2, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*/\nfunction zeros( length ) {\n\tvar dtype;\n\tvar ctor;\n\tif ( !isNonNegativeInteger( length ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a nonnegative integer. Value: `%s`.', length ) );\n\t}\n\tif ( arguments.length > 1 ) {\n\t\tdtype = arguments[ 1 ];\n\t} else {\n\t\tdtype = DEFAULT_DTYPE;\n\t}\n\tif ( dtype === 'generic' ) {\n\t\treturn gzeros( length );\n\t}\n\tctor = ctors( dtype );\n\tif ( ctor === null ) {\n\t\tthrow new TypeError( format( 'invalid argument. Second argument must be a recognized data type. Value: `%s`.', dtype ) );\n\t}\n\treturn new ctor( length ); // WARNING: we assume that, apart from 'generic', the constructors for supported array data types are zero-filled by default\n}\n\n\n// EXPORTS //\n\nmodule.exports = zeros;\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 array having a specified length.\n*\n* @module @stdlib/array-zeros\n*\n* @example\n* var zeros = require( '@stdlib/array-zeros' );\n*\n* var arr = zeros( 2 );\n* // returns [ 0.0, 0.0 ]\n*\n* @example\n* var zeros = require( '@stdlib/array-zeros' );\n*\n* var arr = zeros( 2, 'float32' );\n* // returns [ 0.0, 0.0 ]\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], + "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAuB,QAAS,uCAAwC,EAAE,YAC1EC,EAAQ,QAAS,qBAAsB,EACvCC,EAAS,QAAS,0BAA2B,EAC7CC,EAAW,QAAS,wBAAyB,EAC7CC,EAAS,QAAS,uBAAwB,EAK1CC,EAAgBF,EAAS,IAAK,gBAAiB,EAsBnD,SAASG,EAAOC,EAAS,CACxB,IAAIC,EACAC,EACJ,GAAK,CAACT,EAAsBO,CAAO,EAClC,MAAM,IAAI,UAAWH,EAAQ,+EAAgFG,CAAO,CAAE,EAOvH,GALK,UAAU,OAAS,EACvBC,EAAQ,UAAW,CAAE,EAErBA,EAAQH,EAEJG,IAAU,UACd,OAAON,EAAQK,CAAO,EAGvB,GADAE,EAAOR,EAAOO,CAAM,EACfC,IAAS,KACb,MAAM,IAAI,UAAWL,EAAQ,iFAAkFI,CAAM,CAAE,EAExH,OAAO,IAAIC,EAAMF,CAAO,CACzB,CAKAR,EAAO,QAAUO,ICrCjB,IAAII,EAAO,IAKX,OAAO,QAAUA", + "names": ["require_main", "__commonJSMin", "exports", "module", "isNonNegativeInteger", "ctors", "gzeros", "defaults", "format", "DEFAULT_DTYPE", "zeros", "length", "dtype", "ctor", "main"] } diff --git a/lib/main.js b/lib/main.js index 597d0b2..f1f76f8 100644 --- a/lib/main.js +++ b/lib/main.js @@ -23,9 +23,15 @@ var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; var ctors = require( '@stdlib/array-ctors' ); var gzeros = require( '@stdlib/array-base-zeros' ); +var defaults = require( '@stdlib/array-defaults' ); var format = require( '@stdlib/string-format' ); +// VARIABLES // + +var DEFAULT_DTYPE = defaults.get( 'dtypes.default' ); + + // MAIN // /** @@ -54,7 +60,7 @@ function zeros( length ) { if ( arguments.length > 1 ) { dtype = arguments[ 1 ]; } else { - dtype = 'float64'; + dtype = DEFAULT_DTYPE; } if ( dtype === 'generic' ) { return gzeros( length ); diff --git a/package.json b/package.json index f13bbbd..891fff0 100644 --- a/package.json +++ b/package.json @@ -39,6 +39,7 @@ "dependencies": { "@stdlib/array-base-zeros": "^0.1.1", "@stdlib/array-ctors": "^0.1.0", + "@stdlib/array-defaults": "^0.1.0", "@stdlib/assert-is-nonnegative-integer": "^0.1.0", "@stdlib/string-format": "^0.1.1", "@stdlib/types": "^0.2.0"