-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.mjs.map
1 lines (1 loc) · 2.55 KB
/
index.mjs.map
1
{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"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\nimport { isPrimitive as isNonNegativeInteger } from '@stdlib/assert-is-nonnegative-integer';\nimport isCollection from '@stdlib/assert-is-collection';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Returns the shape of a provided ndarray.\n*\n* @param {ndarrayLike} x - input ndarray\n* @throws {TypeError} must provide an ndarray\n* @returns {NonNegativeIntegerArray} shape\n*\n* @example\n* import zeros from '@stdlib/ndarray-zeros';\n*\n* var out = shape( zeros( [ 3, 3, 3 ] ) );\n* // returns [ 3, 3, 3 ]\n*/\nfunction shape( x ) {\n\tvar out;\n\tvar sh;\n\tvar d;\n\tvar i;\n\n\t// Note: we intentionally avoid rigorous ndarray checks to minimize performance impacts. This obviously means that non-ndarray-like objects can sneak through, but this is likely all right for the purposes of this function...\n\tif ( typeof x !== 'object' || x === null ) {\n\t\tthrow new TypeError( format( '1kBDv', x ) );\n\t}\n\tsh = x.shape;\n\tif ( !isCollection( sh ) ) {\n\t\tthrow new TypeError( format( '1kBDv', x ) );\n\t}\n\t// Copy the shape in order to avoid unintended mutation...\n\tout = [];\n\tfor ( i = 0; i < sh.length; i++ ) {\n\t\td = sh[ i ];\n\t\tif ( !isNonNegativeInteger( d ) ) {\n\t\t\tthrow new TypeError( format( '1kBDv', x ) );\n\t\t}\n\t\tout.push( d );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default shape;\n"],"names":["shape","x","out","sh","d","i","TypeError","format","isCollection","length","isNonNegativeInteger","push"],"mappings":";;uTA0CA,SAASA,EAAOC,GACf,IAAIC,EACAC,EACAC,EACAC,EAGJ,GAAkB,iBAANJ,GAAwB,OAANA,EAC7B,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAGvC,GADAE,EAAKF,EAAED,OACDQ,EAAcL,GACnB,MAAM,IAAIG,UAAWC,EAAQ,QAASN,IAIvC,IADAC,EAAM,GACAG,EAAI,EAAGA,EAAIF,EAAGM,OAAQJ,IAAM,CAEjC,GADAD,EAAID,EAAIE,IACFK,EAAsBN,GAC3B,MAAM,IAAIE,UAAWC,EAAQ,QAASN,IAEvCC,EAAIS,KAAMP,EACV,CACD,OAAOF,CACR"}