@sapphire/string-store 2.0.0-next.548200f1 → 2.0.0-next.598c24a3

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.
@@ -23,47 +23,7 @@ type PointerLike = Pointer | {
23
23
  [Symbol.toPrimitive](hint: 'number'): number;
24
24
  };
25
25
 
26
- interface DuplexBuffer {
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 | DuplexBuffer): DuplexBuffer;
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: DuplexBuffer, value: InputValue): void;
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: DuplexBuffer, pointer: Pointer): ValueType;
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
  */
@@ -249,24 +209,6 @@ declare class Schema<Id extends number = number, Entries extends object = object
249
209
  * If the property does not exist, an error will be thrown.
250
210
  */
251
211
  get<const Name extends keyof Entries & string>(name: Name): Entries[Name];
252
- /**
253
- * Create a buffer and serialize a value into it, then convert it to a string
254
- *
255
- * @param value The value to serialize into the buffer
256
- * @param defaultMaximumArrayLength The default maximum array length, if any
257
- * @returns The newly created string.
258
- *
259
- * @seealso This method calls {@link Schema.serializeRaw} before calling `toString()` to its result.
260
- */
261
- serialize(value: Readonly<SerializeValueEntries<Entries>>, defaultMaximumArrayLength?: number): string;
262
- /**
263
- * Create a buffer and serialize a value into it.
264
- *
265
- * @param value The value to serialize into the buffer
266
- * @param defaultMaximumArrayLength The default maximum array length, if any
267
- * @returns The newly created buffer.
268
- */
269
- serializeRaw(value: Readonly<SerializeValueEntries<Entries>>, defaultMaximumArrayLength?: number): DuplexBuffer;
270
212
  /**
271
213
  * Serialize a value into a buffer.
272
214
  *
@@ -278,7 +220,7 @@ declare class Schema<Id extends number = number, Entries extends object = object
278
220
  * The schema's ID is written to the buffer first, followed by each property
279
221
  * in the schema.
280
222
  */
281
- serializeInto(buffer: DuplexBuffer, value: Readonly<SerializeValueEntries<Entries>>): void;
223
+ serialize(buffer: UnalignedUint16Array, value: Readonly<SerializeValueEntries<Entries>>): void;
282
224
  /**
283
225
  * Deserialize a value from a buffer.
284
226
  *
@@ -288,10 +230,10 @@ declare class Schema<Id extends number = number, Entries extends object = object
288
230
  *
289
231
  * @remarks
290
232
  *
291
- * Unlike {@link Schema.serializeInto}, this method does not read the schema's ID
233
+ * Unlike {@link Schema.serialize}, this method does not read the schema's ID
292
234
  * from the buffer, that is reserved for the {@link SchemaStore}.
293
235
  */
294
- deserialize(buffer: DuplexBuffer | string, pointer: PointerLike): UnwrapSchemaEntries<Entries>;
236
+ deserialize(buffer: UnalignedUint16Array, pointer: PointerLike): UnwrapSchemaEntries<Entries>;
295
237
  /**
296
238
  * Adds an array property to the schema.
297
239
  *
@@ -662,14 +604,14 @@ declare class SchemaStore<Entries extends object = object> {
662
604
  * @param value The value to serialize
663
605
  * @returns The serialized buffer
664
606
  */
665
- serializeRaw<const Id extends KeyOfStore<this>>(id: Id, value: SerializeValue<Entries[Id] & object>): DuplexBuffer;
607
+ serializeRaw<const Id extends KeyOfStore<this>>(id: Id, value: SerializeValue<Entries[Id] & object>): UnalignedUint16Array;
666
608
  /**
667
609
  * Deserializes a buffer
668
610
  *
669
611
  * @param buffer The buffer to deserialize
670
612
  * @returns The resolved value, including the id of the schema used for deserialization
671
613
  */
672
- deserialize(buffer: string | DuplexBuffer): DeserializationResult<Entries>;
614
+ deserialize(buffer: string | UnalignedUint16Array): DeserializationResult<Entries>;
673
615
  /**
674
616
  * Gets the serialized ID from a buffer
675
617
  *
@@ -680,7 +622,7 @@ declare class SchemaStore<Entries extends object = object> {
680
622
  *
681
623
  * If an empty value is passed, a {@linkcode RangeError} will be thrown.
682
624
  */
683
- getIdentifier(buffer: string | DuplexBuffer): KeyOfStore<this>;
625
+ getIdentifier(buffer: string | UnalignedUint16Array): KeyOfStore<this>;
684
626
  /**
685
627
  * Iterates over the stores's schema identifiers.
686
628
  *
@@ -737,4 +679,4 @@ declare function toUTF16(buffer: TypedArray): string;
737
679
  */
738
680
  declare function fromUTF16(buffer: string): Uint16Array;
739
681
 
740
- export { ArrayType, BigInt32Type, BigInt64Type, BigUint32Type, BigUint64Type, BitType, BooleanType, ConstantType, type DeserializationResult, type DuplexBuffer, 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 };
682
+ 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 };