-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
27 changed files
with
329 additions
and
611 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 |
---|---|---|
@@ -1,8 +1,11 @@ | ||
|
||
export interface BaseConverter { | ||
encode(buffer: Uint8Array | number[]): string; | ||
decodeUnsafe(string: string): Uint8Array | undefined; | ||
decode(string: string): Uint8Array; | ||
} | ||
|
||
export default function base(ALPHABET: string, name: string): BaseConverter | ||
export default _brrp__multiformats_scope_baseX; | ||
/** | ||
* @param {string} ALPHABET | ||
* @param {any} name | ||
*/ | ||
declare function _brrp__multiformats_scope_baseX(ALPHABET: string, name: any): { | ||
encode: (source: any[] | Iterable<number>) => string; | ||
decodeUnsafe: (source: string | string[]) => Uint8Array | undefined; | ||
decode: (string: string | string[]) => Uint8Array; | ||
}; | ||
//# sourceMappingURL=base-x.d.ts.map |
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,148 +1,74 @@ | ||
export function or<L extends string, R extends string>(left: API.UnibaseDecoder<L> | API.CombobaseDecoder<L>, right: API.UnibaseDecoder<R> | API.CombobaseDecoder<R>): ComposedDecoder<L | R>; | ||
/** | ||
* @class | ||
* @template {string} Base | ||
* @template {string} Prefix | ||
* @implements {API.MultibaseCodec<Prefix>} | ||
* @implements {API.MultibaseEncoder<Prefix>} | ||
* @implements {API.MultibaseDecoder<Prefix>} | ||
* @implements {API.BaseCodec} | ||
* @implements {API.BaseEncoder} | ||
* @implements {API.BaseDecoder} | ||
*/ | ||
export class Codec<Base extends string, Prefix extends string> implements API.MultibaseCodec<Prefix>, API.MultibaseEncoder<Prefix>, API.MultibaseDecoder<Prefix>, API.BaseCodec, API.BaseEncoder, API.BaseDecoder { | ||
/** | ||
* @param {Base} name | ||
* @param {Prefix} prefix | ||
* @param {(bytes:Uint8Array) => string} baseEncode | ||
* @param {(text:string) => Uint8Array} baseDecode | ||
*/ | ||
constructor(name: Base, prefix: Prefix, baseEncode: (bytes: Uint8Array) => string, baseDecode: (text: string) => Uint8Array); | ||
name: Base; | ||
prefix: Prefix; | ||
baseEncode: (bytes: Uint8Array) => string; | ||
baseDecode: (text: string) => Uint8Array; | ||
encoder: Encoder<Base, Prefix>; | ||
decoder: Decoder<Base, Prefix>; | ||
/** | ||
* @param {Uint8Array} input | ||
*/ | ||
encode(input: Uint8Array): API.Multibase<Prefix>; | ||
/** | ||
* @param {string} input | ||
*/ | ||
decode(input: string): Uint8Array; | ||
import type { BaseCodec, BaseDecoder, BaseEncoder, CombobaseDecoder, Multibase, MultibaseCodec, MultibaseDecoder, MultibaseEncoder, UnibaseDecoder } from './interface.js'; | ||
interface EncodeFn { | ||
(bytes: Uint8Array): string; | ||
} | ||
export function from<Base extends string, Prefix extends string>({ name, prefix, encode, decode }: { | ||
name: Base; | ||
prefix: Prefix; | ||
encode: (bytes: Uint8Array) => string; | ||
decode: (input: string) => Uint8Array; | ||
}): Codec<Base, Prefix>; | ||
export function baseX<Base extends string, Prefix extends string>({ prefix, name, alphabet }: { | ||
name: Base; | ||
prefix: Prefix; | ||
alphabet: string; | ||
}): Codec<Base, Prefix>; | ||
export function rfc4648<Base extends string, Prefix extends string>({ name, prefix, bitsPerChar, alphabet }: { | ||
name: Base; | ||
prefix: Prefix; | ||
alphabet: string; | ||
bitsPerChar: number; | ||
}): Codec<Base, Prefix>; | ||
export type Decoders<Prefix extends string> = Record<Prefix, API.UnibaseDecoder<Prefix>>; | ||
import * as API from "./interface.js"; | ||
/** | ||
* @template {string} Prefix | ||
* @typedef {Record<Prefix, API.UnibaseDecoder<Prefix>>} Decoders | ||
*/ | ||
/** | ||
* @template {string} Prefix | ||
* @implements {API.MultibaseDecoder<Prefix>} | ||
* @implements {API.CombobaseDecoder<Prefix>} | ||
*/ | ||
declare class ComposedDecoder<Prefix extends string> implements API.MultibaseDecoder<Prefix>, API.CombobaseDecoder<Prefix> { | ||
/** | ||
* @param {Decoders<Prefix>} decoders | ||
*/ | ||
constructor(decoders: Decoders<Prefix>); | ||
decoders: Decoders<Prefix>; | ||
/** | ||
* @template {string} OtherPrefix | ||
* @param {API.UnibaseDecoder<OtherPrefix>|ComposedDecoder<OtherPrefix>} decoder | ||
* @returns {ComposedDecoder<Prefix|OtherPrefix>} | ||
*/ | ||
or<OtherPrefix extends string>(decoder: API.UnibaseDecoder<OtherPrefix> | ComposedDecoder<OtherPrefix>): ComposedDecoder<Prefix | OtherPrefix>; | ||
/** | ||
* @param {string} input | ||
* @returns {Uint8Array} | ||
*/ | ||
decode(input: string): Uint8Array; | ||
interface DecodeFn { | ||
(text: string): Uint8Array; | ||
} | ||
/** | ||
* Class represents both BaseEncoder and MultibaseEncoder meaning it | ||
* can be used to encode to multibase or base encode without multibase | ||
* prefix. | ||
* | ||
* @class | ||
* @template {string} Base | ||
* @template {string} Prefix | ||
* @implements {API.MultibaseEncoder<Prefix>} | ||
* @implements {API.BaseEncoder} | ||
*/ | ||
declare class Encoder<Base extends string, Prefix extends string> implements API.MultibaseEncoder<Prefix>, API.BaseEncoder { | ||
/** | ||
* @param {Base} name | ||
* @param {Prefix} prefix | ||
* @param {(bytes:Uint8Array) => string} baseEncode | ||
*/ | ||
constructor(name: Base, prefix: Prefix, baseEncode: (bytes: Uint8Array) => string); | ||
name: Base; | ||
prefix: Prefix; | ||
baseEncode: (bytes: Uint8Array) => string; | ||
/** | ||
* @param {Uint8Array} bytes | ||
* @returns {API.Multibase<Prefix>} | ||
*/ | ||
encode(bytes: Uint8Array): API.Multibase<Prefix>; | ||
declare class Encoder<Base extends string, Prefix extends string> implements MultibaseEncoder<Prefix>, BaseEncoder { | ||
readonly name: Base; | ||
readonly prefix: Prefix; | ||
readonly baseEncode: EncodeFn; | ||
constructor(name: Base, prefix: Prefix, baseEncode: EncodeFn); | ||
encode(bytes: Uint8Array): Multibase<Prefix>; | ||
} | ||
/** | ||
* @template {string} Prefix | ||
*/ | ||
/** | ||
* Class represents both BaseDecoder and MultibaseDecoder so it could be used | ||
* to decode multibases (with matching prefix) or just base decode strings | ||
* with corresponding base encoding. | ||
* | ||
* @class | ||
* @template {string} Base | ||
* @template {string} Prefix | ||
* @implements {API.MultibaseDecoder<Prefix>} | ||
* @implements {API.UnibaseDecoder<Prefix>} | ||
* @implements {API.BaseDecoder} | ||
*/ | ||
declare class Decoder<Base extends string, Prefix extends string> implements API.MultibaseDecoder<Prefix>, API.UnibaseDecoder<Prefix>, API.BaseDecoder { | ||
/** | ||
* @param {Base} name | ||
* @param {Prefix} prefix | ||
* @param {(text:string) => Uint8Array} baseDecode | ||
*/ | ||
constructor(name: Base, prefix: Prefix, baseDecode: (text: string) => Uint8Array); | ||
name: Base; | ||
prefix: Prefix; | ||
/** @private */ | ||
private prefixCodePoint; | ||
baseDecode: (text: string) => Uint8Array; | ||
/** | ||
* @param {string} text | ||
*/ | ||
declare class Decoder<Base extends string, Prefix extends string> implements MultibaseDecoder<Prefix>, UnibaseDecoder<Prefix>, BaseDecoder { | ||
readonly name: Base; | ||
readonly prefix: Prefix; | ||
readonly baseDecode: DecodeFn; | ||
private readonly prefixCodePoint; | ||
constructor(name: Base, prefix: Prefix, baseDecode: DecodeFn); | ||
decode(text: string): Uint8Array; | ||
/** | ||
* @template {string} OtherPrefix | ||
* @param {API.UnibaseDecoder<OtherPrefix>|ComposedDecoder<OtherPrefix>} decoder | ||
* @returns {ComposedDecoder<Prefix|OtherPrefix>} | ||
*/ | ||
or<OtherPrefix extends string>(decoder: API.UnibaseDecoder<OtherPrefix> | ComposedDecoder<OtherPrefix>): ComposedDecoder<Prefix | OtherPrefix>; | ||
or<OtherPrefix extends string>(decoder: UnibaseDecoder<OtherPrefix> | ComposedDecoder<OtherPrefix>): ComposedDecoder<Prefix | OtherPrefix>; | ||
} | ||
type Decoders<Prefix extends string> = Record<Prefix, UnibaseDecoder<Prefix>>; | ||
declare class ComposedDecoder<Prefix extends string> implements MultibaseDecoder<Prefix>, CombobaseDecoder<Prefix> { | ||
readonly decoders: Decoders<Prefix>; | ||
constructor(decoders: Decoders<Prefix>); | ||
or<OtherPrefix extends string>(decoder: UnibaseDecoder<OtherPrefix> | ComposedDecoder<OtherPrefix>): ComposedDecoder<Prefix | OtherPrefix>; | ||
decode(input: string): Uint8Array; | ||
} | ||
export declare function or<L extends string, R extends string>(left: UnibaseDecoder<L> | CombobaseDecoder<L>, right: UnibaseDecoder<R> | CombobaseDecoder<R>): ComposedDecoder<L | R>; | ||
export declare class Codec<Base extends string, Prefix extends string> implements MultibaseCodec<Prefix>, MultibaseEncoder<Prefix>, MultibaseDecoder<Prefix>, BaseCodec, BaseEncoder, BaseDecoder { | ||
readonly name: Base; | ||
readonly prefix: Prefix; | ||
readonly baseEncode: EncodeFn; | ||
readonly baseDecode: DecodeFn; | ||
readonly encoder: Encoder<Base, Prefix>; | ||
readonly decoder: Decoder<Base, Prefix>; | ||
constructor(name: Base, prefix: Prefix, baseEncode: EncodeFn, baseDecode: DecodeFn); | ||
encode(input: Uint8Array): string; | ||
decode(input: string): Uint8Array; | ||
} | ||
export declare function from<Base extends string, Prefix extends string>({ name, prefix, encode, decode }: { | ||
name: Base; | ||
prefix: Prefix; | ||
encode: EncodeFn; | ||
decode: DecodeFn; | ||
}): Codec<Base, Prefix>; | ||
export declare function baseX<Base extends string, Prefix extends string>({ name, prefix, alphabet }: { | ||
name: Base; | ||
prefix: Prefix; | ||
alphabet: string; | ||
}): Codec<Base, Prefix>; | ||
/** | ||
* RFC4648 Factory | ||
*/ | ||
export declare function rfc4648<Base extends string, Prefix extends string>({ name, prefix, bitsPerChar, alphabet }: { | ||
name: Base; | ||
prefix: Prefix; | ||
bitsPerChar: number; | ||
alphabet: string; | ||
}): Codec<Base, Prefix>; | ||
export {}; | ||
//# sourceMappingURL=base.d.ts.map |
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,2 +1,2 @@ | ||
export const base10: import("./base.js").Codec<"base10", "9">; | ||
export declare const base10: import("./base.js").Codec<"base10", "9">; | ||
//# sourceMappingURL=base10.d.ts.map |
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,3 +1,3 @@ | ||
export const base16: import("./base.js").Codec<"base16", "f">; | ||
export const base16upper: import("./base.js").Codec<"base16upper", "F">; | ||
export declare const base16: import("./base.js").Codec<"base16", "f">; | ||
export declare const base16upper: import("./base.js").Codec<"base16upper", "F">; | ||
//# sourceMappingURL=base16.d.ts.map |
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,2 +1,2 @@ | ||
export const base2: import("./base.js").Codec<"base2", "0">; | ||
export declare const base2: import("./base.js").Codec<"base2", "0">; | ||
//# sourceMappingURL=base2.d.ts.map |
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,2 +1,2 @@ | ||
export const base256emoji: import("./base.js").Codec<"base256emoji", "🚀">; | ||
export declare const base256emoji: import("./base.js").Codec<"base256emoji", "🚀">; | ||
//# sourceMappingURL=base256emoji.d.ts.map |
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,10 +1,10 @@ | ||
export const base32: import("./base.js").Codec<"base32", "b">; | ||
export const base32upper: import("./base.js").Codec<"base32upper", "B">; | ||
export const base32pad: import("./base.js").Codec<"base32pad", "c">; | ||
export const base32padupper: import("./base.js").Codec<"base32padupper", "C">; | ||
export const base32hex: import("./base.js").Codec<"base32hex", "v">; | ||
export const base32hexupper: import("./base.js").Codec<"base32hexupper", "V">; | ||
export const base32hexpad: import("./base.js").Codec<"base32hexpad", "t">; | ||
export const base32hexpadupper: import("./base.js").Codec<"base32hexpadupper", "T">; | ||
export const base32z: import("./base.js").Codec<"base32z", "h">; | ||
export declare const base32: import("./base.js").Codec<"base32", "b">; | ||
export declare const base32upper: import("./base.js").Codec<"base32upper", "B">; | ||
export declare const base32pad: import("./base.js").Codec<"base32pad", "c">; | ||
export declare const base32padupper: import("./base.js").Codec<"base32padupper", "C">; | ||
export declare const base32hex: import("./base.js").Codec<"base32hex", "v">; | ||
export declare const base32hexupper: import("./base.js").Codec<"base32hexupper", "V">; | ||
export declare const base32hexpad: import("./base.js").Codec<"base32hexpad", "t">; | ||
export declare const base32hexpadupper: import("./base.js").Codec<"base32hexpadupper", "T">; | ||
export declare const base32z: import("./base.js").Codec<"base32z", "h">; | ||
//# sourceMappingURL=base32.d.ts.map |
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,3 +1,3 @@ | ||
export const base36: import("./base.js").Codec<"base36", "k">; | ||
export const base36upper: import("./base.js").Codec<"base36upper", "K">; | ||
export declare const base36: import("./base.js").Codec<"base36", "k">; | ||
export declare const base36upper: import("./base.js").Codec<"base36upper", "K">; | ||
//# sourceMappingURL=base36.d.ts.map |
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,3 +1,3 @@ | ||
export const base58btc: import("./base.js").Codec<"base58btc", "z">; | ||
export const base58flickr: import("./base.js").Codec<"base58flickr", "Z">; | ||
export declare const base58btc: import("./base.js").Codec<"base58btc", "z">; | ||
export declare const base58flickr: import("./base.js").Codec<"base58flickr", "Z">; | ||
//# sourceMappingURL=base58.d.ts.map |
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,5 +1,5 @@ | ||
export const base64: import("./base.js").Codec<"base64", "m">; | ||
export const base64pad: import("./base.js").Codec<"base64pad", "M">; | ||
export const base64url: import("./base.js").Codec<"base64url", "u">; | ||
export const base64urlpad: import("./base.js").Codec<"base64urlpad", "U">; | ||
export declare const base64: import("./base.js").Codec<"base64", "m">; | ||
export declare const base64pad: import("./base.js").Codec<"base64pad", "M">; | ||
export declare const base64url: import("./base.js").Codec<"base64url", "u">; | ||
export declare const base64urlpad: import("./base.js").Codec<"base64urlpad", "U">; | ||
//# sourceMappingURL=base64.d.ts.map |
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,2 +1,2 @@ | ||
export const base8: import("./base.js").Codec<"base8", "7">; | ||
export declare const base8: import("./base.js").Codec<"base8", "7">; | ||
//# sourceMappingURL=base8.d.ts.map |
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
Oops, something went wrong.