@solana/codecs-core 2.0.0-experimental.fc4e943 → 2.0.0-experimental.fcff844

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.
@@ -2,55 +2,121 @@
2
2
  * Defines an offset in bytes.
3
3
  */
4
4
  export type Offset = number;
5
- /**
6
- * The shared attributes between codecs, encoders and decoders.
7
- */
8
- export type CodecData = {
9
- /** A description for the codec. */
10
- description: string;
11
- /** The fixed size of the encoded value in bytes, or `null` if it is variable. */
12
- fixedSize: number | null;
13
- /** The maximum size an encoded value can be in bytes, or `null` if it is variable. */
14
- maxSize: number | null;
5
+ type BaseEncoder<TFrom> = {
6
+ /** Encode the provided value and return the encoded bytes directly. */
7
+ readonly encode: (value: TFrom) => Uint8Array;
8
+ /**
9
+ * Writes the encoded value into the provided byte array at the given offset.
10
+ * Returns the offset of the next byte after the encoded value.
11
+ */
12
+ readonly write: (value: TFrom, bytes: Uint8Array, offset: Offset) => Offset;
13
+ };
14
+ export type FixedSizeEncoder<TFrom, TSize extends number = number> = BaseEncoder<TFrom> & {
15
+ /** The fixed size of the encoded value in bytes. */
16
+ readonly fixedSize: TSize;
17
+ };
18
+ export type VariableSizeEncoder<TFrom> = BaseEncoder<TFrom> & {
19
+ /** The total size of the encoded value in bytes. */
20
+ readonly getSizeFromValue: (value: TFrom) => number;
21
+ /** The maximum size an encoded value can be in bytes, if applicable. */
22
+ readonly maxSize?: number;
15
23
  };
16
24
  /**
17
25
  * An object that can encode a value to a `Uint8Array`.
18
26
  */
19
- export type Encoder<T> = CodecData & {
20
- /** The function that encodes a value into bytes. */
21
- encode: (value: T) => Uint8Array;
27
+ export type Encoder<TFrom> = FixedSizeEncoder<TFrom> | VariableSizeEncoder<TFrom>;
28
+ type BaseDecoder<TTo> = {
29
+ /** Decodes the provided byte array at the given offset (or zero) and returns the value directly. */
30
+ readonly decode: (bytes: Uint8Array, offset?: Offset) => TTo;
31
+ /**
32
+ * Reads the encoded value from the provided byte array at the given offset.
33
+ * Returns the decoded value and the offset of the next byte after the encoded value.
34
+ */
35
+ readonly read: (bytes: Uint8Array, offset: Offset) => [TTo, Offset];
36
+ };
37
+ export type FixedSizeDecoder<TTo, TSize extends number = number> = BaseDecoder<TTo> & {
38
+ /** The fixed size of the encoded value in bytes. */
39
+ readonly fixedSize: TSize;
40
+ };
41
+ export type VariableSizeDecoder<TTo> = BaseDecoder<TTo> & {
42
+ /** The maximum size an encoded value can be in bytes, if applicable. */
43
+ readonly maxSize?: number;
22
44
  };
23
45
  /**
24
46
  * An object that can decode a value from a `Uint8Array`.
25
47
  */
26
- export type Decoder<T> = CodecData & {
27
- /**
28
- * The function that decodes a value from bytes.
29
- * It returns the decoded value and the number of bytes read.
30
- */
31
- decode: (bytes: Uint8Array, offset?: Offset) => [T, Offset];
32
- };
48
+ export type Decoder<TTo> = FixedSizeDecoder<TTo> | VariableSizeDecoder<TTo>;
49
+ export type FixedSizeCodec<TFrom, TTo extends TFrom = TFrom, TSize extends number = number> = FixedSizeEncoder<TFrom, TSize> & FixedSizeDecoder<TTo, TSize>;
50
+ export type VariableSizeCodec<TFrom, TTo extends TFrom = TFrom> = VariableSizeEncoder<TFrom> & VariableSizeDecoder<TTo>;
33
51
  /**
34
52
  * An object that can encode and decode a value to and from a `Uint8Array`.
35
53
  * It supports encoding looser types than it decodes for convenience.
36
54
  * For example, a `bigint` encoder will always decode to a `bigint`
37
55
  * but can be used to encode a `number`.
38
56
  *
39
- * @typeParam From - The type of the value to encode.
40
- * @typeParam To - The type of the decoded value. Defaults to `From`.
57
+ * @typeParam TFrom - The type of the value to encode.
58
+ * @typeParam TTo - The type of the decoded value. Defaults to `TFrom`.
41
59
  */
42
- export type Codec<From, To extends From = From> = Encoder<From> & Decoder<To>;
60
+ export type Codec<TFrom, TTo extends TFrom = TFrom> = FixedSizeCodec<TFrom, TTo> | VariableSizeCodec<TFrom, TTo>;
43
61
  /**
44
- * Defines common options for codec factories.
62
+ * Get the encoded size of a given value in bytes.
45
63
  */
46
- export type BaseCodecOptions = {
47
- /** A custom description for the Codec. */
48
- description?: string;
64
+ export declare function getEncodedSize<TFrom>(value: TFrom, encoder: {
65
+ fixedSize: number;
66
+ } | {
67
+ getSizeFromValue: (value: TFrom) => number;
68
+ }): number;
69
+ /** Fills the missing `encode` function using the existing `write` function. */
70
+ export declare function createEncoder<TFrom, TSize extends number>(encoder: Omit<FixedSizeEncoder<TFrom, TSize>, 'encode'>): FixedSizeEncoder<TFrom, TSize>;
71
+ export declare function createEncoder<TFrom>(encoder: Omit<VariableSizeEncoder<TFrom>, 'encode'>): VariableSizeEncoder<TFrom>;
72
+ export declare function createEncoder<TFrom>(encoder: Omit<FixedSizeEncoder<TFrom>, 'encode'> | Omit<VariableSizeEncoder<TFrom>, 'encode'>): Encoder<TFrom>;
73
+ /** Fills the missing `decode` function using the existing `read` function. */
74
+ export declare function createDecoder<TTo, TSize extends number>(decoder: Omit<FixedSizeDecoder<TTo, TSize>, 'decode'>): FixedSizeDecoder<TTo, TSize>;
75
+ export declare function createDecoder<TTo>(decoder: Omit<VariableSizeDecoder<TTo>, 'decode'>): VariableSizeDecoder<TTo>;
76
+ export declare function createDecoder<TTo>(decoder: Omit<FixedSizeDecoder<TTo>, 'decode'> | Omit<VariableSizeDecoder<TTo>, 'decode'>): Decoder<TTo>;
77
+ /** Fills the missing `encode` and `decode` function using the existing `write` and `read` functions. */
78
+ export declare function createCodec<TFrom, TTo extends TFrom = TFrom, TSize extends number = number>(codec: Omit<FixedSizeCodec<TFrom, TTo, TSize>, 'encode' | 'decode'>): FixedSizeCodec<TFrom, TTo, TSize>;
79
+ export declare function createCodec<TFrom, TTo extends TFrom = TFrom>(codec: Omit<VariableSizeCodec<TFrom, TTo>, 'encode' | 'decode'>): VariableSizeCodec<TFrom, TTo>;
80
+ export declare function createCodec<TFrom, TTo extends TFrom = TFrom>(codec: Omit<FixedSizeCodec<TFrom, TTo>, 'encode' | 'decode'> | Omit<VariableSizeCodec<TFrom, TTo>, 'encode' | 'decode'>): Codec<TFrom, TTo>;
81
+ export declare function isFixedSize<TFrom, TSize extends number>(encoder: FixedSizeEncoder<TFrom, TSize> | VariableSizeEncoder<TFrom>): encoder is FixedSizeEncoder<TFrom, TSize>;
82
+ export declare function isFixedSize<TTo, TSize extends number>(decoder: FixedSizeDecoder<TTo, TSize> | VariableSizeDecoder<TTo>): decoder is FixedSizeDecoder<TTo, TSize>;
83
+ export declare function isFixedSize<TFrom, TTo extends TFrom, TSize extends number>(codec: FixedSizeCodec<TFrom, TTo, TSize> | VariableSizeCodec<TFrom, TTo>): codec is FixedSizeCodec<TFrom, TTo, TSize>;
84
+ export declare function isFixedSize<TSize extends number>(codec: {
85
+ fixedSize: TSize;
86
+ } | {
87
+ maxSize?: number;
88
+ }): codec is {
89
+ fixedSize: TSize;
49
90
  };
50
- /**
51
- * Wraps all the attributes of an object in Codecs.
52
- */
53
- export type WrapInCodec<T, U extends T = T> = {
54
- [P in keyof T]: Codec<T[P], U[P]>;
91
+ export declare function assertIsFixedSize<TFrom, TSize extends number>(encoder: FixedSizeEncoder<TFrom, TSize> | VariableSizeEncoder<TFrom>, message?: string): asserts encoder is FixedSizeEncoder<TFrom, TSize>;
92
+ export declare function assertIsFixedSize<TTo, TSize extends number>(decoder: FixedSizeDecoder<TTo, TSize> | VariableSizeDecoder<TTo>, message?: string): asserts decoder is FixedSizeDecoder<TTo, TSize>;
93
+ export declare function assertIsFixedSize<TFrom, TTo extends TFrom, TSize extends number>(codec: FixedSizeCodec<TFrom, TTo, TSize> | VariableSizeCodec<TFrom, TTo>, message?: string): asserts codec is FixedSizeCodec<TFrom, TTo, TSize>;
94
+ export declare function assertIsFixedSize<TSize extends number>(codec: {
95
+ fixedSize: TSize;
96
+ } | {
97
+ maxSize?: number;
98
+ }, message?: string): asserts codec is {
99
+ fixedSize: TSize;
100
+ };
101
+ export declare function isVariableSize<TFrom>(encoder: Encoder<TFrom>): encoder is VariableSizeEncoder<TFrom>;
102
+ export declare function isVariableSize<TTo>(decoder: Decoder<TTo>): decoder is VariableSizeDecoder<TTo>;
103
+ export declare function isVariableSize<TFrom, TTo extends TFrom>(codec: Codec<TFrom, TTo>): codec is VariableSizeCodec<TFrom, TTo>;
104
+ export declare function isVariableSize(codec: {
105
+ fixedSize: number;
106
+ } | {
107
+ maxSize?: number;
108
+ }): codec is {
109
+ maxSize?: number;
110
+ };
111
+ export declare function assertIsVariableSize<T>(encoder: Encoder<T>, message?: string): asserts encoder is VariableSizeEncoder<T>;
112
+ export declare function assertIsVariableSize<T>(decoder: Decoder<T>, message?: string): asserts decoder is VariableSizeDecoder<T>;
113
+ export declare function assertIsVariableSize<TFrom, TTo extends TFrom>(codec: Codec<TFrom, TTo>, message?: string): asserts codec is VariableSizeCodec<TFrom, TTo>;
114
+ export declare function assertIsVariableSize(codec: {
115
+ fixedSize: number;
116
+ } | {
117
+ maxSize?: number;
118
+ }, message?: string): asserts codec is {
119
+ maxSize?: number;
55
120
  };
121
+ export {};
56
122
  //# sourceMappingURL=codec.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"codec.d.ts","sourceRoot":"","sources":["../../src/codec.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,MAAM,MAAM,GAAG,MAAM,CAAC;AAE5B;;GAEG;AACH,MAAM,MAAM,SAAS,GAAG;IACpB,mCAAmC;IACnC,WAAW,EAAE,MAAM,CAAC;IACpB,iFAAiF;IACjF,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,sFAAsF;IACtF,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;CAC1B,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,OAAO,CAAC,CAAC,IAAI,SAAS,GAAG;IACjC,oDAAoD;IACpD,MAAM,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,UAAU,CAAC;CACpC,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,OAAO,CAAC,CAAC,IAAI,SAAS,GAAG;IACjC;;;OAGG;IACH,M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AgB,cAAc,CAAC,KAAK,EAAE;IAAE,SAAS,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,OAAO,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,KAAK,IAAI;IAAE,OAAO,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAKnH,wBAAgB,oBAAoB,CAAC,CAAC,EAClC,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,EACnB,OAAO,CAAC,EAAE,MAAM,GACjB,OAAO,CAAC,OAAO,IAAI,mBAAmB,CAAC,CAAC,CAAC,CAAC;AAC7C,wBAAgB,oBAAoB,CAAC,CAAC,EAClC,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,EACnB,OAAO,CAAC,EAAE,MAAM,GACjB,OAAO,CAAC,OAAO,IAAI,mBAAmB,CAAC,CAAC,CAAC,CAAC;AAC7C,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,GAAG,SAAS,KAAK,EACzD,KAAK,EAAE,KAAK,CAAC,KAAK,EAAE,GAAG,CAAC,EACxB,OAAO,CAAC,EAAE,MAAM,GACjB,OAAO,CAAC,KAAK,IAAI,iBAAiB,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;AAClD,wBAAgB,oBAAoB,CAChC,KAAK,EAAE;IAAE,SAAS,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,OAAO,CAAC,EAAE,MAAM,CAAA;CAAE,EACnD,OAAO,CAAC,EAAE,MAAM,GACjB,OAAO,CAAC,KAAK,IAAI;IAAE,OAAO,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC"}
@@ -1,8 +1,10 @@
1
- import { Codec, Decoder, Encoder } from './codec';
1
+ import { Codec, Decoder, Encoder, FixedSizeCodec, FixedSizeDecoder, FixedSizeEncoder, VariableSizeCodec, VariableSizeDecoder, VariableSizeEncoder } from './codec';
2
2
  /**
3
3
  * Combines an encoder and a decoder into a codec.
4
4
  * The encoder and decoder must have the same fixed size, max size and description.
5
5
  * If a description is provided, it will override the encoder and decoder descriptions.
6
6
  */
7
- export declare function combineCodec<From, To extends From = From>(encoder: Encoder<From>, decoder: Decoder<To>, description?: string): Codec<From, To>;
7
+ export declare function combineCodec<TFrom, TTo extends TFrom, TSize extends number>(encoder: FixedSizeEncoder<TFrom, TSize>, decoder: FixedSizeDecoder<TTo, TSize>): FixedSizeCodec<TFrom, TTo, TSize>;
8
+ export declare function combineCodec<TFrom, TTo extends TFrom>(encoder: VariableSizeEncoder<TFrom>, decoder: VariableSizeDecoder<TTo>): VariableSizeCodec<TFrom, TTo>;
9
+ export declare function combineCodec<TFrom, TTo extends TFrom>(encoder: Encoder<TFrom>, decoder: Decoder<TTo>): Codec<TFrom, TTo>;
8
10
  //# sourceMappingURL=combine-codec.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"combine-codec.d.ts","sourceRoot":"","sources":["../../src/combine-codec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAElD;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,EAAE,SAAS,IAAI,GAAG,IAAI,EACrD,OAAO,EAAE,OAAO,CAAC,IAAI,CAAC,EACtB,OAAO,EAAE,OAAO,CAAC,EAAE,CAAC,EACpB,WAAW,CAAC,EAAE,MAAM,GACrB,KAAK,CAAC,IAAI,EAAE,EAAE,CAAC,CA8BjB"}
1
+ {"version":3,"file":"combine-codec.d.ts","sourceRoot":"","sources":["../../src/combine-codec.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,KAAK,EACL,OAAO,EACP,OAAO,EACP,cAAc,EACd,gBAAgB,EAChB,gBAAgB,EAEhB,iBAAiB,EACjB,mBAAmB,EACnB,mBAAmB,EACtB,MAAM,SAAS,CAAC;AAEjB;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,GAAG,SAAS,KAAK,EAAE,KAAK,SAAS,MAAM,EACvE,OAAO,EAAE,gBAAgB,CAAC,KAAK,EAAE,KAAK,CAAC,EACvC,OAAO,EAAE,gBAAgB,CAAC,GAAG,EAAE,KAAK,CAAC,GACtC,cAAc,CAAC,KAAK,EAAE,GAAG,EAAE,KAAK,CAAC,CAAC;AACrC,wBAAgB,YAAY,CAAC,KAAK,EAAE,GAAG,SAAS,KAAK,EACjD,OAAO,EAAE,mBAAmB,CAAC,KAAK,CAAC,EACnC,OAAO,EAAE,mBAAmB,CAAC,GAAG,CAAC,GAClC,iBAAiB,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;AACjC,wBAAgB,YAAY,CAAC,KAAK,EAAE,GAAG,SAAS,KAAK,EACjD,OAAO,EAAE,OAAO,CAAC,KAAK,CAAC,EACvB,OAAO,EAAE,OAAO,CAAC,GAAG,CAAC,GACtB,KAAK,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC"}
@@ -1,26 +1,23 @@
1
- import { Codec, Decoder, Encoder } from './codec';
1
+ import { Codec, Decoder, Encoder, FixedSizeCodec, FixedSizeDecoder, FixedSizeEncoder } from './codec';
2
2
  /**
3
3
  * Creates a fixed-size encoder from a given encoder.
4
4
  *
5
5
  * @param encoder - The encoder to wrap into a fixed-size encoder.
6
6
  * @param fixedBytes - The fixed number of bytes to write.
7
- * @param description - A custom description for the encoder.
8
7
  */
9
- export declare function fixEncoder<T>(encoder: Encoder<T>, fixedBytes: number, description?: string): Encoder<T>;
8
+ export declare function fixEncoder<TFrom, TSize extends number>(encoder: Encoder<TFrom>, fixedBytes: TSize): FixedSizeEncoder<TFrom, TSize>;
10
9
  /**
11
10
  * Creates a fixed-size decoder from a given decoder.
12
11
  *
13
12
  * @param decoder - The decoder to wrap into a fixed-size decoder.
14
13
  * @param fixedBytes - The fixed number of bytes to read.
15
- * @param description - A custom description for the decoder.
16
14
  */
17
- export declare function fixDecoder<T>(decoder: Decoder<T>, fixedBytes: number, description?: string): Decoder<T>;
15
+ export declare function fixDecoder<TTo, TSize extends number>(decoder: Decoder<TTo>, fixedBytes: TSize): FixedSizeDecoder<TTo, TSize>;
18
16
  /**
19
17
  * Creates a fixed-size codec from a given codec.
20
18
  *
21
19
  * @param codec - The codec to wrap into a fixed-size codec.
22
20
  * @param fixedBytes - The fixed number of bytes to read/write.
23
- * @param description - A custom description for the codec.
24
21
  */
25
- export declare function fixCodec<T, U extends T = T>(codec: Codec<T, U>, fixedBytes: number, description?: string): Codec<T, U>;
22
+ export declare function fixCodec<TFrom, TTo extends TFrom, TSize extends number>(codec: Codec<TFrom, TTo>, fixedBytes: TSize): FixedSizeCodec<TFrom, TTo, TSize>;
26
23
  //# sourceMappingURL=fix-codec.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"fix-codec.d.ts","sourceRoot":"","sources":["../../src/fix-codec.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,EAAa,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAW7D;;;;;;GAMG;AACH,wBAAgB,UAAU,CAAC,CAAC,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,EAAE,UAAU,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC,CAKvG;AAED;;;;;;GAMG;AACH,wBAAgB,UAAU,CAAC,CAAC,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,EAAE,UAAU,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC,CAkBvG;AAED;;;;;;GAMG;AACH,wBAAgB,QAAQ,CAAC,CAAC,EAAE,CAAC,SAAS,CAAC,GAAG,CAAC,EACvC,KAAK,EAAE,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,EAClB,UAAU,EAAE,MAAM,EAClB,WAAW,CAAC,EAAE,MAAM,GACrB,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAEb"}
1
+ {"version":3,"file":"fix-codec.d.ts","sourceRoot":"","sources":["../../src/fix-codec.ts"],"names":[],"mappings":"AAEA,OAAO,EACH,KAAK,EAGL,OAAO,EACP,OAAO,EACP,cAAc,EACd,gBAAgB,EAChB,gBAAgB,EAGnB,MAAM,SAAS,CAAC;AAGjB;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,KAAK,SAAS,MAAM,EAClD,OAAO,EAAE,OAAO,CAAC,KAAK,CAAC,EACvB,UAAU,EAAE,KAAK,GAClB,gBAAgB,CAAC,KAAK,EAAE,KAAK,CAAC,CAchC;AAED;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,KAAK,SAAS,MAAM,EAChD,OAAO,EAAE,OAAO,CAAC,GAAG,CAAC,EACrB,UAAU,EAAE,KAAK,GAClB,gBAAgB,CAAC,GAAG,EAAE,KAAK,CAAC,CAkB9B;AAED;;;;;GAKG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,GAAG,SAAS,KAAK,EAAE,KAAK,SAAS,MAAM,EACnE,KAAK,EAAE,KAAK,CAAC,KAAK,EAAE,GAAG,CAAC,EACxB,UAAU,EAAE,KAAK,GAClB,cAAc,CAAC,KAAK,EAAE,GAAG,EAAE,KAAK,CAAC,CAEnC"}
@@ -1,15 +1,23 @@
1
- import { Codec, Decoder, Encoder } from './codec';
1
+ import { Codec, Decoder, Encoder, FixedSizeCodec, FixedSizeDecoder, FixedSizeEncoder, VariableSizeCodec, VariableSizeDecoder, VariableSizeEncoder } from './codec';
2
2
  /**
3
3
  * Converts an encoder A to a encoder B by mapping their values.
4
4
  */
5
- export declare function mapEncoder<T, U>(encoder: Encoder<T>, unmap: (value: U) => T): Encoder<U>;
5
+ export declare function mapEncoder<TOldFrom, TNewFrom, TSize extends number>(encoder: FixedSizeEncoder<TOldFrom, TSize>, unmap: (value: TNewFrom) => TOldFrom): FixedSizeEncoder<TNewFrom, TSize>;
6
+ export declare function mapEncoder<TOldFrom, TNewFrom>(encoder: VariableSizeEncoder<TOldFrom>, unmap: (value: TNewFrom) => TOldFrom): VariableSizeEncoder<TNewFrom>;
7
+ export declare function mapEncoder<TOldFrom, TNewFrom>(encoder: Encoder<TOldFrom>, unmap: (value: TNewFrom) => TOldFrom): Encoder<TNewFrom>;
6
8
  /**
7
9
  * Converts an decoder A to a decoder B by mapping their values.
8
10
  */
9
- export declare function mapDecoder<T, U>(decoder: Decoder<T>, map: (value: T, bytes: Uint8Array, offset: number) => U): Decoder<U>;
11
+ export declare function mapDecoder<TOldTo, TNewTo, TSize extends number>(decoder: FixedSizeDecoder<TOldTo, TSize>, map: (value: TOldTo, bytes: Uint8Array, offset: number) => TNewTo): FixedSizeDecoder<TNewTo, TSize>;
12
+ export declare function mapDecoder<TOldTo, TNewTo>(decoder: VariableSizeDecoder<TOldTo>, map: (value: TOldTo, bytes: Uint8Array, offset: number) => TNewTo): VariableSizeDecoder<TNewTo>;
13
+ export declare function mapDecoder<TOldTo, TNewTo>(decoder: Decoder<TOldTo>, map: (value: TOldTo, bytes: Uint8Array, offset: number) => TNewTo): Decoder<TNewTo>;
10
14
  /**
11
15
  * Converts a codec A to a codec B by mapping their values.
12
16
  */
13
- export declare function mapCodec<NewFrom, OldFrom, To extends NewFrom & OldFrom>(codec: Codec<OldFrom, To>, unmap: (value: NewFrom) => OldFrom): Codec<NewFrom, To>;
14
- export declare function mapCodec<NewFrom, OldFrom, NewTo extends NewFrom = NewFrom, OldTo extends OldFrom = OldFrom>(codec: Codec<OldFrom, OldTo>, unmap: (value: NewFrom) => OldFrom, map: (value: OldTo, bytes: Uint8Array, offset: number) => NewTo): Codec<NewFrom, NewTo>;
17
+ export declare function mapCodec<TOldFrom, TNewFrom, TTo extends TNewFrom & TOldFrom, TSize extends number>(codec: FixedSizeCodec<TOldFrom, TTo, TSize>, unmap: (value: TNewFrom) => TOldFrom): FixedSizeCodec<TNewFrom, TTo, TSize>;
18
+ export declare function mapCodec<TOldFrom, TNewFrom, TTo extends TNewFrom & TOldFrom>(codec: VariableSizeCodec<TOldFrom, TTo>, unmap: (value: TNewFrom) => TOldFrom): VariableSizeCodec<TNewFrom, TTo>;
19
+ export declare function mapCodec<TOldFrom, TNewFrom, TTo extends TNewFrom & TOldFrom>(codec: Codec<TOldFrom, TTo>, unmap: (value: TNewFrom) => TOldFrom): Codec<TNewFrom, TTo>;
20
+ export declare function mapCodec<TOldFrom, TNewFrom, TOldTo extends TOldFrom, TNewTo extends TNewFrom, TSize extends number>(codec: FixedSizeCodec<TOldFrom, TOldTo, TSize>, unmap: (value: TNewFrom) => TOldFrom, map: (value: TOldTo, bytes: Uint8Array, offset: number) => TNewTo): FixedSizeCodec<TNewFrom, TNewTo, TSize>;
21
+ export declare function mapCodec<TOldFrom, TNewFrom, TOldTo extends TOldFrom, TNewTo extends TNewFrom>(codec: VariableSizeCodec<TOldFrom, TOldTo>, unmap: (value: TNewFrom) => TOldFrom, map: (value: TOldTo, bytes: Uint8Array, offset: number) => TNewTo): VariableSizeCodec<TNewFrom, TNewTo>;
22
+ export declare function mapCodec<TOldFrom, TNewFrom, TOldTo extends TOldFrom, TNewTo extends TNewFrom>(codec: Codec<TOldFrom, TOldTo>, unmap: (value: TNewFrom) => TOldFrom, map: (value: TOldTo, bytes: Uint8Array, offset: number) => TNewTo): Codec<TNewFrom, TNewTo>;
15
23
  //# sourceMappingURL=map-codec.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"map-codec.d.ts","sourceRoot":"","sources":["../../src/map-codec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAElD;;GAEG;AACH,wBAAgB,UAAU,CAAC,CAAC,EAAE,CAAC,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAOxF;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,CAAC,EAAE,CAAC,EAC3B,OAAO,EAAE,OAAO,CAAC,CAAC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AAQ,EACzF,KAAK,EAAE,iBAAiB,CAAC,QAAQ,EAAE,MAAM,CAAC,EAC1C,KAAK,EAAE,CAAC,KAAK,EAAE,QAAQ,KAAK,QAAQ,EACpC,GAAG,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,KAAK,MAAM,GAClE,iBAAiB,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;AACvC,wBAAgB,QAAQ,CAAC,QAAQ,EAAE,QAAQ,EAAE,MAAM,SAAS,QAAQ,EAAE,MAAM,SAAS,QAAQ,EACzF,KAAK,EAAE,KAAK,CAAC,QAAQ,EAAE,MAAM,CAAC,EAC9B,KAAK,EAAE,CAAC,KAAK,EAAE,QAAQ,KAAK,QAAQ,EACpC,GAAG,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,KAAK,MAAM,GAClE,KAAK,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC"}
@@ -1,14 +1,14 @@
1
- import { Codec, Decoder, Encoder } from './codec';
1
+ import { FixedSizeCodec, FixedSizeDecoder, FixedSizeEncoder } from './codec';
2
2
  /**
3
3
  * Reverses the bytes of a fixed-size encoder.
4
4
  */
5
- export declare function reverseEncoder<T>(encoder: Encoder<T>): Encoder<T>;
5
+ export declare function reverseEncoder<TFrom, TSize extends number>(encoder: FixedSizeEncoder<TFrom, TSize>): FixedSizeEncoder<TFrom, TSize>;
6
6
  /**
7
7
  * Reverses the bytes of a fixed-size decoder.
8
8
  */
9
- export declare function reverseDecoder<T>(decoder: Decoder<T>): Decoder<T>;
9
+ export declare function reverseDecoder<TTo, TSize extends number>(decoder: FixedSizeDecoder<TTo, TSize>): FixedSizeDecoder<TTo, TSize>;
10
10
  /**
11
11
  * Reverses the bytes of a fixed-size codec.
12
12
  */
13
- export declare function reverseCodec<T, U extends T = T>(codec: Codec<T, U>): Codec<T, U>;
13
+ export declare function reverseCodec<TFrom, TTo extends TFrom, TSize extends number>(codec: FixedSizeCodec<TFrom, TTo, TSize>): FixedSizeCodec<TFrom, TTo, TSize>;
14
14
  //# sourceMappingURL=reverse-codec.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"reverse-codec.d.ts","sourceRoot":"","sources":["../../src/reverse-codec.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAGlD;;GAEG;AACH,wBAAgB,cAAc,CAAC,CAAC,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAMjE;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,CAAC,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAiBjE;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,CAAC,EAAE,CAAC,SAAS,CAAC,GAAG,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAEhF"}
1
+ {"version":3,"file":"reverse-codec.d.ts","sourceRoot":"","sources":["../../src/reverse-codec.ts"],"names":[],"mappings":"AAAA,OAAO,EAIH,cAAc,EACd,gBAAgB,EAChB,gBAAgB,EACnB,MAAM,SAAS,CAAC;AAGjB;;GAEG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,KAAK,SAAS,MAAM,EACtD,OAAO,EAAE,gBAAgB,CAAC,KAAK,EAAE,KAAK,CAAC,GACxC,gBAAgB,CAAC,KAAK,EAAE,KAAK,CAAC,CAWhC;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,KAAK,SAAS,MAAM,EACpD,OAAO,EAAE,gBAAgB,CAAC,GAAG,EAAE,KAAK,CAAC,GACtC,gBAAgB,CAAC,GAAG,EAAE,KAAK,CAAC,CAc9B;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,GAAG,SAAS,KAAK,EAAE,KAAK,SAAS,MAAM,EACvE,KAAK,EAAE,cAAc,CAAC,KAAK,EAAE,GAAG,EAAE,KAAK,CAAC,GACzC,cAAc,CAAC,KAAK,EAAE,GAAG,EAAE,KAAK,CAAC,CAEnC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@solana/codecs-core",
3
- "version": "2.0.0-experimental.fc4e943",
3
+ "version": "2.0.0-experimental.fcff844",
4
4
  "description": "Core types and helpers for encoding and decoding byte arrays on Solana",
5
5
  "exports": {
6
6
  "browser": {
@@ -50,20 +50,20 @@
50
50
  },
51
51
  "devDependencies": {
52
52
  "@solana/eslint-config-solana": "^1.0.2",
53
- "@swc/jest": "^0.2.28",
54
- "@types/jest": "^29.5.5",
53
+ "@swc/jest": "^0.2.29",
54
+ "@types/jest": "^29.5.6",
55
55
  "@typescript-eslint/eslint-plugin": "^6.7.0",
56
56
  "@typescript-eslint/parser": "^6.3.0",
57
57
  "agadoo": "^3.0.0",
58
58
  "eslint": "^8.45.0",
59
- "eslint-plugin-jest": "^27.2.3",
59
+ "eslint-plugin-jest": "^27.4.2",
60
60
  "eslint-plugin-sort-keys-fix": "^1.1.2",
61
61
  "jest": "^29.7.0",
62
- "jest-environment-jsdom": "^29.6.4",
63
- "jest-runner-eslint": "^2.1.0",
62
+ "jest-environment-jsdom": "^29.7.0",
63
+ "jest-runner-eslint": "^2.1.2",
64
64
  "jest-runner-prettier": "^1.0.0",
65
- "prettier": "^2.8",
66
- "tsup": "7.2.0",
65
+ "prettier": "^3.1",
66
+ "tsup": "^8.0.1",
67
67
  "typescript": "^5.2.2",
68
68
  "version-from-git": "^1.1.1",
69
69
  "build-scripts": "0.0.0",