Line data Source code
1 1 : import { INT32_SIZE } from "./constants.ts"; 2 : 3 : /** 4 : * See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Int32Array 5 : */ 6 1 : const I32Array: typeof Int32Array = (() => { 7 2 : try { 8 2 : const buffer = new ArrayBuffer(4); 9 2 : const view = new Int32Array(buffer); 10 2 : view[0] = INT32_SIZE; 11 2 : if (view[0] === -INT32_SIZE) { 12 2 : return Int32Array; 13 2 : } 14 2 : } catch (_) { 15 : // nothing to do here 16 0 : } 17 0 : return (Array as unknown) as typeof Int32Array; 18 1 : })(); 19 1 : export { I32Array as Int32Array };