ctors.js (1778B)
1 /** 2 * @license Apache-2.0 3 * 4 * Copyright (c) 2018 The Stdlib Authors. 5 * 6 * Licensed under the Apache License, Version 2.0 (the "License"); 7 * you may not use this file except in compliance with the License. 8 * You may obtain a copy of the License at 9 * 10 * http://www.apache.org/licenses/LICENSE-2.0 11 * 12 * Unless required by applicable law or agreed to in writing, software 13 * distributed under the License is distributed on an "AS IS" BASIS, 14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 * See the License for the specific language governing permissions and 16 * limitations under the License. 17 */ 18 19 'use strict'; 20 21 // MODULES // 22 23 var Buffer = require( '@stdlib/buffer/ctor' ); 24 var Float64Array = require( '@stdlib/array/float64' ); 25 var Float32Array = require( '@stdlib/array/float32' ); 26 var Int16Array = require( '@stdlib/array/int16' ); 27 var Int32Array = require( '@stdlib/array/int32' ); 28 var Int8Array = require( '@stdlib/array/int8' ); 29 var Uint16Array = require( '@stdlib/array/uint16' ); 30 var Uint32Array = require( '@stdlib/array/uint32' ); 31 var Uint8Array = require( '@stdlib/array/uint8' ); 32 var Uint8ClampedArray = require( '@stdlib/array/uint8c' ); 33 var Complex64Array = require( '@stdlib/array/complex64' ); 34 var Complex128Array = require( '@stdlib/array/complex128' ); 35 36 37 // MAIN // 38 39 // Mapping from data types to underlying buffer constructors... 40 var ctors = { 41 'binary': Buffer, 42 'float64': Float64Array, 43 'float32': Float32Array, 44 'generic': Array, // TODO: replace with `stdlib` pkg 45 'int16': Int16Array, 46 'int32': Int32Array, 47 'int8': Int8Array, 48 'uint16': Uint16Array, 49 'uint32': Uint32Array, 50 'uint8': Uint8Array, 51 'uint8c': Uint8ClampedArray, 52 'complex64': Complex64Array, 53 'complex128': Complex128Array 54 }; 55 56 57 // EXPORTS // 58 59 module.exports = ctors;