1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | exports.writeUInt32LE = exports.readUInt32LE = exports.writeUInt32BE = exports.readUInt32BE = exports.writeUInt16LE = exports.readUInt16LE = exports.writeUInt8 = exports.readUInt8 = exports.writeUInt16BE = exports.readUInt16BE = exports.alloc = exports.equals = void 0;
|
4 | function equals(a, b) {
|
5 | if (a.byteLength !== b.byteLength)
|
6 | return false;
|
7 | for (let i = 0; i < a.byteLength; i++) {
|
8 | if (a[i] !== b[i])
|
9 | return false;
|
10 | }
|
11 | return true;
|
12 | }
|
13 | exports.equals = equals;
|
14 | function alloc(length, value) {
|
15 | const a = new Uint8Array(length);
|
16 | for (let i = 0; i < length; i++) {
|
17 | a[i] = value;
|
18 | }
|
19 | return a;
|
20 | }
|
21 | exports.alloc = alloc;
|
22 | function readUInt16BE(source, offset) {
|
23 | return ((source[offset + 0] << 8) | source[offset + 1]) >>> 0;
|
24 | }
|
25 | exports.readUInt16BE = readUInt16BE;
|
26 | function writeUInt16BE(source, value, offset) {
|
27 | source[offset + 0] = value >>> 8;
|
28 | source[offset + 1] = value >>> 0;
|
29 | }
|
30 | exports.writeUInt16BE = writeUInt16BE;
|
31 | function readUInt8(source, offset) {
|
32 | return source[offset];
|
33 | }
|
34 | exports.readUInt8 = readUInt8;
|
35 | function writeUInt8(destination, value, offset) {
|
36 | destination[offset] = value;
|
37 | }
|
38 | exports.writeUInt8 = writeUInt8;
|
39 | function readUInt16LE(source, offset) {
|
40 | return ((source[offset + 0] << 0) >>> 0) | ((source[offset + 1] << 8) >>> 0);
|
41 | }
|
42 | exports.readUInt16LE = readUInt16LE;
|
43 | function writeUInt16LE(destination, value, offset) {
|
44 | destination[offset + 0] = value & 255;
|
45 | value >>>= 8;
|
46 | destination[offset + 1] = value & 255;
|
47 | }
|
48 | exports.writeUInt16LE = writeUInt16LE;
|
49 | function readUInt32BE(source, offset) {
|
50 | return (source[offset] * 2 ** 24 +
|
51 | source[offset + 1] * 2 ** 16 +
|
52 | source[offset + 2] * 2 ** 8 +
|
53 | source[offset + 3]);
|
54 | }
|
55 | exports.readUInt32BE = readUInt32BE;
|
56 | function writeUInt32BE(destination, value, offset) {
|
57 | destination[offset + 3] = value;
|
58 | value >>>= 8;
|
59 | destination[offset + 2] = value;
|
60 | value >>>= 8;
|
61 | destination[offset + 1] = value;
|
62 | value >>>= 8;
|
63 | destination[offset] = value;
|
64 | }
|
65 | exports.writeUInt32BE = writeUInt32BE;
|
66 | function readUInt32LE(source, offset) {
|
67 | return (((source[offset + 0] << 0) >>> 0) |
|
68 | ((source[offset + 1] << 8) >>> 0) |
|
69 | ((source[offset + 2] << 16) >>> 0) |
|
70 | ((source[offset + 3] << 24) >>> 0));
|
71 | }
|
72 | exports.readUInt32LE = readUInt32LE;
|
73 | function writeUInt32LE(destination, value, offset) {
|
74 | destination[offset + 0] = value & 255;
|
75 | value >>>= 8;
|
76 | destination[offset + 1] = value & 255;
|
77 | value >>>= 8;
|
78 | destination[offset + 2] = value & 255;
|
79 | value >>>= 8;
|
80 | destination[offset + 3] = value & 255;
|
81 | }
|
82 | exports.writeUInt32LE = writeUInt32LE;
|
83 |
|
\ | No newline at end of file |