@sapphire/string-store 2.0.0-next.548200f1 → 2.0.0-next.8a922c42
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/index.cjs +241 -241
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/index.d.cts +11 -51
- package/dist/esm/index.d.mts +11 -51
- package/dist/esm/index.mjs +241 -241
- package/dist/esm/index.mjs.map +1 -1
- package/dist/iife/index.global.js +241 -241
- package/dist/iife/index.global.js.map +1 -1
- package/package.json +1 -1
package/dist/esm/index.d.mts
CHANGED
|
@@ -23,47 +23,7 @@ type PointerLike = Pointer | {
|
|
|
23
23
|
[Symbol.toPrimitive](hint: 'number'): number;
|
|
24
24
|
};
|
|
25
25
|
|
|
26
|
-
|
|
27
|
-
at(index: number): number | undefined;
|
|
28
|
-
get maxLength(): number;
|
|
29
|
-
get maxBitLength(): number;
|
|
30
|
-
get length(): number;
|
|
31
|
-
get bitLength(): number;
|
|
32
|
-
writeBit(value: number): void;
|
|
33
|
-
writeInt2(value: number): void;
|
|
34
|
-
writeInt4(value: number): void;
|
|
35
|
-
writeInt8(value: number): void;
|
|
36
|
-
writeInt16(value: number): void;
|
|
37
|
-
writeInt32(value: number): void;
|
|
38
|
-
writeInt64(value: number): void;
|
|
39
|
-
writeBigInt32(value: bigint): void;
|
|
40
|
-
writeBigInt64(value: bigint): void;
|
|
41
|
-
writeFloat32(value: number): void;
|
|
42
|
-
writeFloat64(value: number): void;
|
|
43
|
-
readBit(offset: PointerLike): 0 | 1;
|
|
44
|
-
readInt2(offset: PointerLike): number;
|
|
45
|
-
readUint2(offset: PointerLike): number;
|
|
46
|
-
readInt4(offset: PointerLike): number;
|
|
47
|
-
readUint4(offset: PointerLike): number;
|
|
48
|
-
readInt8(offset: PointerLike): number;
|
|
49
|
-
readUint8(offset: PointerLike): number;
|
|
50
|
-
readInt16(offset: PointerLike): number;
|
|
51
|
-
readUint16(offset: PointerLike): number;
|
|
52
|
-
readInt32(offset: PointerLike): number;
|
|
53
|
-
readUint32(offset: PointerLike): number;
|
|
54
|
-
readInt64(offset: PointerLike): number;
|
|
55
|
-
readUint64(offset: PointerLike): number;
|
|
56
|
-
readBigInt32(offset: PointerLike): bigint;
|
|
57
|
-
readBigUint32(offset: PointerLike): bigint;
|
|
58
|
-
readBigInt64(offset: PointerLike): bigint;
|
|
59
|
-
readBigUint64(offset: PointerLike): bigint;
|
|
60
|
-
readFloat32(offset: PointerLike): number;
|
|
61
|
-
readFloat64(offset: PointerLike): number;
|
|
62
|
-
toString(): string;
|
|
63
|
-
toArray(): Uint16Array;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
declare class UnalignedUint16Array implements DuplexBuffer {
|
|
26
|
+
declare class UnalignedUint16Array {
|
|
67
27
|
#private;
|
|
68
28
|
constructor(maxLength: number);
|
|
69
29
|
at(index: number): number | undefined;
|
|
@@ -103,7 +63,7 @@ declare class UnalignedUint16Array implements DuplexBuffer {
|
|
|
103
63
|
readFloat64(offset: PointerLike): number;
|
|
104
64
|
toString(): string;
|
|
105
65
|
toArray(): Uint16Array;
|
|
106
|
-
static from(value: string |
|
|
66
|
+
static from(value: string | UnalignedUint16Array): UnalignedUint16Array;
|
|
107
67
|
}
|
|
108
68
|
|
|
109
69
|
interface IType<ValueType, BitSize extends number | null, InputValue = ValueType> {
|
|
@@ -113,14 +73,14 @@ interface IType<ValueType, BitSize extends number | null, InputValue = ValueType
|
|
|
113
73
|
* @param buffer The buffer to write to
|
|
114
74
|
* @param value The value to write
|
|
115
75
|
*/
|
|
116
|
-
serialize(buffer:
|
|
76
|
+
serialize(buffer: UnalignedUint16Array, value: InputValue): void;
|
|
117
77
|
/**
|
|
118
78
|
* Deserialize a value from a buffer.
|
|
119
79
|
*
|
|
120
80
|
* @param buffer The buffer to read from
|
|
121
81
|
* @param pointer The pointer indicating the current position in the buffer
|
|
122
82
|
*/
|
|
123
|
-
deserialize(buffer:
|
|
83
|
+
deserialize(buffer: UnalignedUint16Array, pointer: Pointer): ValueType;
|
|
124
84
|
/**
|
|
125
85
|
* The size of the value in bits, or `null` if the size is variable.
|
|
126
86
|
*/
|
|
@@ -266,7 +226,7 @@ declare class Schema<Id extends number = number, Entries extends object = object
|
|
|
266
226
|
* @param defaultMaximumArrayLength The default maximum array length, if any
|
|
267
227
|
* @returns The newly created buffer.
|
|
268
228
|
*/
|
|
269
|
-
serializeRaw(value: Readonly<SerializeValueEntries<Entries>>, defaultMaximumArrayLength?: number):
|
|
229
|
+
serializeRaw(value: Readonly<SerializeValueEntries<Entries>>, defaultMaximumArrayLength?: number): UnalignedUint16Array;
|
|
270
230
|
/**
|
|
271
231
|
* Serialize a value into a buffer.
|
|
272
232
|
*
|
|
@@ -278,7 +238,7 @@ declare class Schema<Id extends number = number, Entries extends object = object
|
|
|
278
238
|
* The schema's ID is written to the buffer first, followed by each property
|
|
279
239
|
* in the schema.
|
|
280
240
|
*/
|
|
281
|
-
serializeInto(buffer:
|
|
241
|
+
serializeInto(buffer: UnalignedUint16Array, value: Readonly<SerializeValueEntries<Entries>>): void;
|
|
282
242
|
/**
|
|
283
243
|
* Deserialize a value from a buffer.
|
|
284
244
|
*
|
|
@@ -291,7 +251,7 @@ declare class Schema<Id extends number = number, Entries extends object = object
|
|
|
291
251
|
* Unlike {@link Schema.serializeInto}, this method does not read the schema's ID
|
|
292
252
|
* from the buffer, that is reserved for the {@link SchemaStore}.
|
|
293
253
|
*/
|
|
294
|
-
deserialize(buffer:
|
|
254
|
+
deserialize(buffer: UnalignedUint16Array | string, pointer: PointerLike): UnwrapSchemaEntries<Entries>;
|
|
295
255
|
/**
|
|
296
256
|
* Adds an array property to the schema.
|
|
297
257
|
*
|
|
@@ -662,14 +622,14 @@ declare class SchemaStore<Entries extends object = object> {
|
|
|
662
622
|
* @param value The value to serialize
|
|
663
623
|
* @returns The serialized buffer
|
|
664
624
|
*/
|
|
665
|
-
serializeRaw<const Id extends KeyOfStore<this>>(id: Id, value: SerializeValue<Entries[Id] & object>):
|
|
625
|
+
serializeRaw<const Id extends KeyOfStore<this>>(id: Id, value: SerializeValue<Entries[Id] & object>): UnalignedUint16Array;
|
|
666
626
|
/**
|
|
667
627
|
* Deserializes a buffer
|
|
668
628
|
*
|
|
669
629
|
* @param buffer The buffer to deserialize
|
|
670
630
|
* @returns The resolved value, including the id of the schema used for deserialization
|
|
671
631
|
*/
|
|
672
|
-
deserialize(buffer: string |
|
|
632
|
+
deserialize(buffer: string | UnalignedUint16Array): DeserializationResult<Entries>;
|
|
673
633
|
/**
|
|
674
634
|
* Gets the serialized ID from a buffer
|
|
675
635
|
*
|
|
@@ -680,7 +640,7 @@ declare class SchemaStore<Entries extends object = object> {
|
|
|
680
640
|
*
|
|
681
641
|
* If an empty value is passed, a {@linkcode RangeError} will be thrown.
|
|
682
642
|
*/
|
|
683
|
-
getIdentifier(buffer: string |
|
|
643
|
+
getIdentifier(buffer: string | UnalignedUint16Array): KeyOfStore<this>;
|
|
684
644
|
/**
|
|
685
645
|
* Iterates over the stores's schema identifiers.
|
|
686
646
|
*
|
|
@@ -737,4 +697,4 @@ declare function toUTF16(buffer: TypedArray): string;
|
|
|
737
697
|
*/
|
|
738
698
|
declare function fromUTF16(buffer: string): Uint16Array;
|
|
739
699
|
|
|
740
|
-
export { ArrayType, BigInt32Type, BigInt64Type, BigUint32Type, BigUint64Type, BitType, BooleanType, ConstantType, type DeserializationResult, type
|
|
700
|
+
export { ArrayType, BigInt32Type, BigInt64Type, BigUint32Type, BigUint64Type, BitType, BooleanType, ConstantType, type DeserializationResult, type EntryOfSchema, type EntryOfStore, FixedLengthArrayType, Float32Type, Float64Type, type IType, Int16Type, Int2Type, Int32Type, Int4Type, Int64Type, Int8Type, type KeyOfSchema, type KeyOfStore, NullableType, Pointer, type PointerLike, Schema, SchemaStore, type SerializeValue, type SerializeValueEntries, type SerializeValueType, SnowflakeType, StringType, type TypedArray, Uint16Type, Uint2Type, Uint32Type, Uint4Type, Uint64Type, Uint8Type, UnalignedUint16Array, type UnwrapSchema, type UnwrapSchemaEntries, type UnwrapSchemaType, type ValueOfSchema, type ValueOfStore, fromUTF16, t, toUTF16 };
|
package/dist/esm/index.mjs
CHANGED
|
@@ -71,247 +71,6 @@ _value = new WeakMap();
|
|
|
71
71
|
__name(_Pointer, "Pointer");
|
|
72
72
|
var Pointer = _Pointer;
|
|
73
73
|
|
|
74
|
-
// src/lib/buffer/UnalignedUint16Array.ts
|
|
75
|
-
var ConverterUint8 = new Uint8Array(8);
|
|
76
|
-
var ConverterUint16 = new Uint16Array(ConverterUint8.buffer);
|
|
77
|
-
var ConverterUint32 = new Uint32Array(ConverterUint8.buffer);
|
|
78
|
-
var ConverterUint64 = new BigUint64Array(ConverterUint8.buffer);
|
|
79
|
-
var ConverterInt32 = new Int32Array(ConverterUint8.buffer);
|
|
80
|
-
var ConverterInt64 = new BigInt64Array(ConverterUint8.buffer);
|
|
81
|
-
var ConverterFloat = new Float32Array(ConverterUint8.buffer);
|
|
82
|
-
var ConverterDouble = new Float64Array(ConverterUint8.buffer);
|
|
83
|
-
var _buffer, _bitLength, _wordIndex, _wordLength, _UnalignedUint16Array_instances, readBit_fn, readByte_fn, bufferRead16_fn, bufferRead32_fn, bufferRead64_fn, writeBit_fn, bufferWrite16_fn;
|
|
84
|
-
var _UnalignedUint16Array = class _UnalignedUint16Array {
|
|
85
|
-
constructor(maxLength) {
|
|
86
|
-
__privateAdd(this, _UnalignedUint16Array_instances);
|
|
87
|
-
__privateAdd(this, _buffer);
|
|
88
|
-
__privateAdd(this, _bitLength, 0);
|
|
89
|
-
__privateAdd(this, _wordIndex, 0);
|
|
90
|
-
__privateAdd(this, _wordLength, 0);
|
|
91
|
-
__privateSet(this, _buffer, new Uint16Array(maxLength));
|
|
92
|
-
}
|
|
93
|
-
at(index) {
|
|
94
|
-
return __privateGet(this, _buffer).at(index);
|
|
95
|
-
}
|
|
96
|
-
get maxLength() {
|
|
97
|
-
return __privateGet(this, _buffer).length;
|
|
98
|
-
}
|
|
99
|
-
get maxBitLength() {
|
|
100
|
-
return __privateGet(this, _buffer).length * 16;
|
|
101
|
-
}
|
|
102
|
-
get length() {
|
|
103
|
-
return __privateGet(this, _wordLength);
|
|
104
|
-
}
|
|
105
|
-
get bitLength() {
|
|
106
|
-
return __privateGet(this, _bitLength);
|
|
107
|
-
}
|
|
108
|
-
writeBit(value) {
|
|
109
|
-
__privateMethod(this, _UnalignedUint16Array_instances, writeBit_fn).call(this, value);
|
|
110
|
-
}
|
|
111
|
-
writeInt2(value) {
|
|
112
|
-
this.writeBit(value & 1);
|
|
113
|
-
this.writeBit(value >> 1);
|
|
114
|
-
}
|
|
115
|
-
writeInt4(value) {
|
|
116
|
-
this.writeInt2(value & 3);
|
|
117
|
-
this.writeInt2(value >> 2);
|
|
118
|
-
}
|
|
119
|
-
writeInt8(value) {
|
|
120
|
-
this.writeInt4(value & 15);
|
|
121
|
-
this.writeInt4(value >> 4);
|
|
122
|
-
}
|
|
123
|
-
writeInt16(value) {
|
|
124
|
-
__privateMethod(this, _UnalignedUint16Array_instances, bufferWrite16_fn).call(this, value);
|
|
125
|
-
}
|
|
126
|
-
writeInt32(value) {
|
|
127
|
-
__privateMethod(this, _UnalignedUint16Array_instances, bufferWrite16_fn).call(this, value);
|
|
128
|
-
__privateMethod(this, _UnalignedUint16Array_instances, bufferWrite16_fn).call(this, value >> 16);
|
|
129
|
-
}
|
|
130
|
-
writeInt64(value) {
|
|
131
|
-
this.writeBigInt64(BigInt(value));
|
|
132
|
-
}
|
|
133
|
-
writeBigInt32(value) {
|
|
134
|
-
ConverterInt64[0] = value;
|
|
135
|
-
__privateMethod(this, _UnalignedUint16Array_instances, bufferWrite16_fn).call(this, ConverterUint16[0]);
|
|
136
|
-
__privateMethod(this, _UnalignedUint16Array_instances, bufferWrite16_fn).call(this, ConverterUint16[1]);
|
|
137
|
-
}
|
|
138
|
-
writeBigInt64(value) {
|
|
139
|
-
ConverterInt64[0] = value;
|
|
140
|
-
__privateMethod(this, _UnalignedUint16Array_instances, bufferWrite16_fn).call(this, ConverterUint16[0]);
|
|
141
|
-
__privateMethod(this, _UnalignedUint16Array_instances, bufferWrite16_fn).call(this, ConverterUint16[1]);
|
|
142
|
-
__privateMethod(this, _UnalignedUint16Array_instances, bufferWrite16_fn).call(this, ConverterUint16[2]);
|
|
143
|
-
__privateMethod(this, _UnalignedUint16Array_instances, bufferWrite16_fn).call(this, ConverterUint16[3]);
|
|
144
|
-
}
|
|
145
|
-
writeFloat32(value) {
|
|
146
|
-
ConverterFloat[0] = value;
|
|
147
|
-
__privateMethod(this, _UnalignedUint16Array_instances, bufferWrite16_fn).call(this, ConverterUint16[0]);
|
|
148
|
-
__privateMethod(this, _UnalignedUint16Array_instances, bufferWrite16_fn).call(this, ConverterUint16[1]);
|
|
149
|
-
}
|
|
150
|
-
writeFloat64(value) {
|
|
151
|
-
ConverterDouble[0] = value;
|
|
152
|
-
__privateMethod(this, _UnalignedUint16Array_instances, bufferWrite16_fn).call(this, ConverterUint16[0]);
|
|
153
|
-
__privateMethod(this, _UnalignedUint16Array_instances, bufferWrite16_fn).call(this, ConverterUint16[1]);
|
|
154
|
-
__privateMethod(this, _UnalignedUint16Array_instances, bufferWrite16_fn).call(this, ConverterUint16[2]);
|
|
155
|
-
__privateMethod(this, _UnalignedUint16Array_instances, bufferWrite16_fn).call(this, ConverterUint16[3]);
|
|
156
|
-
}
|
|
157
|
-
readBit(offset) {
|
|
158
|
-
const ptr = Pointer.from(offset);
|
|
159
|
-
return __privateMethod(this, _UnalignedUint16Array_instances, readBit_fn).call(this, ptr);
|
|
160
|
-
}
|
|
161
|
-
readInt2(offset) {
|
|
162
|
-
return this.readUint2(offset) << 30 >> 30;
|
|
163
|
-
}
|
|
164
|
-
readUint2(offset) {
|
|
165
|
-
const ptr = Pointer.from(offset);
|
|
166
|
-
return __privateMethod(this, _UnalignedUint16Array_instances, readBit_fn).call(this, ptr) | __privateMethod(this, _UnalignedUint16Array_instances, readBit_fn).call(this, ptr) << 1;
|
|
167
|
-
}
|
|
168
|
-
readInt4(offset) {
|
|
169
|
-
return this.readUint4(offset) << 28 >> 28;
|
|
170
|
-
}
|
|
171
|
-
readUint4(offset) {
|
|
172
|
-
const ptr = Pointer.from(offset);
|
|
173
|
-
return __privateMethod(this, _UnalignedUint16Array_instances, readBit_fn).call(this, ptr) | __privateMethod(this, _UnalignedUint16Array_instances, readBit_fn).call(this, ptr) << 1 | __privateMethod(this, _UnalignedUint16Array_instances, readBit_fn).call(this, ptr) << 2 | __privateMethod(this, _UnalignedUint16Array_instances, readBit_fn).call(this, ptr) << 3;
|
|
174
|
-
}
|
|
175
|
-
readInt8(offset) {
|
|
176
|
-
return this.readUint8(offset) << 24 >> 24;
|
|
177
|
-
}
|
|
178
|
-
readUint8(offset) {
|
|
179
|
-
const ptr = Pointer.from(offset);
|
|
180
|
-
return __privateMethod(this, _UnalignedUint16Array_instances, readByte_fn).call(this, ptr);
|
|
181
|
-
}
|
|
182
|
-
readInt16(offset) {
|
|
183
|
-
return this.readUint16(offset) << 16 >> 16;
|
|
184
|
-
}
|
|
185
|
-
readUint16(offset) {
|
|
186
|
-
__privateMethod(this, _UnalignedUint16Array_instances, bufferRead16_fn).call(this, Pointer.from(offset));
|
|
187
|
-
return ConverterUint16[0];
|
|
188
|
-
}
|
|
189
|
-
readInt32(offset) {
|
|
190
|
-
__privateMethod(this, _UnalignedUint16Array_instances, bufferRead32_fn).call(this, Pointer.from(offset));
|
|
191
|
-
return ConverterInt32[0];
|
|
192
|
-
}
|
|
193
|
-
readUint32(offset) {
|
|
194
|
-
__privateMethod(this, _UnalignedUint16Array_instances, bufferRead32_fn).call(this, Pointer.from(offset));
|
|
195
|
-
return ConverterUint32[0];
|
|
196
|
-
}
|
|
197
|
-
readInt64(offset) {
|
|
198
|
-
return Number(this.readBigInt64(offset));
|
|
199
|
-
}
|
|
200
|
-
readUint64(offset) {
|
|
201
|
-
return Number(this.readBigUint64(offset));
|
|
202
|
-
}
|
|
203
|
-
readBigInt32(offset) {
|
|
204
|
-
__privateMethod(this, _UnalignedUint16Array_instances, bufferRead32_fn).call(this, Pointer.from(offset));
|
|
205
|
-
return BigInt(ConverterInt32[0]);
|
|
206
|
-
}
|
|
207
|
-
readBigUint32(offset) {
|
|
208
|
-
__privateMethod(this, _UnalignedUint16Array_instances, bufferRead32_fn).call(this, Pointer.from(offset));
|
|
209
|
-
return BigInt(ConverterUint32[0]);
|
|
210
|
-
}
|
|
211
|
-
readBigInt64(offset) {
|
|
212
|
-
__privateMethod(this, _UnalignedUint16Array_instances, bufferRead64_fn).call(this, Pointer.from(offset));
|
|
213
|
-
return ConverterInt64[0];
|
|
214
|
-
}
|
|
215
|
-
readBigUint64(offset) {
|
|
216
|
-
__privateMethod(this, _UnalignedUint16Array_instances, bufferRead64_fn).call(this, Pointer.from(offset));
|
|
217
|
-
return ConverterUint64[0];
|
|
218
|
-
}
|
|
219
|
-
readFloat32(offset) {
|
|
220
|
-
__privateMethod(this, _UnalignedUint16Array_instances, bufferRead32_fn).call(this, Pointer.from(offset));
|
|
221
|
-
return ConverterFloat[0];
|
|
222
|
-
}
|
|
223
|
-
readFloat64(offset) {
|
|
224
|
-
__privateMethod(this, _UnalignedUint16Array_instances, bufferRead64_fn).call(this, Pointer.from(offset));
|
|
225
|
-
return ConverterDouble[0];
|
|
226
|
-
}
|
|
227
|
-
toString() {
|
|
228
|
-
let result = "";
|
|
229
|
-
for (let i = 0; i < this.length; i++) {
|
|
230
|
-
result += String.fromCharCode(__privateGet(this, _buffer)[i]);
|
|
231
|
-
}
|
|
232
|
-
return result;
|
|
233
|
-
}
|
|
234
|
-
toArray() {
|
|
235
|
-
return __privateGet(this, _buffer).slice(0, this.length);
|
|
236
|
-
}
|
|
237
|
-
static from(value) {
|
|
238
|
-
if (typeof value !== "string") return value;
|
|
239
|
-
const buffer = new _UnalignedUint16Array(value.length);
|
|
240
|
-
for (let i = 0; i < value.length; i++) {
|
|
241
|
-
__privateGet(buffer, _buffer)[i] = value.charCodeAt(i);
|
|
242
|
-
}
|
|
243
|
-
__privateSet(buffer, _bitLength, value.length << 4);
|
|
244
|
-
return buffer;
|
|
245
|
-
}
|
|
246
|
-
};
|
|
247
|
-
_buffer = new WeakMap();
|
|
248
|
-
_bitLength = new WeakMap();
|
|
249
|
-
_wordIndex = new WeakMap();
|
|
250
|
-
_wordLength = new WeakMap();
|
|
251
|
-
_UnalignedUint16Array_instances = new WeakSet();
|
|
252
|
-
readBit_fn = /* @__PURE__ */ __name(function(pointer) {
|
|
253
|
-
const bitOffset = pointer.value;
|
|
254
|
-
const index = bitOffset >> 4;
|
|
255
|
-
const bitIndex = bitOffset & 15;
|
|
256
|
-
pointer.add(1);
|
|
257
|
-
return __privateGet(this, _buffer)[index] >> bitIndex & 1;
|
|
258
|
-
}, "#readBit");
|
|
259
|
-
readByte_fn = /* @__PURE__ */ __name(function(ptr) {
|
|
260
|
-
return __privateMethod(this, _UnalignedUint16Array_instances, readBit_fn).call(this, ptr) | __privateMethod(this, _UnalignedUint16Array_instances, readBit_fn).call(this, ptr) << 1 | __privateMethod(this, _UnalignedUint16Array_instances, readBit_fn).call(this, ptr) << 2 | __privateMethod(this, _UnalignedUint16Array_instances, readBit_fn).call(this, ptr) << 3 | __privateMethod(this, _UnalignedUint16Array_instances, readBit_fn).call(this, ptr) << 4 | __privateMethod(this, _UnalignedUint16Array_instances, readBit_fn).call(this, ptr) << 5 | __privateMethod(this, _UnalignedUint16Array_instances, readBit_fn).call(this, ptr) << 6 | __privateMethod(this, _UnalignedUint16Array_instances, readBit_fn).call(this, ptr) << 7;
|
|
261
|
-
}, "#readByte");
|
|
262
|
-
bufferRead16_fn = /* @__PURE__ */ __name(function(ptr) {
|
|
263
|
-
ConverterUint8[0] = __privateMethod(this, _UnalignedUint16Array_instances, readByte_fn).call(this, ptr);
|
|
264
|
-
ConverterUint8[1] = __privateMethod(this, _UnalignedUint16Array_instances, readByte_fn).call(this, ptr);
|
|
265
|
-
}, "#bufferRead16");
|
|
266
|
-
bufferRead32_fn = /* @__PURE__ */ __name(function(ptr) {
|
|
267
|
-
ConverterUint8[0] = __privateMethod(this, _UnalignedUint16Array_instances, readByte_fn).call(this, ptr);
|
|
268
|
-
ConverterUint8[1] = __privateMethod(this, _UnalignedUint16Array_instances, readByte_fn).call(this, ptr);
|
|
269
|
-
ConverterUint8[2] = __privateMethod(this, _UnalignedUint16Array_instances, readByte_fn).call(this, ptr);
|
|
270
|
-
ConverterUint8[3] = __privateMethod(this, _UnalignedUint16Array_instances, readByte_fn).call(this, ptr);
|
|
271
|
-
}, "#bufferRead32");
|
|
272
|
-
bufferRead64_fn = /* @__PURE__ */ __name(function(ptr) {
|
|
273
|
-
ConverterUint8[0] = __privateMethod(this, _UnalignedUint16Array_instances, readByte_fn).call(this, ptr);
|
|
274
|
-
ConverterUint8[1] = __privateMethod(this, _UnalignedUint16Array_instances, readByte_fn).call(this, ptr);
|
|
275
|
-
ConverterUint8[2] = __privateMethod(this, _UnalignedUint16Array_instances, readByte_fn).call(this, ptr);
|
|
276
|
-
ConverterUint8[3] = __privateMethod(this, _UnalignedUint16Array_instances, readByte_fn).call(this, ptr);
|
|
277
|
-
ConverterUint8[4] = __privateMethod(this, _UnalignedUint16Array_instances, readByte_fn).call(this, ptr);
|
|
278
|
-
ConverterUint8[5] = __privateMethod(this, _UnalignedUint16Array_instances, readByte_fn).call(this, ptr);
|
|
279
|
-
ConverterUint8[6] = __privateMethod(this, _UnalignedUint16Array_instances, readByte_fn).call(this, ptr);
|
|
280
|
-
ConverterUint8[7] = __privateMethod(this, _UnalignedUint16Array_instances, readByte_fn).call(this, ptr);
|
|
281
|
-
}, "#bufferRead64");
|
|
282
|
-
writeBit_fn = /* @__PURE__ */ __name(function(value) {
|
|
283
|
-
if (__privateGet(this, _wordIndex) === this.maxLength) {
|
|
284
|
-
throw new RangeError(`The buffer is full`);
|
|
285
|
-
}
|
|
286
|
-
if (value) {
|
|
287
|
-
const index = __privateGet(this, _wordIndex);
|
|
288
|
-
const bitIndex = this.bitLength & 15;
|
|
289
|
-
__privateGet(this, _buffer)[index] |= 1 << bitIndex;
|
|
290
|
-
}
|
|
291
|
-
if ((__privateGet(this, _bitLength) & 15) === 0) __privateWrapper(this, _wordLength)._++;
|
|
292
|
-
__privateWrapper(this, _bitLength)._++;
|
|
293
|
-
if ((__privateGet(this, _bitLength) & 15) === 0) __privateWrapper(this, _wordIndex)._++;
|
|
294
|
-
}, "#writeBit");
|
|
295
|
-
bufferWrite16_fn = /* @__PURE__ */ __name(function(value) {
|
|
296
|
-
const wordIndex = __privateGet(this, _wordIndex);
|
|
297
|
-
const bitIndex = this.bitLength & 15;
|
|
298
|
-
if (wordIndex + (bitIndex === 0 ? 0 : 1) === this.maxLength) {
|
|
299
|
-
throw new RangeError(`The buffer is full`);
|
|
300
|
-
}
|
|
301
|
-
if (bitIndex === 0) {
|
|
302
|
-
__privateGet(this, _buffer)[wordIndex] = value;
|
|
303
|
-
} else {
|
|
304
|
-
value &= 65535;
|
|
305
|
-
__privateGet(this, _buffer)[wordIndex] |= value << bitIndex;
|
|
306
|
-
__privateGet(this, _buffer)[wordIndex + 1] = value >> 16 - bitIndex;
|
|
307
|
-
}
|
|
308
|
-
__privateSet(this, _bitLength, __privateGet(this, _bitLength) + 16);
|
|
309
|
-
__privateWrapper(this, _wordIndex)._++;
|
|
310
|
-
__privateWrapper(this, _wordLength)._++;
|
|
311
|
-
}, "#bufferWrite16");
|
|
312
|
-
__name(_UnalignedUint16Array, "UnalignedUint16Array");
|
|
313
|
-
var UnalignedUint16Array = _UnalignedUint16Array;
|
|
314
|
-
|
|
315
74
|
// src/lib/types/Array.ts
|
|
316
75
|
function ArrayType(type) {
|
|
317
76
|
return {
|
|
@@ -675,6 +434,247 @@ var t = {
|
|
|
675
434
|
uint8: Uint8Type
|
|
676
435
|
};
|
|
677
436
|
|
|
437
|
+
// src/lib/UnalignedUint16Array.ts
|
|
438
|
+
var ConverterUint8 = new Uint8Array(8);
|
|
439
|
+
var ConverterUint16 = new Uint16Array(ConverterUint8.buffer);
|
|
440
|
+
var ConverterUint32 = new Uint32Array(ConverterUint8.buffer);
|
|
441
|
+
var ConverterUint64 = new BigUint64Array(ConverterUint8.buffer);
|
|
442
|
+
var ConverterInt32 = new Int32Array(ConverterUint8.buffer);
|
|
443
|
+
var ConverterInt64 = new BigInt64Array(ConverterUint8.buffer);
|
|
444
|
+
var ConverterFloat = new Float32Array(ConverterUint8.buffer);
|
|
445
|
+
var ConverterDouble = new Float64Array(ConverterUint8.buffer);
|
|
446
|
+
var _buffer, _bitLength, _wordIndex, _wordLength, _UnalignedUint16Array_instances, readBit_fn, readByte_fn, bufferRead16_fn, bufferRead32_fn, bufferRead64_fn, writeBit_fn, bufferWrite16_fn;
|
|
447
|
+
var _UnalignedUint16Array = class _UnalignedUint16Array {
|
|
448
|
+
constructor(maxLength) {
|
|
449
|
+
__privateAdd(this, _UnalignedUint16Array_instances);
|
|
450
|
+
__privateAdd(this, _buffer);
|
|
451
|
+
__privateAdd(this, _bitLength, 0);
|
|
452
|
+
__privateAdd(this, _wordIndex, 0);
|
|
453
|
+
__privateAdd(this, _wordLength, 0);
|
|
454
|
+
__privateSet(this, _buffer, new Uint16Array(maxLength));
|
|
455
|
+
}
|
|
456
|
+
at(index) {
|
|
457
|
+
return __privateGet(this, _buffer).at(index);
|
|
458
|
+
}
|
|
459
|
+
get maxLength() {
|
|
460
|
+
return __privateGet(this, _buffer).length;
|
|
461
|
+
}
|
|
462
|
+
get maxBitLength() {
|
|
463
|
+
return __privateGet(this, _buffer).length * 16;
|
|
464
|
+
}
|
|
465
|
+
get length() {
|
|
466
|
+
return __privateGet(this, _wordLength);
|
|
467
|
+
}
|
|
468
|
+
get bitLength() {
|
|
469
|
+
return __privateGet(this, _bitLength);
|
|
470
|
+
}
|
|
471
|
+
writeBit(value) {
|
|
472
|
+
__privateMethod(this, _UnalignedUint16Array_instances, writeBit_fn).call(this, value);
|
|
473
|
+
}
|
|
474
|
+
writeInt2(value) {
|
|
475
|
+
this.writeBit(value & 1);
|
|
476
|
+
this.writeBit(value >> 1);
|
|
477
|
+
}
|
|
478
|
+
writeInt4(value) {
|
|
479
|
+
this.writeInt2(value & 3);
|
|
480
|
+
this.writeInt2(value >> 2);
|
|
481
|
+
}
|
|
482
|
+
writeInt8(value) {
|
|
483
|
+
this.writeInt4(value & 15);
|
|
484
|
+
this.writeInt4(value >> 4);
|
|
485
|
+
}
|
|
486
|
+
writeInt16(value) {
|
|
487
|
+
__privateMethod(this, _UnalignedUint16Array_instances, bufferWrite16_fn).call(this, value);
|
|
488
|
+
}
|
|
489
|
+
writeInt32(value) {
|
|
490
|
+
__privateMethod(this, _UnalignedUint16Array_instances, bufferWrite16_fn).call(this, value);
|
|
491
|
+
__privateMethod(this, _UnalignedUint16Array_instances, bufferWrite16_fn).call(this, value >> 16);
|
|
492
|
+
}
|
|
493
|
+
writeInt64(value) {
|
|
494
|
+
this.writeBigInt64(BigInt(value));
|
|
495
|
+
}
|
|
496
|
+
writeBigInt32(value) {
|
|
497
|
+
ConverterInt64[0] = value;
|
|
498
|
+
__privateMethod(this, _UnalignedUint16Array_instances, bufferWrite16_fn).call(this, ConverterUint16[0]);
|
|
499
|
+
__privateMethod(this, _UnalignedUint16Array_instances, bufferWrite16_fn).call(this, ConverterUint16[1]);
|
|
500
|
+
}
|
|
501
|
+
writeBigInt64(value) {
|
|
502
|
+
ConverterInt64[0] = value;
|
|
503
|
+
__privateMethod(this, _UnalignedUint16Array_instances, bufferWrite16_fn).call(this, ConverterUint16[0]);
|
|
504
|
+
__privateMethod(this, _UnalignedUint16Array_instances, bufferWrite16_fn).call(this, ConverterUint16[1]);
|
|
505
|
+
__privateMethod(this, _UnalignedUint16Array_instances, bufferWrite16_fn).call(this, ConverterUint16[2]);
|
|
506
|
+
__privateMethod(this, _UnalignedUint16Array_instances, bufferWrite16_fn).call(this, ConverterUint16[3]);
|
|
507
|
+
}
|
|
508
|
+
writeFloat32(value) {
|
|
509
|
+
ConverterFloat[0] = value;
|
|
510
|
+
__privateMethod(this, _UnalignedUint16Array_instances, bufferWrite16_fn).call(this, ConverterUint16[0]);
|
|
511
|
+
__privateMethod(this, _UnalignedUint16Array_instances, bufferWrite16_fn).call(this, ConverterUint16[1]);
|
|
512
|
+
}
|
|
513
|
+
writeFloat64(value) {
|
|
514
|
+
ConverterDouble[0] = value;
|
|
515
|
+
__privateMethod(this, _UnalignedUint16Array_instances, bufferWrite16_fn).call(this, ConverterUint16[0]);
|
|
516
|
+
__privateMethod(this, _UnalignedUint16Array_instances, bufferWrite16_fn).call(this, ConverterUint16[1]);
|
|
517
|
+
__privateMethod(this, _UnalignedUint16Array_instances, bufferWrite16_fn).call(this, ConverterUint16[2]);
|
|
518
|
+
__privateMethod(this, _UnalignedUint16Array_instances, bufferWrite16_fn).call(this, ConverterUint16[3]);
|
|
519
|
+
}
|
|
520
|
+
readBit(offset) {
|
|
521
|
+
const ptr = Pointer.from(offset);
|
|
522
|
+
return __privateMethod(this, _UnalignedUint16Array_instances, readBit_fn).call(this, ptr);
|
|
523
|
+
}
|
|
524
|
+
readInt2(offset) {
|
|
525
|
+
return this.readUint2(offset) << 30 >> 30;
|
|
526
|
+
}
|
|
527
|
+
readUint2(offset) {
|
|
528
|
+
const ptr = Pointer.from(offset);
|
|
529
|
+
return __privateMethod(this, _UnalignedUint16Array_instances, readBit_fn).call(this, ptr) | __privateMethod(this, _UnalignedUint16Array_instances, readBit_fn).call(this, ptr) << 1;
|
|
530
|
+
}
|
|
531
|
+
readInt4(offset) {
|
|
532
|
+
return this.readUint4(offset) << 28 >> 28;
|
|
533
|
+
}
|
|
534
|
+
readUint4(offset) {
|
|
535
|
+
const ptr = Pointer.from(offset);
|
|
536
|
+
return __privateMethod(this, _UnalignedUint16Array_instances, readBit_fn).call(this, ptr) | __privateMethod(this, _UnalignedUint16Array_instances, readBit_fn).call(this, ptr) << 1 | __privateMethod(this, _UnalignedUint16Array_instances, readBit_fn).call(this, ptr) << 2 | __privateMethod(this, _UnalignedUint16Array_instances, readBit_fn).call(this, ptr) << 3;
|
|
537
|
+
}
|
|
538
|
+
readInt8(offset) {
|
|
539
|
+
return this.readUint8(offset) << 24 >> 24;
|
|
540
|
+
}
|
|
541
|
+
readUint8(offset) {
|
|
542
|
+
const ptr = Pointer.from(offset);
|
|
543
|
+
return __privateMethod(this, _UnalignedUint16Array_instances, readByte_fn).call(this, ptr);
|
|
544
|
+
}
|
|
545
|
+
readInt16(offset) {
|
|
546
|
+
return this.readUint16(offset) << 16 >> 16;
|
|
547
|
+
}
|
|
548
|
+
readUint16(offset) {
|
|
549
|
+
__privateMethod(this, _UnalignedUint16Array_instances, bufferRead16_fn).call(this, Pointer.from(offset));
|
|
550
|
+
return ConverterUint16[0];
|
|
551
|
+
}
|
|
552
|
+
readInt32(offset) {
|
|
553
|
+
__privateMethod(this, _UnalignedUint16Array_instances, bufferRead32_fn).call(this, Pointer.from(offset));
|
|
554
|
+
return ConverterInt32[0];
|
|
555
|
+
}
|
|
556
|
+
readUint32(offset) {
|
|
557
|
+
__privateMethod(this, _UnalignedUint16Array_instances, bufferRead32_fn).call(this, Pointer.from(offset));
|
|
558
|
+
return ConverterUint32[0];
|
|
559
|
+
}
|
|
560
|
+
readInt64(offset) {
|
|
561
|
+
return Number(this.readBigInt64(offset));
|
|
562
|
+
}
|
|
563
|
+
readUint64(offset) {
|
|
564
|
+
return Number(this.readBigUint64(offset));
|
|
565
|
+
}
|
|
566
|
+
readBigInt32(offset) {
|
|
567
|
+
__privateMethod(this, _UnalignedUint16Array_instances, bufferRead32_fn).call(this, Pointer.from(offset));
|
|
568
|
+
return BigInt(ConverterInt32[0]);
|
|
569
|
+
}
|
|
570
|
+
readBigUint32(offset) {
|
|
571
|
+
__privateMethod(this, _UnalignedUint16Array_instances, bufferRead32_fn).call(this, Pointer.from(offset));
|
|
572
|
+
return BigInt(ConverterUint32[0]);
|
|
573
|
+
}
|
|
574
|
+
readBigInt64(offset) {
|
|
575
|
+
__privateMethod(this, _UnalignedUint16Array_instances, bufferRead64_fn).call(this, Pointer.from(offset));
|
|
576
|
+
return ConverterInt64[0];
|
|
577
|
+
}
|
|
578
|
+
readBigUint64(offset) {
|
|
579
|
+
__privateMethod(this, _UnalignedUint16Array_instances, bufferRead64_fn).call(this, Pointer.from(offset));
|
|
580
|
+
return ConverterUint64[0];
|
|
581
|
+
}
|
|
582
|
+
readFloat32(offset) {
|
|
583
|
+
__privateMethod(this, _UnalignedUint16Array_instances, bufferRead32_fn).call(this, Pointer.from(offset));
|
|
584
|
+
return ConverterFloat[0];
|
|
585
|
+
}
|
|
586
|
+
readFloat64(offset) {
|
|
587
|
+
__privateMethod(this, _UnalignedUint16Array_instances, bufferRead64_fn).call(this, Pointer.from(offset));
|
|
588
|
+
return ConverterDouble[0];
|
|
589
|
+
}
|
|
590
|
+
toString() {
|
|
591
|
+
let result = "";
|
|
592
|
+
for (let i = 0; i < this.length; i++) {
|
|
593
|
+
result += String.fromCharCode(__privateGet(this, _buffer)[i]);
|
|
594
|
+
}
|
|
595
|
+
return result;
|
|
596
|
+
}
|
|
597
|
+
toArray() {
|
|
598
|
+
return __privateGet(this, _buffer).slice(0, this.length);
|
|
599
|
+
}
|
|
600
|
+
static from(value) {
|
|
601
|
+
if (value instanceof _UnalignedUint16Array) return value;
|
|
602
|
+
const buffer = new _UnalignedUint16Array(value.length);
|
|
603
|
+
for (let i = 0; i < value.length; i++) {
|
|
604
|
+
__privateGet(buffer, _buffer)[i] = value.charCodeAt(i);
|
|
605
|
+
}
|
|
606
|
+
__privateSet(buffer, _bitLength, value.length << 4);
|
|
607
|
+
return buffer;
|
|
608
|
+
}
|
|
609
|
+
};
|
|
610
|
+
_buffer = new WeakMap();
|
|
611
|
+
_bitLength = new WeakMap();
|
|
612
|
+
_wordIndex = new WeakMap();
|
|
613
|
+
_wordLength = new WeakMap();
|
|
614
|
+
_UnalignedUint16Array_instances = new WeakSet();
|
|
615
|
+
readBit_fn = /* @__PURE__ */ __name(function(pointer) {
|
|
616
|
+
const bitOffset = pointer.value;
|
|
617
|
+
const index = bitOffset >> 4;
|
|
618
|
+
const bitIndex = bitOffset & 15;
|
|
619
|
+
pointer.add(1);
|
|
620
|
+
return __privateGet(this, _buffer)[index] >> bitIndex & 1;
|
|
621
|
+
}, "#readBit");
|
|
622
|
+
readByte_fn = /* @__PURE__ */ __name(function(ptr) {
|
|
623
|
+
return __privateMethod(this, _UnalignedUint16Array_instances, readBit_fn).call(this, ptr) | __privateMethod(this, _UnalignedUint16Array_instances, readBit_fn).call(this, ptr) << 1 | __privateMethod(this, _UnalignedUint16Array_instances, readBit_fn).call(this, ptr) << 2 | __privateMethod(this, _UnalignedUint16Array_instances, readBit_fn).call(this, ptr) << 3 | __privateMethod(this, _UnalignedUint16Array_instances, readBit_fn).call(this, ptr) << 4 | __privateMethod(this, _UnalignedUint16Array_instances, readBit_fn).call(this, ptr) << 5 | __privateMethod(this, _UnalignedUint16Array_instances, readBit_fn).call(this, ptr) << 6 | __privateMethod(this, _UnalignedUint16Array_instances, readBit_fn).call(this, ptr) << 7;
|
|
624
|
+
}, "#readByte");
|
|
625
|
+
bufferRead16_fn = /* @__PURE__ */ __name(function(ptr) {
|
|
626
|
+
ConverterUint8[0] = __privateMethod(this, _UnalignedUint16Array_instances, readByte_fn).call(this, ptr);
|
|
627
|
+
ConverterUint8[1] = __privateMethod(this, _UnalignedUint16Array_instances, readByte_fn).call(this, ptr);
|
|
628
|
+
}, "#bufferRead16");
|
|
629
|
+
bufferRead32_fn = /* @__PURE__ */ __name(function(ptr) {
|
|
630
|
+
ConverterUint8[0] = __privateMethod(this, _UnalignedUint16Array_instances, readByte_fn).call(this, ptr);
|
|
631
|
+
ConverterUint8[1] = __privateMethod(this, _UnalignedUint16Array_instances, readByte_fn).call(this, ptr);
|
|
632
|
+
ConverterUint8[2] = __privateMethod(this, _UnalignedUint16Array_instances, readByte_fn).call(this, ptr);
|
|
633
|
+
ConverterUint8[3] = __privateMethod(this, _UnalignedUint16Array_instances, readByte_fn).call(this, ptr);
|
|
634
|
+
}, "#bufferRead32");
|
|
635
|
+
bufferRead64_fn = /* @__PURE__ */ __name(function(ptr) {
|
|
636
|
+
ConverterUint8[0] = __privateMethod(this, _UnalignedUint16Array_instances, readByte_fn).call(this, ptr);
|
|
637
|
+
ConverterUint8[1] = __privateMethod(this, _UnalignedUint16Array_instances, readByte_fn).call(this, ptr);
|
|
638
|
+
ConverterUint8[2] = __privateMethod(this, _UnalignedUint16Array_instances, readByte_fn).call(this, ptr);
|
|
639
|
+
ConverterUint8[3] = __privateMethod(this, _UnalignedUint16Array_instances, readByte_fn).call(this, ptr);
|
|
640
|
+
ConverterUint8[4] = __privateMethod(this, _UnalignedUint16Array_instances, readByte_fn).call(this, ptr);
|
|
641
|
+
ConverterUint8[5] = __privateMethod(this, _UnalignedUint16Array_instances, readByte_fn).call(this, ptr);
|
|
642
|
+
ConverterUint8[6] = __privateMethod(this, _UnalignedUint16Array_instances, readByte_fn).call(this, ptr);
|
|
643
|
+
ConverterUint8[7] = __privateMethod(this, _UnalignedUint16Array_instances, readByte_fn).call(this, ptr);
|
|
644
|
+
}, "#bufferRead64");
|
|
645
|
+
writeBit_fn = /* @__PURE__ */ __name(function(value) {
|
|
646
|
+
if (__privateGet(this, _wordIndex) === this.maxLength) {
|
|
647
|
+
throw new RangeError(`The buffer is full`);
|
|
648
|
+
}
|
|
649
|
+
if (value) {
|
|
650
|
+
const index = __privateGet(this, _wordIndex);
|
|
651
|
+
const bitIndex = this.bitLength & 15;
|
|
652
|
+
__privateGet(this, _buffer)[index] |= 1 << bitIndex;
|
|
653
|
+
}
|
|
654
|
+
if ((__privateGet(this, _bitLength) & 15) === 0) __privateWrapper(this, _wordLength)._++;
|
|
655
|
+
__privateWrapper(this, _bitLength)._++;
|
|
656
|
+
if ((__privateGet(this, _bitLength) & 15) === 0) __privateWrapper(this, _wordIndex)._++;
|
|
657
|
+
}, "#writeBit");
|
|
658
|
+
bufferWrite16_fn = /* @__PURE__ */ __name(function(value) {
|
|
659
|
+
const wordIndex = __privateGet(this, _wordIndex);
|
|
660
|
+
const bitIndex = this.bitLength & 15;
|
|
661
|
+
if (wordIndex + (bitIndex === 0 ? 0 : 1) === this.maxLength) {
|
|
662
|
+
throw new RangeError(`The buffer is full`);
|
|
663
|
+
}
|
|
664
|
+
if (bitIndex === 0) {
|
|
665
|
+
__privateGet(this, _buffer)[wordIndex] = value;
|
|
666
|
+
} else {
|
|
667
|
+
value &= 65535;
|
|
668
|
+
__privateGet(this, _buffer)[wordIndex] |= value << bitIndex;
|
|
669
|
+
__privateGet(this, _buffer)[wordIndex + 1] = value >> 16 - bitIndex;
|
|
670
|
+
}
|
|
671
|
+
__privateSet(this, _bitLength, __privateGet(this, _bitLength) + 16);
|
|
672
|
+
__privateWrapper(this, _wordIndex)._++;
|
|
673
|
+
__privateWrapper(this, _wordLength)._++;
|
|
674
|
+
}, "#bufferWrite16");
|
|
675
|
+
__name(_UnalignedUint16Array, "UnalignedUint16Array");
|
|
676
|
+
var UnalignedUint16Array = _UnalignedUint16Array;
|
|
677
|
+
|
|
678
678
|
// src/lib/schema/Schema.ts
|
|
679
679
|
var _id, _types, _bitSize, _Schema_instances, addType_fn;
|
|
680
680
|
var _Schema = class _Schema {
|