-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.mjs.map
More file actions
1 lines (1 loc) · 5.71 KB
/
Copy pathindex.mjs.map
File metadata and controls
1 lines (1 loc) · 5.71 KB
1
{"version":3,"file":"index.mjs","sources":["../lib/ctors.js","../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\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n// MODULES //\n\nimport Buffer from '@stdlib/buffer-ctor';\n\nimport Float64Array from '@stdlib/array-float64';\nimport Float32Array from '@stdlib/array-float32';\nimport Float16Array from '@stdlib/array-float16';\nimport Int16Array from '@stdlib/array-int16';\nimport Int32Array from '@stdlib/array-int32';\nimport Int8Array from '@stdlib/array-int8';\nimport Uint16Array from '@stdlib/array-uint16';\nimport Uint32Array from '@stdlib/array-uint32';\nimport Uint8Array from '@stdlib/array-uint8';\nimport Uint8ClampedArray from '@stdlib/array-uint8c';\nimport Complex64Array from '@stdlib/array-complex64';\nimport Complex128Array from '@stdlib/array-complex128';\nimport BooleanArray from '@stdlib/array-bool';\n\n// FUNCTIONS //\n\n/**\n* Throws an error.\n*\n* @private\n* @throws {Error} not implemented\n*/\nfunction notImplemented() {\n\tthrow new Error( format('0i900') );\n}\n\n// MAIN //\n\n// Mapping from data types to underlying buffer constructors...\nvar ctors = { // eslint-disable-line vars-on-top\n\t'binary': Buffer,\n\t'float64': Float64Array,\n\t'float32': Float32Array,\n\t'float16': Float16Array,\n\t'generic': Array, // TODO: replace with `stdlib` pkg\n\t'int16': Int16Array,\n\t'int32': Int32Array,\n\t'int8': Int8Array,\n\t'uint16': Uint16Array,\n\t'uint32': Uint32Array,\n\t'uint8': Uint8Array,\n\t'uint8c': Uint8ClampedArray,\n\t'complex32': notImplemented, // FIXME: replace with Complex32Array constructor once implemented\n\t'complex64': Complex64Array,\n\t'complex128': Complex128Array,\n\t'bool': BooleanArray\n};\n\n// EXPORTS //\n\nexport default ctors;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 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 isFunction from '@stdlib/assert-is-function';\nimport isStructDataType from '@stdlib/ndarray-base-assert-is-struct-data-type';\nimport resolveStr from '@stdlib/ndarray-base-dtype-resolve-str';\nimport structFactory from '@stdlib/array-struct-factory';\nimport table from './ctors.js';\n\n\n// VARIABLES //\n\n// Initialize a cache to storing memoized struct array constructors:\nvar CACHE = {}; // TODO: consider adding/using `@stdlib/array/memoized-struct-factory`; should we need to memoize struct array constructors elsewhere, we should centralize that logic, rather than have multiple caches.\n\n\n// MAIN //\n\n/**\n* Returns an ndarray data buffer constructor.\n*\n* @param {*} dtype - data type\n* @returns {(Function|null)} data buffer constructor or null\n*\n* @example\n* var ctor = ctors( 'float64' );\n* // returns <Function>\n*\n* @example\n* var ctor = ctors( 'float' );\n* // returns null\n*/\nfunction ctors( dtype ) {\n\tvar struct;\n\tvar ctor;\n\tvar key;\n\n\t// Case: string || dtype_instance_with_string\n\tif ( !isFunction( dtype ) ) {\n\t\tkey = resolveStr( dtype );\n\t\tctor = table[ key ] || null;\n\t\tif ( ctor ) {\n\t\t\treturn ctor;\n\t\t}\n\t}\n\t// Case: struct_ctor || dtype_instance_with_struct_ctor\n\tif ( isStructDataType( dtype ) ) {\n\t\tif ( key ) {\n\t\t\t// Data type instance (note: we assume that `key === struct.layout`):\n\t\t\tstruct = dtype.value;\n\t\t} else {\n\t\t\t// Struct constructor:\n\t\t\tstruct = dtype;\n\t\t\tkey = struct.layout;\n\t\t}\n\t\tctor = CACHE[ key ];\n\t\tif ( ctor ) {\n\t\t\treturn ctor;\n\t\t}\n\t\tctor = structFactory( struct );\n\t\tCACHE[ key ] = ctor;\n\t\treturn ctor;\n\t}\n\treturn null;\n}\n\n\n// EXPORTS //\n\nexport default ctors;\n"],"names":["ctors","binary","Buffer","float64","Float64Array","float32","Float32Array","float16","Float16Array","generic","Array","int16","Int16Array","int32","Int32Array","int8","Int8Array","uint16","Uint16Array","uint32","Uint32Array","uint8","Uint8Array","uint8c","Uint8ClampedArray","complex32","Error","format","complex64","Complex64Array","complex128","Complex128Array","bool","BooleanArray","CACHE","dtype","struct","ctor","key","isFunction","resolveStr","table","isStructDataType","value","layout","structFactory"],"mappings":";;qrDAuDA,IAAIA,EAAQ,CACXC,OAAUC,EACVC,QAAWC,EACXC,QAAWC,EACXC,QAAWC,EACXC,QAAWC,MACXC,MAASC,EACTC,MAASC,EACTC,KAAQC,EACRC,OAAUC,EACVC,OAAUC,EACVC,MAASC,EACTC,OAAUC,EACVC,UApBD,WACC,MAAM,IAAIC,MAAOC,EAAO,SACzB,EAmBCC,UAAaC,EACbC,WAAcC,EACdC,KAAQC,GCvCLC,EAAQ,CAAA,EAmBZ,SAASlC,EAAOmC,GACf,IAAIC,EACAC,EACAC,EAGJ,OAAMC,EAAYJ,KACjBG,EAAME,EAAYL,GAClBE,EAAOI,EAAOH,IAAS,MAEfD,EAIJK,EAAkBP,IACjBG,EAEJF,EAASD,EAAMQ,MAIfL,GADAF,EAASD,GACIS,QAEdP,EAAOH,EAAOI,MAIdD,EAAOQ,EAAeT,GACtBF,EAAOI,GAAQD,GAHPA,GAMF,IACR"}