mirror of
https://github.com/pezkuwichain/pezkuwi-common.git
synced 2026-04-22 05:38:03 +00:00
26 lines
965 B
TypeScript
26 lines
965 B
TypeScript
import type { U8aLike } from '@pezkuwi/util/types';
|
|
export type { U8aLike } from '@pezkuwi/util/types';
|
|
interface Coder {
|
|
decode: (value: string) => Uint8Array;
|
|
encode: (value: Uint8Array) => string;
|
|
}
|
|
interface Config {
|
|
chars: string;
|
|
coder: Coder;
|
|
ipfs?: string;
|
|
regex?: RegExp;
|
|
type: string;
|
|
withPadding?: boolean;
|
|
}
|
|
type DecodeFn = (value: string, ipfsCompat?: boolean) => Uint8Array;
|
|
type EncodeFn = (value: U8aLike, ipfsCompat?: boolean) => string;
|
|
type ValidateFn = (value?: unknown, ipfsCompat?: boolean) => value is string;
|
|
/** @internal */
|
|
export declare function createDecode({ coder, ipfs }: Config, validate: ValidateFn): DecodeFn;
|
|
/** @internal */
|
|
export declare function createEncode({ coder, ipfs }: Config): EncodeFn;
|
|
/** @internal */
|
|
export declare function createIs(validate: ValidateFn): ValidateFn;
|
|
/** @internal */
|
|
export declare function createValidate({ chars, ipfs, type, withPadding }: Config): ValidateFn;
|