UNPKG

molstar

Version:

A comprehensive macromolecular library.

36 lines 1.31 kB
"use strict"; /** * Copyright (c) 2017-2019 mol* contributors, licensed under MIT, See LICENSE file for more info. * * @author Alexander Rose <alexander.rose@weirdbyte.de> * @author David Sehnal <david.sehnal@gmail.com> */ Object.defineProperty(exports, "__esModule", { value: true }); exports.uint8ToString = exports.flipByteOrder = exports.IsNativeEndianLittle = void 0; exports.IsNativeEndianLittle = new Uint16Array(new Uint8Array([0x12, 0x34]).buffer)[0] === 0x3412; function flipByteOrder(data, bytes) { var buffer = new ArrayBuffer(data.length); var ret = new Uint8Array(buffer); for (var i = 0, n = data.length; i < n; i += bytes) { for (var j = 0; j < bytes; j++) { ret[i + bytes - j - 1] = data[i + j]; } } return buffer; } exports.flipByteOrder = flipByteOrder; var ChunkSize = 0x7000; function uint8ToString(array) { if (array.length > ChunkSize) { var c = []; for (var i = 0; i < array.length; i += ChunkSize) { c.push(String.fromCharCode.apply(null, array.subarray(i, i + ChunkSize))); } return c.join(''); } else { return String.fromCharCode.apply(null, array); } } exports.uint8ToString = uint8ToString; //# sourceMappingURL=binary.js.map