-
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathindex.mjs.map
1 lines (1 loc) · 2.74 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 strides2offset from '@stdlib/ndarray-base-strides2offset';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Returns the index offset specifying the underlying buffer index of the first iterated ndarray element.\n*\n* @param {ndarrayLike} x - input ndarray\n* @throws {TypeError} must provide an ndarray\n* @returns {NonNegativeInteger} index offset\n*\n* @example\n* import zeros from '@stdlib/ndarray-zeros';\n*\n* var n = offset( zeros( [ 3, 3, 3 ] ) );\n* // returns 0\n*/\nfunction offset( x ) {\n\tvar st;\n\tvar sh;\n\tvar n;\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( '1k9Dv', x ) );\n\t}\n\tn = x.offset;\n\tif ( isNonNegativeInteger( n ) ) {\n\t\treturn n;\n\t}\n\tsh = x.shape;\n\tif ( !isCollection( sh ) ) {\n\t\tthrow new TypeError( format( '1k9Dv', x ) );\n\t}\n\tst = x.strides;\n\tif ( sh.length === 0 || !isCollection( st ) ) {\n\t\treturn 0;\n\t}\n\tn = strides2offset( sh, st );\n\tif ( isNonNegativeInteger( n ) ) {\n\t\treturn n;\n\t}\n\tthrow new TypeError( format( '1k9Dv', x ) );\n}\n\n\n// EXPORTS //\n\nexport default offset;\n"],"names":["offset","x","st","sh","n","TypeError","format","isNonNegativeInteger","shape","isCollection","strides","length","strides2offset"],"mappings":";;6ZA2CA,SAASA,EAAQC,GAChB,IAAIC,EACAC,EACAC,EAGJ,GAAkB,iBAANH,GAAwB,OAANA,EAC7B,MAAM,IAAII,UAAWC,EAAQ,QAASL,IAGvC,GADAG,EAAIH,EAAED,OACDO,EAAsBH,GAC1B,OAAOA,EAGR,GADAD,EAAKF,EAAEO,OACDC,EAAcN,GACnB,MAAM,IAAIE,UAAWC,EAAQ,QAASL,IAGvC,GADAC,EAAKD,EAAES,QACY,IAAdP,EAAGQ,SAAiBF,EAAcP,GACtC,OAAO,EAGR,GADAE,EAAIQ,EAAgBT,EAAID,GACnBK,EAAsBH,GAC1B,OAAOA,EAER,MAAM,IAAIC,UAAWC,EAAQ,QAASL,GACvC"}