@sapphire/string-store 1.1.0-next.7c2bed20 → 1.1.0-next.98befbf8
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/README.md +131 -39
- package/dist/cjs/index.cjs +416 -64
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/index.d.cts +244 -37
- package/dist/esm/index.d.mts +244 -37
- package/dist/esm/index.mjs +406 -65
- package/dist/esm/index.mjs.map +1 -1
- package/dist/iife/index.global.js +416 -64
- package/dist/iife/index.global.js.map +1 -1
- package/package.json +7 -7
package/dist/esm/index.d.mts
CHANGED
|
@@ -43,13 +43,21 @@ declare class UnalignedUint16Array {
|
|
|
43
43
|
writeFloat64(value: number): void;
|
|
44
44
|
readBit(offset: PointerLike): 0 | 1;
|
|
45
45
|
readInt2(offset: PointerLike): number;
|
|
46
|
+
readUint2(offset: PointerLike): number;
|
|
46
47
|
readInt4(offset: PointerLike): number;
|
|
48
|
+
readUint4(offset: PointerLike): number;
|
|
47
49
|
readInt8(offset: PointerLike): number;
|
|
50
|
+
readUint8(offset: PointerLike): number;
|
|
48
51
|
readInt16(offset: PointerLike): number;
|
|
52
|
+
readUint16(offset: PointerLike): number;
|
|
49
53
|
readInt32(offset: PointerLike): number;
|
|
54
|
+
readUint32(offset: PointerLike): number;
|
|
50
55
|
readInt64(offset: PointerLike): number;
|
|
56
|
+
readUint64(offset: PointerLike): number;
|
|
51
57
|
readBigInt32(offset: PointerLike): bigint;
|
|
58
|
+
readBigUint32(offset: PointerLike): bigint;
|
|
52
59
|
readBigInt64(offset: PointerLike): bigint;
|
|
60
|
+
readBigUint64(offset: PointerLike): bigint;
|
|
53
61
|
readFloat32(offset: PointerLike): number;
|
|
54
62
|
readFloat64(offset: PointerLike): number;
|
|
55
63
|
toString(): string;
|
|
@@ -78,6 +86,89 @@ interface IType<ValueType, BitSize extends number | null> {
|
|
|
78
86
|
readonly BIT_SIZE: BitSize;
|
|
79
87
|
}
|
|
80
88
|
|
|
89
|
+
declare function ArrayType<ValueType, ValueBitSize extends number | null>(type: IType<ValueType, ValueBitSize>): IType<ValueType[], null>;
|
|
90
|
+
|
|
91
|
+
declare const BigInt32Type: IType<bigint, 32>;
|
|
92
|
+
|
|
93
|
+
declare const BigInt64Type: IType<bigint, 64>;
|
|
94
|
+
|
|
95
|
+
declare const BigUint32Type: IType<bigint, 32>;
|
|
96
|
+
|
|
97
|
+
declare const BigUint64Type: IType<bigint, 64>;
|
|
98
|
+
|
|
99
|
+
declare const BitType: IType<number, 1>;
|
|
100
|
+
|
|
101
|
+
declare const BooleanType: IType<boolean, 1>;
|
|
102
|
+
|
|
103
|
+
declare function FixedLengthArrayType<ValueType, ValueBitSize extends number | null>(type: IType<ValueType, ValueBitSize>, length: number): IType<ValueType[], ValueBitSize extends null ? null : number>;
|
|
104
|
+
|
|
105
|
+
declare const Float32Type: IType<number, 32>;
|
|
106
|
+
|
|
107
|
+
declare const Float64Type: IType<number, 64>;
|
|
108
|
+
|
|
109
|
+
declare const Int16Type: IType<number, 16>;
|
|
110
|
+
|
|
111
|
+
declare const Int2Type: IType<number, 2>;
|
|
112
|
+
|
|
113
|
+
declare const Int32Type: IType<number, 32>;
|
|
114
|
+
|
|
115
|
+
declare const Int4Type: IType<number, 4>;
|
|
116
|
+
|
|
117
|
+
declare const Int64Type: IType<number, 64>;
|
|
118
|
+
|
|
119
|
+
declare const Int8Type: IType<number, 8>;
|
|
120
|
+
|
|
121
|
+
declare const SnowflakeType: {
|
|
122
|
+
readonly serialize: (buffer: UnalignedUint16Array, value: bigint | string) => void;
|
|
123
|
+
readonly deserialize: (buffer: UnalignedUint16Array, offset: Pointer) => bigint;
|
|
124
|
+
readonly BIT_SIZE: 64;
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
declare const StringType: IType<string, null>;
|
|
128
|
+
|
|
129
|
+
declare const Uint16Type: IType<number, 16>;
|
|
130
|
+
|
|
131
|
+
declare const Uint2Type: IType<number, 2>;
|
|
132
|
+
|
|
133
|
+
declare const Uint32Type: IType<number, 32>;
|
|
134
|
+
|
|
135
|
+
declare const Uint4Type: IType<number, 4>;
|
|
136
|
+
|
|
137
|
+
declare const Uint64Type: IType<number, 64>;
|
|
138
|
+
|
|
139
|
+
declare const Uint8Type: IType<number, 8>;
|
|
140
|
+
|
|
141
|
+
declare const t: {
|
|
142
|
+
array: typeof ArrayType;
|
|
143
|
+
bigInt32: IType<bigint, 32>;
|
|
144
|
+
bigInt64: IType<bigint, 64>;
|
|
145
|
+
bigUint32: IType<bigint, 32>;
|
|
146
|
+
bigUint64: IType<bigint, 64>;
|
|
147
|
+
bit: IType<number, 1>;
|
|
148
|
+
boolean: IType<boolean, 1>;
|
|
149
|
+
fixedLengthArray: typeof FixedLengthArrayType;
|
|
150
|
+
float32: IType<number, 32>;
|
|
151
|
+
float64: IType<number, 64>;
|
|
152
|
+
int16: IType<number, 16>;
|
|
153
|
+
int2: IType<number, 2>;
|
|
154
|
+
int32: IType<number, 32>;
|
|
155
|
+
int4: IType<number, 4>;
|
|
156
|
+
int64: IType<number, 64>;
|
|
157
|
+
int8: IType<number, 8>;
|
|
158
|
+
snowflake: {
|
|
159
|
+
readonly serialize: (buffer: UnalignedUint16Array, value: string | bigint) => void;
|
|
160
|
+
readonly deserialize: (buffer: UnalignedUint16Array, offset: Pointer) => bigint;
|
|
161
|
+
readonly BIT_SIZE: 64;
|
|
162
|
+
};
|
|
163
|
+
string: IType<string, null>;
|
|
164
|
+
uint16: IType<number, 16>;
|
|
165
|
+
uint2: IType<number, 2>;
|
|
166
|
+
uint32: IType<number, 32>;
|
|
167
|
+
uint4: IType<number, 4>;
|
|
168
|
+
uint64: IType<number, 64>;
|
|
169
|
+
uint8: IType<number, 8>;
|
|
170
|
+
};
|
|
171
|
+
|
|
81
172
|
declare class Schema<Id extends number = number, Entries extends object = object> {
|
|
82
173
|
#private;
|
|
83
174
|
/**
|
|
@@ -180,62 +271,190 @@ declare class Schema<Id extends number = number, Entries extends object = object
|
|
|
180
271
|
/**
|
|
181
272
|
* Adds a 2-bit integer property to the schema.
|
|
182
273
|
*
|
|
274
|
+
* @remarks
|
|
275
|
+
*
|
|
276
|
+
* The range of values is from -2 to 1, inclusive.
|
|
277
|
+
*
|
|
183
278
|
* @param name The name of the property
|
|
184
279
|
* @returns The modified schema
|
|
185
280
|
*/
|
|
186
281
|
int2<const Name extends string>(name: Name): Merge$1<Id, Entries, Name, IType<number, 2>>;
|
|
282
|
+
/**
|
|
283
|
+
* Adds a 2-bit unsigned integer property to the schema.
|
|
284
|
+
*
|
|
285
|
+
* @remarks
|
|
286
|
+
*
|
|
287
|
+
* The range of values is from 0 to 3, inclusive.
|
|
288
|
+
*
|
|
289
|
+
* @param name The name of the property
|
|
290
|
+
* @returns The modified schema
|
|
291
|
+
*/
|
|
292
|
+
uint2<const Name extends string>(name: Name): Merge$1<Id, Entries, Name, IType<number, 2>>;
|
|
187
293
|
/**
|
|
188
294
|
* Adds a 4-bit integer property to the schema.
|
|
189
295
|
*
|
|
296
|
+
* @remarks
|
|
297
|
+
*
|
|
298
|
+
* The range of values is from -8 to 7, inclusive.
|
|
299
|
+
*
|
|
190
300
|
* @param name The name of the property
|
|
191
301
|
* @returns The modified schema
|
|
192
302
|
*/
|
|
193
303
|
int4<const Name extends string>(name: Name): Merge$1<Id, Entries, Name, IType<number, 4>>;
|
|
304
|
+
/**
|
|
305
|
+
* Adds a 4-bit unsigned integer property to the schema.
|
|
306
|
+
*
|
|
307
|
+
* @remarks
|
|
308
|
+
*
|
|
309
|
+
* The range of values is from 0 to 15, inclusive.
|
|
310
|
+
*
|
|
311
|
+
* @param name The name of the property
|
|
312
|
+
* @returns The modified schema
|
|
313
|
+
*/
|
|
314
|
+
uint4<const Name extends string>(name: Name): Merge$1<Id, Entries, Name, IType<number, 4>>;
|
|
194
315
|
/**
|
|
195
316
|
* Adds a 8-bit integer property to the schema.
|
|
196
317
|
*
|
|
318
|
+
* @remarks
|
|
319
|
+
*
|
|
320
|
+
* The range of values is from -128 to 127, inclusive.
|
|
321
|
+
*
|
|
197
322
|
* @param name The name of the property
|
|
198
323
|
* @returns The modified schema
|
|
199
324
|
*/
|
|
200
325
|
int8<const Name extends string>(name: Name): Merge$1<Id, Entries, Name, IType<number, 8>>;
|
|
326
|
+
/**
|
|
327
|
+
* Adds a 8-bit unsigned integer property to the schema.
|
|
328
|
+
*
|
|
329
|
+
* @remarks
|
|
330
|
+
*
|
|
331
|
+
* The range of values is from 0 to 255, inclusive.
|
|
332
|
+
*
|
|
333
|
+
* @param name The name of the property
|
|
334
|
+
* @returns The modified schema
|
|
335
|
+
*/
|
|
336
|
+
uint8<const Name extends string>(name: Name): Merge$1<Id, Entries, Name, IType<number, 8>>;
|
|
201
337
|
/**
|
|
202
338
|
* Adds a 16-bit integer property to the schema.
|
|
203
339
|
*
|
|
340
|
+
* @remarks
|
|
341
|
+
*
|
|
342
|
+
* The range of values is from -32768 to 32767, inclusive.
|
|
343
|
+
*
|
|
204
344
|
* @param name The name of the property
|
|
205
345
|
* @returns The modified schema
|
|
206
346
|
*/
|
|
207
347
|
int16<const Name extends string>(name: Name): Merge$1<Id, Entries, Name, IType<number, 16>>;
|
|
348
|
+
/**
|
|
349
|
+
* Adds a 16-bit unsigned integer property to the schema.
|
|
350
|
+
*
|
|
351
|
+
* @remarks
|
|
352
|
+
*
|
|
353
|
+
* The range of values is from 0 to 65535, inclusive.
|
|
354
|
+
*
|
|
355
|
+
* @param name The name of the property
|
|
356
|
+
* @returns The modified schema
|
|
357
|
+
*/
|
|
358
|
+
uint16<const Name extends string>(name: Name): Merge$1<Id, Entries, Name, IType<number, 16>>;
|
|
208
359
|
/**
|
|
209
360
|
* Adds a 32-bit integer property to the schema.
|
|
210
361
|
*
|
|
362
|
+
* @remarks
|
|
363
|
+
*
|
|
364
|
+
* The range of values is from -2_147_483_648 to 2_147_483_647, inclusive.
|
|
365
|
+
*
|
|
211
366
|
* @param name The name of the property
|
|
212
367
|
* @returns The modified schema
|
|
213
368
|
*/
|
|
214
369
|
int32<const Name extends string>(name: Name): Merge$1<Id, Entries, Name, IType<number, 32>>;
|
|
370
|
+
/**
|
|
371
|
+
* Adds a 32-bit unsigned integer property to the schema.
|
|
372
|
+
*
|
|
373
|
+
* @remarks
|
|
374
|
+
*
|
|
375
|
+
* The range of values is from 0 to 4_294_967_295, inclusive.
|
|
376
|
+
*
|
|
377
|
+
* @param name The name of the property
|
|
378
|
+
* @returns The modified schema
|
|
379
|
+
*/
|
|
380
|
+
uint32<const Name extends string>(name: Name): Merge$1<Id, Entries, Name, IType<number, 32>>;
|
|
215
381
|
/**
|
|
216
382
|
* Adds a 64-bit integer property to the schema.
|
|
217
383
|
*
|
|
384
|
+
* @remarks
|
|
385
|
+
*
|
|
386
|
+
* The range of values is from -9_223_372_036_854_775_808 to 9_223_372_036_854_775_807, inclusive.
|
|
387
|
+
*
|
|
388
|
+
* However, it may run into precision issues past the range of `-9_007_199_254_740_991` to `9_007_199_254_740_991`
|
|
389
|
+
*
|
|
218
390
|
* @param name The name of the property
|
|
219
391
|
* @returns The modified schema
|
|
220
392
|
*/
|
|
221
393
|
int64<const Name extends string>(name: Name): Merge$1<Id, Entries, Name, IType<number, 64>>;
|
|
394
|
+
/**
|
|
395
|
+
* Adds a 64-bit unsigned integer property to the schema.
|
|
396
|
+
*
|
|
397
|
+
* @remarks
|
|
398
|
+
*
|
|
399
|
+
* The range of values is from 0 to 18_446_744_073_709_551_615, inclusive.
|
|
400
|
+
*
|
|
401
|
+
* However, it may run into precision issues past `9_007_199_254_740_991`
|
|
402
|
+
*
|
|
403
|
+
* @param name The name of the property
|
|
404
|
+
* @returns The modified schema
|
|
405
|
+
*/
|
|
406
|
+
uint64<const Name extends string>(name: Name): Merge$1<Id, Entries, Name, IType<number, 64>>;
|
|
222
407
|
/**
|
|
223
408
|
* Adds a 32-bit big integer property to the schema.
|
|
224
409
|
*
|
|
410
|
+
* @remarks
|
|
411
|
+
*
|
|
412
|
+
* The range of values is from -2_147_483_648n to 2_147_483_647n, inclusive.
|
|
413
|
+
*
|
|
225
414
|
* @param name The name of the property
|
|
226
415
|
* @returns The modified schema
|
|
227
416
|
*/
|
|
228
417
|
bigInt32<const Name extends string>(name: Name): Merge$1<Id, Entries, Name, IType<bigint, 32>>;
|
|
418
|
+
/**
|
|
419
|
+
* Adds a 32-bit big integer property to the schema.
|
|
420
|
+
*
|
|
421
|
+
* @remarks
|
|
422
|
+
*
|
|
423
|
+
* The range of values is from 0n to 4_294_967_295n, inclusive.
|
|
424
|
+
*
|
|
425
|
+
* @param name The name of the property
|
|
426
|
+
* @returns The modified schema
|
|
427
|
+
*/
|
|
428
|
+
bigUint32<const Name extends string>(name: Name): Merge$1<Id, Entries, Name, IType<bigint, 32>>;
|
|
229
429
|
/**
|
|
230
430
|
* Adds a 64-bit big integer property to the schema.
|
|
231
431
|
*
|
|
432
|
+
* @remarks
|
|
433
|
+
*
|
|
434
|
+
* The range of values is from -9_223_372_036_854_775_808n to 9_223_372_036_854_775_807n, inclusive.
|
|
435
|
+
*
|
|
232
436
|
* @param name The name of the property
|
|
233
437
|
* @returns The modified schema
|
|
234
438
|
*/
|
|
235
439
|
bigInt64<const Name extends string>(name: Name): Merge$1<Id, Entries, Name, IType<bigint, 64>>;
|
|
440
|
+
/**
|
|
441
|
+
* Adds a 64-bit big integer property to the schema.
|
|
442
|
+
*
|
|
443
|
+
* @remarks
|
|
444
|
+
*
|
|
445
|
+
* The range of values is from 0n to 18_446_744_073_709_551_615n, inclusive.
|
|
446
|
+
*
|
|
447
|
+
* @param name The name of the property
|
|
448
|
+
* @returns The modified schema
|
|
449
|
+
*/
|
|
450
|
+
bigUint64<const Name extends string>(name: Name): Merge$1<Id, Entries, Name, IType<bigint, 64>>;
|
|
236
451
|
/**
|
|
237
452
|
* Adds a 32-bit floating point number property to the schema.
|
|
238
453
|
*
|
|
454
|
+
* @remarks
|
|
455
|
+
*
|
|
456
|
+
* The range of values is from -3.4028234663852886e+38 to 3.4028234663852886e+38, inclusive.
|
|
457
|
+
*
|
|
239
458
|
* @param name The name of the property
|
|
240
459
|
* @returns The modified schema
|
|
241
460
|
*/
|
|
@@ -243,12 +462,20 @@ declare class Schema<Id extends number = number, Entries extends object = object
|
|
|
243
462
|
/**
|
|
244
463
|
* Adds a 64-bit floating point number property to the schema.
|
|
245
464
|
*
|
|
465
|
+
* @remarks
|
|
466
|
+
*
|
|
467
|
+
* The range of values is from -1.7976931348623157e+308 to 1.7976931348623157e+308, inclusive.
|
|
468
|
+
*
|
|
246
469
|
* @param name The name of the property
|
|
247
470
|
* @returns The modified schema
|
|
248
471
|
*/
|
|
249
472
|
float64<const Name extends string>(name: Name): Merge$1<Id, Entries, Name, IType<number, 64>>;
|
|
250
473
|
/**
|
|
251
|
-
* Adds a 64-bit big integer property to the schema, similar to {@link Schema.
|
|
474
|
+
* Adds a 64-bit big integer property to the schema, similar to {@link Schema.bigUint64}.
|
|
475
|
+
*
|
|
476
|
+
* @remarks
|
|
477
|
+
*
|
|
478
|
+
* The range of values is from 0n to 18_446_744_073_709_551_615n, inclusive.
|
|
252
479
|
*
|
|
253
480
|
* @param name The name of the property
|
|
254
481
|
* @returns The modified schema
|
|
@@ -384,40 +611,20 @@ type DeserializationResult<SchemaStoreEntries extends object> = {
|
|
|
384
611
|
};
|
|
385
612
|
}[keyof SchemaStoreEntries];
|
|
386
613
|
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
declare
|
|
402
|
-
|
|
403
|
-
declare const Int16Type: IType<number, 16>;
|
|
404
|
-
|
|
405
|
-
declare const Int2Type: IType<number, 2>;
|
|
406
|
-
|
|
407
|
-
declare const Int32Type: IType<number, 32>;
|
|
408
|
-
|
|
409
|
-
declare const Int4Type: IType<number, 4>;
|
|
410
|
-
|
|
411
|
-
declare const Int64Type: IType<number, 64>;
|
|
412
|
-
|
|
413
|
-
declare const Int8Type: IType<number, 8>;
|
|
414
|
-
|
|
415
|
-
declare const SnowflakeType: {
|
|
416
|
-
readonly serialize: (buffer: UnalignedUint16Array, value: bigint | string) => void;
|
|
417
|
-
readonly deserialize: (buffer: UnalignedUint16Array, offset: Pointer) => bigint;
|
|
418
|
-
readonly BIT_SIZE: 64;
|
|
419
|
-
};
|
|
420
|
-
|
|
421
|
-
declare const StringType: IType<string, null>;
|
|
614
|
+
type TypedArray = Int8Array | Uint8Array | Uint8ClampedArray | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array | Float64Array | BigInt64Array | BigUint64Array;
|
|
615
|
+
/**
|
|
616
|
+
* Converts a {@link TypedArray} to a string.
|
|
617
|
+
*
|
|
618
|
+
* @param buffer The buffer to convert
|
|
619
|
+
* @returns The generated UTF16 string
|
|
620
|
+
*/
|
|
621
|
+
declare function toUTF16(buffer: TypedArray): string;
|
|
622
|
+
/**
|
|
623
|
+
* Converts a string to a {@link Uint16Array}.
|
|
624
|
+
*
|
|
625
|
+
* @param buffer The string to convert
|
|
626
|
+
* @returns The generated {@link Uint16Array}
|
|
627
|
+
*/
|
|
628
|
+
declare function fromUTF16(buffer: string): Uint16Array;
|
|
422
629
|
|
|
423
|
-
export { ArrayType, BigInt32Type, BigInt64Type, BitType, BooleanType, type DeserializationResult, type EntryOfSchema, type EntryOfStore, FixedLengthArrayType, Float32Type, Float64Type, type IType, Int16Type, Int2Type, Int32Type, Int4Type, Int64Type, Int8Type, type KeyOfSchema, type KeyOfStore, Pointer, type PointerLike, Schema, SchemaStore, SnowflakeType, StringType, UnalignedUint16Array, type UnwrapSchema, type UnwrapSchemaEntries, type UnwrapSchemaType, type ValueOfSchema, type ValueOfStore };
|
|
630
|
+
export { ArrayType, BigInt32Type, BigInt64Type, BigUint32Type, BigUint64Type, BitType, BooleanType, type DeserializationResult, type EntryOfSchema, type EntryOfStore, FixedLengthArrayType, Float32Type, Float64Type, type IType, Int16Type, Int2Type, Int32Type, Int4Type, Int64Type, Int8Type, type KeyOfSchema, type KeyOfStore, Pointer, type PointerLike, Schema, SchemaStore, SnowflakeType, StringType, type TypedArray, Uint16Type, Uint2Type, Uint32Type, Uint4Type, Uint64Type, Uint8Type, UnalignedUint16Array, type UnwrapSchema, type UnwrapSchemaEntries, type UnwrapSchemaType, type ValueOfSchema, type ValueOfStore, fromUTF16, t, toUTF16 };
|