UNPKG

@woosh/meep-engine

Version:

Pure JavaScript game engine. Fully featured and production ready.

29 lines (20 loc) 761 B
import { EndianType } from "./EndianType.js"; let platform_endianness = EndianType.LittleEndian; let platform_endianness_inferred = false; /** * Determines underlying native endianness type * Useful for knowing byte order in TypedArrays * @returns {EndianType} */ export function platform_compute_endianness() { if (platform_endianness_inferred) { return platform_endianness; } const buffer = new ArrayBuffer(2); const uint8 = new Uint8Array(buffer); const uint16 = new Uint16Array(buffer); uint8[0] = 0x13; platform_endianness = ((uint16[0] & 0xFF) === 0x13) ? EndianType.LittleEndian : EndianType.BigEndian; platform_endianness_inferred = true; return platform_endianness; }