/*! scure-base - MIT License (c) 2022 Paul Miller (paulmillr.com) */ /** * @__NO_SIDE_EFFECTS__ */ export declare function assertNumber(n: number): void; export interface Coder { encode(from: F): T; decode(to: T): F; } export interface BytesCoder extends Coder { encode: (data: Uint8Array) => string; decode: (str: string) => Uint8Array; } type Chain = [Coder, ...Coder[]]; type Input = F extends Coder ? T : never; type Output = F extends Coder ? T : never; type First = T extends [infer U, ...any[]] ? U : never; type Last = T extends [...any[], infer U] ? U : never; type Tail = T extends [any, ...infer U] ? U : never; type AsChain> = { [K in keyof C]: Coder, Input>; }; /** * @__NO_SIDE_EFFECTS__ */ declare function chain>(...args: T): Coder>, Output>>; type Alphabet = string[] | string; /** * Encodes integer radix representation to array of strings using alphabet and back * @__NO_SIDE_EFFECTS__ */ declare function alphabet(alphabet: Alphabet): Coder; /** * @__NO_SIDE_EFFECTS__ */ declare function join(separator?: string): Coder; /** * Pad strings array so it has integer number of bits * @__NO_SIDE_EFFECTS__ */ declare function padding(bits: number, chr?: string): Coder; /** * @__NO_SIDE_EFFECTS__ */ declare function radix(num: number): Coder; /** * If both bases are power of same number (like `2**8 <-> 2**64`), * there is a linear algorithm. For now we have implementation for power-of-two bases only. * @__NO_SIDE_EFFECTS__ */ declare function radix2(bits: number, revPadding?: boolean): Coder; /** * @__NO_SIDE_EFFECTS__ */ declare function checksum(len: number, fn: (data: Uint8Array) => Uint8Array): Coder; export declare const utils: { alphabet: typeof alphabet; chain: typeof chain; checksum: typeof checksum; radix: typeof radix; radix2: typeof radix2; join: typeof join; padding: typeof padding; }; export declare const base16: BytesCoder; export declare const base32: BytesCoder; export declare const base32hex: BytesCoder; export declare const base32crockford: BytesCoder; export declare const base64: BytesCoder; export declare const base64url: BytesCoder; export declare const base64urlnopad: BytesCoder; export declare const base58: BytesCoder; export declare const base58flickr: BytesCoder; export declare const base58xrp: BytesCoder; export declare const base58xmr: BytesCoder; export declare const base58check: (sha256: (data: Uint8Array) => Uint8Array) => BytesCoder; export interface Bech32Decoded { prefix: Prefix; words: number[]; } export interface Bech32DecodedWithArray { prefix: Prefix; words: number[]; bytes: Uint8Array; } export declare const bech32: { encode: (prefix: Prefix, words: number[] | Uint8Array, limit?: number | false) => `${Lowercase}1${string}`; decode: { (str: `${Prefix_1}1${string}`, limit?: number | false): Bech32Decoded; (str: string, limit?: number | false): Bech32Decoded; }; decodeToBytes: (str: string) => Bech32DecodedWithArray; decodeUnsafe: (str: string, limit?: number | false | undefined) => void | Bech32Decoded; fromWords: (to: number[]) => Uint8Array; fromWordsUnsafe: (to: number[]) => void | Uint8Array; toWords: (from: Uint8Array) => number[]; }; export declare const bech32m: { encode: (prefix: Prefix, words: number[] | Uint8Array, limit?: number | false) => `${Lowercase}1${string}`; decode: { (str: `${Prefix_1}1${string}`, limit?: number | false): Bech32Decoded; (str: string, limit?: number | false): Bech32Decoded; }; decodeToBytes: (str: string) => Bech32DecodedWithArray; decodeUnsafe: (str: string, limit?: number | false | undefined) => void | Bech32Decoded; fromWords: (to: number[]) => Uint8Array; fromWordsUnsafe: (to: number[]) => void | Uint8Array; toWords: (from: Uint8Array) => number[]; }; export declare const utf8: BytesCoder; export declare const hex: BytesCoder; declare const CODERS: { utf8: BytesCoder; hex: BytesCoder; base16: BytesCoder; base32: BytesCoder; base64: BytesCoder; base64url: BytesCoder; base58: BytesCoder; base58xmr: BytesCoder; }; type CoderType = keyof typeof CODERS; export declare const bytesToString: (type: CoderType, bytes: Uint8Array) => string; export declare const str: (type: CoderType, bytes: Uint8Array) => string; export declare const stringToBytes: (type: CoderType, str: string) => Uint8Array; export declare const bytes: (type: CoderType, str: string) => Uint8Array; export {}; //# sourceMappingURL=index.d.ts.map