-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.mjs.map
1 lines (1 loc) · 3.29 KB
/
index.mjs.map
1
{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 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 isndarrayLike from '@stdlib/assert-is-ndarray-like';\nimport { isPrimitive as isInteger } from '@stdlib/assert-is-integer';\nimport normalizeIndex from '@stdlib/ndarray-base-normalize-index';\nimport getShape from '@stdlib/ndarray-shape';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Returns an ndarray element.\n*\n* @param {ndarrayLike} x - input ndarray\n* @param {...integer} [indices] - indices\n* @throws {TypeError} first argument must be an ndarray\n* @throws {TypeError} index arguments must be integers\n* @throws {RangeError} number of index arguments must equal the number of dimensions\n* @returns {*} ndarray element\n*\n* @example\n* import zeros from '@stdlib/ndarray-zeros';\n*\n* var x = zeros( [ 3, 3 ] );\n* // returns <ndarray>\n*\n* var v = at( x, 0, 0 );\n* // returns 0\n*\n* v = at( x, 5, 5 );\n* // returns undefined\n*/\nfunction at( x ) {\n\tvar nargs;\n\tvar args;\n\tvar idx;\n\tvar sh;\n\tvar N;\n\tvar i;\n\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( '1q34f', x ) );\n\t}\n\tsh = getShape( x );\n\tN = sh.length;\n\tnargs = arguments.length - 1;\n\tif ( nargs < N ) {\n\t\tthrow new RangeError( 'invalid invocation. Insufficient arguments. Array shape: (%s). Number of indices: %u.', sh.join( ',' ), nargs );\n\t} else if ( nargs > N ) {\n\t\tthrow new RangeError( 'invalid invocation. Too many arguments. Array shape: (%s). Number of indices: %u.', sh.join( ',' ), nargs );\n\t}\n\targs = [];\n\tfor ( i = 1; i <= nargs; i++ ) {\n\t\tidx = arguments[ i ];\n\t\tif ( !isInteger( idx ) ) {\n\t\t\tthrow new TypeError( format( '1q3FR', idx ) );\n\t\t}\n\t\tidx = normalizeIndex( idx, sh[i-1]-1 );\n\t\tif ( idx === -1 ) {\n\t\t\t// Index is out-of-bounds...\n\t\t\treturn;\n\t\t}\n\t\targs.push( idx );\n\t}\n\treturn x.get.apply( x, args );\n}\n\n\n// EXPORTS //\n\nexport default at;\n"],"names":["at","x","nargs","args","idx","sh","N","i","isndarrayLike","TypeError","format","getShape","length","arguments","RangeError","join","isInteger","normalizeIndex","push","get","apply"],"mappings":";;4eAqDA,SAASA,EAAIC,GACZ,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EAEJ,IAAMC,EAAeP,GACpB,MAAM,IAAIQ,UAAWC,EAAQ,QAAST,IAKvC,GAFAK,GADAD,EAAKM,EAAUV,IACRW,QACPV,EAAQW,UAAUD,OAAS,GACdN,EACZ,MAAM,IAAIQ,WAAY,wFAAyFT,EAAGU,KAAM,KAAOb,GACzH,GAAKA,EAAQI,EACnB,MAAM,IAAIQ,WAAY,oFAAqFT,EAAGU,KAAM,KAAOb,GAG5H,IADAC,EAAO,GACDI,EAAI,EAAGA,GAAKL,EAAOK,IAAM,CAE9B,IAAMS,EADNZ,EAAMS,UAAWN,IAEhB,MAAM,IAAIE,UAAWC,EAAQ,QAASN,IAGvC,IAAc,KADdA,EAAMa,EAAgBb,EAAKC,EAAGE,EAAE,GAAG,IAGlC,OAEDJ,EAAKe,KAAMd,EACX,CACD,OAAOH,EAAEkB,IAAIC,MAAOnB,EAAGE,EACxB"}