-
Notifications
You must be signed in to change notification settings - Fork 915
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(experimental): rename mapCodec to transformCodec (#2434)
Currently we have the following codec functions: ``` // Transforms Codec<T> to Codec<U> by providing mapping functions between T and U. mapCodec(codec, U => T, T => U); // Creates a Codec<Map<K, V>> by providing a Codec<K> and a Codec<V>. getMapCodec(keyCodec, valueCodec); ``` Whilst they do completely different things, their names are too close to each other. This PR fixes this by renaming `mapCodec` to `transformCodec` — i.e. `/map(Encoder|Decoder|Codec)/transform$1/g`.
- Loading branch information
1 parent
2d48c09
commit 31916ae
Showing
29 changed files
with
194 additions
and
167 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
--- | ||
'@solana/codecs-data-structures': patch | ||
'@solana/codecs-strings': patch | ||
'@solana/transactions': patch | ||
'@solana/codecs-core': patch | ||
'@solana/addresses': patch | ||
'@solana/rpc-types': patch | ||
'@solana/options': patch | ||
--- | ||
|
||
Renamed `mapCodec` to `transformCodec` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 0 additions & 45 deletions
45
packages/codecs-core/src/__typetests__/map-codec-typetest.ts
This file was deleted.
Oops, something went wrong.
45 changes: 45 additions & 0 deletions
45
packages/codecs-core/src/__typetests__/transform-codec-typetest.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import { | ||
Codec, | ||
Decoder, | ||
Encoder, | ||
FixedSizeCodec, | ||
FixedSizeDecoder, | ||
FixedSizeEncoder, | ||
VariableSizeCodec, | ||
VariableSizeDecoder, | ||
VariableSizeEncoder, | ||
} from '../codec'; | ||
import { transformCodec, transformDecoder, transformEncoder } from '../transform-codec'; | ||
|
||
{ | ||
// [transformEncoder]: It keeps track of the nested encoder's size. | ||
transformEncoder({} as FixedSizeEncoder<string, 42>, (_: number) => '42') satisfies FixedSizeEncoder<number, 42>; | ||
transformEncoder({} as VariableSizeEncoder<string>, (_: number) => '42') satisfies VariableSizeEncoder<number>; | ||
transformEncoder({} as Encoder<string>, (_: number) => '42') satisfies Encoder<number>; | ||
} | ||
|
||
{ | ||
// [transformDecoder]: It keeps track of the nested decoder's size. | ||
transformDecoder({} as FixedSizeDecoder<string, 42>, (_: string) => 42) satisfies FixedSizeDecoder<number, 42>; | ||
transformDecoder({} as VariableSizeDecoder<string>, (_: string) => 42) satisfies VariableSizeDecoder<number>; | ||
transformDecoder({} as Decoder<string>, (_: string) => 42) satisfies Decoder<number>; | ||
} | ||
|
||
{ | ||
// [transformCodec]: It keeps track of the nested codec's size. | ||
transformCodec( | ||
{} as FixedSizeCodec<string, string, 42>, | ||
(_: number) => '42', | ||
(_: string) => 42, | ||
) satisfies FixedSizeCodec<number, number, 42>; | ||
transformCodec( | ||
{} as VariableSizeCodec<string>, | ||
(_: number) => '42', | ||
(_: string) => 42, | ||
) satisfies VariableSizeCodec<number>; | ||
transformCodec( | ||
{} as Codec<string>, | ||
(_: number) => '42', | ||
(_: string) => 42, | ||
) satisfies Codec<number>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,13 @@ | ||
export * from './add-codec-size-prefix'; | ||
export * from './add-codec-sentinel'; | ||
export * from './add-codec-size-prefix'; | ||
export * from './assertions'; | ||
export * from './bytes'; | ||
export * from './codec'; | ||
export * from './combine-codec'; | ||
export * from './fix-codec-size'; | ||
export * from './map-codec'; | ||
export * from './offset-codec'; | ||
export * from './pad-codec'; | ||
export * from './readonly-uint8array'; | ||
export * from './resize-codec'; | ||
export * from './reverse-codec'; | ||
export * from './transform-codec'; |
Oops, something went wrong.