-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.d.ts
56 lines (46 loc) · 2.67 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import { Codecs as BaseCodecs, Codec as BaseCodec, OutType as BaseOutType, InType as BaseInType, CodecName as BaseCodecName, NamedCodec, BinaryCodec, CodecLookup } from 'codecs'
import { MsgPackCodec, DecodeOptions, EncodeOptions } from 'msgpack-codec'
import { Base32cCodec, Base32Codec, Base32hCodec, Base32hpCodec, Base32pCodec } from 'base32-codecs'
export type BigIntBECodec = NamedCodec<'bigIntBE', bigint>
export type BigIntLECodec = NamedCodec<'bigIntLE', bigint>
export type BigIntQuickCodec = NamedCodec<'bigIntQuick', bigint>
export type BigUintBECodec = NamedCodec<'bigUintBE', bigint>
export type BigUintLECodec = NamedCodec<'bigUintLE', bigint>
interface KnownCodecs extends CodecLookup {
base32: Base32Codec
base32c: Base32cCodec
base32h: Base32hCodec
base32hp: Base32hpCodec
base32p: Base32pCodec
msgpack: MsgPackCodec
bigIntBE: BigIntBECodec
bigIntLE: BigIntLECodec
bigIntQuick: BigIntQuickCodec
bigUintBE: BigUintBECodec
bigUintLE: BigUintLECodec
}
export type Codec <TCodec, TFallback = BinaryCodec, TCodecs = KnownCodecs> = BaseCodec<TCodec, TFallback, TCodecs>
export type OutType <TCodec extends MaybeCodecInput, TFallback extends NamedCodec = BinaryCodec, TCodecs = KnownCodecs> = BaseOutType<TCodec, TFallback, TCodecs>
export type InType <TCodec extends MaybeCodecInput, TFallback extends NamedCodec = BinaryCodec, TCodecs = KnownCodecs> = BaseInType<TCodec, TFallback, TCodecs>
export type CodecName <TCodec extends MaybeCodecInput, TFallback extends NamedCodec = BinaryCodec, TCodecs = KnownCodecs> = BaseCodecName<TCodec, TFallback, TCodecs>
export { MsgPackCodec, DecodeOptions, EncodeOptions } from 'msgpack-codec'
export { Base32cCodec, Base32Codec, Base32hCodec, Base32hpCodec, Base32pCodec } from 'base32-codecs'
export { JsonCodec, NDJsonCodec, AsciiCodec, Utf8Codec, HexCodec, Base64Codec, Ucs2Codec, Utf16leCodec, NamedCodec, JsonObject, JsonArray, JsonValue } from 'codecs'
export type CodecInput = keyof KnownCodecs | NamedCodec
export type MaybeCodecInput = CodecInput | null | undefined
interface Codecs extends BaseCodecs, KnownCodecs {
(): BinaryCodec;
<TCodec extends MaybeCodecInput, TFallback= BinaryCodec>(
codec: TCodec,
fallback?: TFallback,
): Codec<TCodec, TFallback>;
[Symbol.iterator] (): Iterator<NamedCodec<keyof KnownCodecs>>
has (codec: string): boolean
bindMsgpack <TName extends string | null | undefined = undefined> (options: { encode?: EncodeOptions, decode?: DecodeOptions }, name?: TName): TName extends string
? MsgPackCodec<TName>
: MsgPackCodec<'msgpack-ext'>
available: Array<keyof KnownCodecs>
inspect (type: string, name: string): () => string
}
declare const codecs: Codecs
export default codecs