300 lines
15 KiB
TypeScript
300 lines
15 KiB
TypeScript
/**
|
|
* TODO: bigint, large decimals. For right now, only use numbers that fit in
|
|
* JavaScript number.
|
|
*/
|
|
/// <reference types="node" />
|
|
export declare const Types: {
|
|
readonly BERT_START: 131;
|
|
readonly SMALL_ATOM: 119;
|
|
readonly ATOM: 100;
|
|
readonly BINARY: 109;
|
|
readonly SMALL_INTEGER: 97;
|
|
readonly INTEGER: 98;
|
|
readonly SMALL_BIG: 110;
|
|
readonly LARGE_BIG: 111;
|
|
readonly FLOAT: 99;
|
|
readonly STRING: 107;
|
|
readonly LIST: 108;
|
|
readonly SMALL_TUPLE: 104;
|
|
readonly LARGE_TUPLE: 105;
|
|
readonly MAP: 116;
|
|
readonly NIL: 106;
|
|
readonly NEW_FLOAT: 70;
|
|
readonly ZERO: 0;
|
|
};
|
|
export declare const Lang: {
|
|
readonly ELIXIR: 0;
|
|
readonly ERLANG: 1;
|
|
};
|
|
interface Partial<Type> {
|
|
value: Type;
|
|
rest: Buffer;
|
|
}
|
|
export declare class Atom {
|
|
readonly value: string;
|
|
private constructor();
|
|
private static atoms;
|
|
static toAtom: (value: string) => Atom;
|
|
}
|
|
/**
|
|
* WIP WIP WIP
|
|
*/
|
|
export declare class Tuple {
|
|
readonly values: any[];
|
|
constructor(values: any[]);
|
|
}
|
|
export declare class Bert {
|
|
#private;
|
|
private allBinariesAsString;
|
|
private mapKeyAsAtom;
|
|
private decodeUndefinedValues;
|
|
private convention;
|
|
private outputBuffer;
|
|
constructor(allBinariesAsString?: boolean, mapKeyAsAtom?: boolean, decodeUndefinedValues?: boolean, convention?: 0 | 1);
|
|
toAtom: (str: string) => {
|
|
type: string;
|
|
value: string;
|
|
toString: () => string;
|
|
};
|
|
toTuple: (arr: any[]) => {
|
|
type: string;
|
|
length: number;
|
|
value: any[];
|
|
toString: () => string;
|
|
toLocaleString(): string;
|
|
pop(): any;
|
|
push(...items: any[]): number;
|
|
concat(...items: ConcatArray<any>[]): any[];
|
|
concat(...items: any[]): any[];
|
|
join(separator?: string | undefined): string;
|
|
reverse(): any[];
|
|
shift(): any;
|
|
slice(start?: number | undefined, end?: number | undefined): any[];
|
|
sort(compareFn?: ((a: any, b: any) => number) | undefined): any[];
|
|
splice(start: number, deleteCount?: number | undefined): any[];
|
|
splice(start: number, deleteCount: number, ...items: any[]): any[];
|
|
unshift(...items: any[]): number;
|
|
indexOf(searchElement: any, fromIndex?: number | undefined): number;
|
|
lastIndexOf(searchElement: any, fromIndex?: number | undefined): number;
|
|
every<S extends any>(predicate: (value: any, index: number, array: any[]) => value is S, thisArg?: any): this is S[];
|
|
every(predicate: (value: any, index: number, array: any[]) => unknown, thisArg?: any): boolean;
|
|
some(predicate: (value: any, index: number, array: any[]) => unknown, thisArg?: any): boolean;
|
|
forEach(callbackfn: (value: any, index: number, array: any[]) => void, thisArg?: any): void;
|
|
map<U>(callbackfn: (value: any, index: number, array: any[]) => U, thisArg?: any): U[];
|
|
filter<S_1 extends any>(predicate: (value: any, index: number, array: any[]) => value is S_1, thisArg?: any): S_1[];
|
|
filter(predicate: (value: any, index: number, array: any[]) => unknown, thisArg?: any): any[];
|
|
reduce(callbackfn: (previousValue: any, currentValue: any, currentIndex: number, array: any[]) => any): any;
|
|
reduce(callbackfn: (previousValue: any, currentValue: any, currentIndex: number, array: any[]) => any, initialValue: any): any;
|
|
reduce<U_1>(callbackfn: (previousValue: U_1, currentValue: any, currentIndex: number, array: any[]) => U_1, initialValue: U_1): U_1;
|
|
reduceRight(callbackfn: (previousValue: any, currentValue: any, currentIndex: number, array: any[]) => any): any;
|
|
reduceRight(callbackfn: (previousValue: any, currentValue: any, currentIndex: number, array: any[]) => any, initialValue: any): any;
|
|
reduceRight<U_2>(callbackfn: (previousValue: U_2, currentValue: any, currentIndex: number, array: any[]) => U_2, initialValue: U_2): U_2;
|
|
find<S_2 extends any>(predicate: (value: any, index: number, obj: any[]) => value is S_2, thisArg?: any): S_2 | undefined;
|
|
find(predicate: (value: any, index: number, obj: any[]) => unknown, thisArg?: any): any;
|
|
findIndex(predicate: (value: any, index: number, obj: any[]) => unknown, thisArg?: any): number;
|
|
fill(value: any, start?: number | undefined, end?: number | undefined): any[];
|
|
copyWithin(target: number, start: number, end?: number | undefined): any[];
|
|
entries(): IterableIterator<[number, any]>;
|
|
keys(): IterableIterator<number>;
|
|
values(): IterableIterator<any>;
|
|
includes(searchElement: any, fromIndex?: number | undefined): boolean;
|
|
flatMap<U_3, This = undefined>(callback: (this: This, value: any, index: number, array: any[]) => U_3 | readonly U_3[], thisArg?: This | undefined): U_3[];
|
|
flat<A, D extends number = 1>(this: A, depth?: D | undefined): FlatArray<A, D>[];
|
|
at(index: number): any;
|
|
findLast<S_3 extends any>(predicate: (value: any, index: number, array: any[]) => value is S_3, thisArg?: any): S_3 | undefined;
|
|
findLast(predicate: (value: any, index: number, array: any[]) => unknown, thisArg?: any): any;
|
|
findLastIndex(predicate: (value: any, index: number, array: any[]) => unknown, thisArg?: any): number;
|
|
toReversed(): any[];
|
|
toSorted(compareFn?: ((a: any, b: any) => number) | undefined): any[];
|
|
toSpliced(start: number, deleteCount: number, ...items: any[]): any[];
|
|
toSpliced(start: number, deleteCount?: number | undefined): any[];
|
|
with(index: number, value: any): any[];
|
|
[Symbol.iterator](): IterableIterator<any>;
|
|
[Symbol.unscopables]: {
|
|
[x: number]: boolean | undefined;
|
|
length?: boolean | undefined;
|
|
toString?: boolean | undefined;
|
|
toLocaleString?: boolean | undefined;
|
|
pop?: boolean | undefined;
|
|
push?: boolean | undefined;
|
|
concat?: boolean | undefined;
|
|
join?: boolean | undefined;
|
|
reverse?: boolean | undefined;
|
|
shift?: boolean | undefined;
|
|
slice?: boolean | undefined;
|
|
sort?: boolean | undefined;
|
|
splice?: boolean | undefined;
|
|
unshift?: boolean | undefined;
|
|
indexOf?: boolean | undefined;
|
|
lastIndexOf?: boolean | undefined;
|
|
every?: boolean | undefined;
|
|
some?: boolean | undefined;
|
|
forEach?: boolean | undefined;
|
|
map?: boolean | undefined;
|
|
filter?: boolean | undefined;
|
|
reduce?: boolean | undefined;
|
|
reduceRight?: boolean | undefined;
|
|
find?: boolean | undefined;
|
|
findIndex?: boolean | undefined;
|
|
fill?: boolean | undefined;
|
|
copyWithin?: boolean | undefined;
|
|
entries?: boolean | undefined;
|
|
keys?: boolean | undefined;
|
|
values?: boolean | undefined;
|
|
includes?: boolean | undefined;
|
|
flatMap?: boolean | undefined;
|
|
flat?: boolean | undefined;
|
|
at?: boolean | undefined;
|
|
findLast?: boolean | undefined;
|
|
findLastIndex?: boolean | undefined;
|
|
toReversed?: boolean | undefined;
|
|
toSorted?: boolean | undefined;
|
|
toSpliced?: boolean | undefined;
|
|
with?: boolean | undefined;
|
|
[Symbol.iterator]?: boolean | undefined;
|
|
readonly [Symbol.unscopables]?: boolean | undefined;
|
|
};
|
|
};
|
|
encode: (obj: any, copy?: boolean) => Buffer;
|
|
decode: (buffer: Buffer) => any;
|
|
encode_string: (obj: string, buffer: Buffer) => Buffer;
|
|
encode_boolean: (obj: boolean, buffer: Buffer) => Buffer;
|
|
encode_number: (obj: number, buffer: Buffer) => Buffer;
|
|
encode_float: (obj: number, buffer: Buffer) => Buffer;
|
|
encode_object: (obj: any, buffer: Buffer) => Buffer;
|
|
encode_atom: (obj: any, buffer: Buffer) => Buffer;
|
|
encode_binary: (obj: Buffer, buffer: Buffer) => Buffer;
|
|
encode_undefined: (_obj: Buffer, buffer: Buffer) => Buffer;
|
|
encode_tuple: (obj: Buffer, buffer: Buffer) => Buffer;
|
|
encode_array: (obj: any[], buffer: Buffer) => Buffer;
|
|
encode_map: (obj: Record<string, any>, buffer: Buffer) => Buffer;
|
|
decode_atom: (buffer: Buffer, count: 1 | 2 | 4) => Partial<any>;
|
|
decode_binary: (buffer: Buffer) => Partial<string | Buffer>;
|
|
decode_integer: (buffer: Buffer, count: 1 | 2 | 4, unsigned?: boolean) => Partial<number>;
|
|
decode_big: (buffer: Buffer, count: 1 | 2 | 4) => {
|
|
value: number;
|
|
rest: Buffer;
|
|
};
|
|
decode_float: (buffer: Buffer) => Partial<number>;
|
|
decode_new_float: (buffer: Buffer) => Partial<number>;
|
|
decode_string: (buffer: Buffer) => Partial<string>;
|
|
decode_list: (buffer: Buffer) => Partial<any[]>;
|
|
decode_map: (buffer: Buffer) => Partial<Record<string, any>>;
|
|
decode_tuple: (buffer: Buffer, count: 1 | 2 | 4) => Partial<any>;
|
|
decode_nil: (buffer: Buffer) => Partial<[]>;
|
|
bytesToInt: (buffer: Buffer, length: 1 | 2 | 4, unsigned: boolean) => number;
|
|
}
|
|
/**
|
|
* Convert object to atom.
|
|
*
|
|
*/
|
|
export declare const toAtom: (str: string) => {
|
|
type: string;
|
|
value: string;
|
|
toString: () => string;
|
|
};
|
|
/**
|
|
* Convert array of items to tuple.
|
|
*
|
|
*/
|
|
export declare const toTuple: (arr: any[]) => {
|
|
type: string;
|
|
length: number;
|
|
value: any[];
|
|
toString: () => string;
|
|
toLocaleString(): string;
|
|
pop(): any;
|
|
push(...items: any[]): number;
|
|
concat(...items: ConcatArray<any>[]): any[];
|
|
concat(...items: any[]): any[];
|
|
join(separator?: string | undefined): string;
|
|
reverse(): any[];
|
|
shift(): any;
|
|
slice(start?: number | undefined, end?: number | undefined): any[];
|
|
sort(compareFn?: ((a: any, b: any) => number) | undefined): any[];
|
|
splice(start: number, deleteCount?: number | undefined): any[];
|
|
splice(start: number, deleteCount: number, ...items: any[]): any[];
|
|
unshift(...items: any[]): number;
|
|
indexOf(searchElement: any, fromIndex?: number | undefined): number;
|
|
lastIndexOf(searchElement: any, fromIndex?: number | undefined): number;
|
|
every<S extends any>(predicate: (value: any, index: number, array: any[]) => value is S, thisArg?: any): this is S[];
|
|
every(predicate: (value: any, index: number, array: any[]) => unknown, thisArg?: any): boolean;
|
|
some(predicate: (value: any, index: number, array: any[]) => unknown, thisArg?: any): boolean;
|
|
forEach(callbackfn: (value: any, index: number, array: any[]) => void, thisArg?: any): void;
|
|
map<U>(callbackfn: (value: any, index: number, array: any[]) => U, thisArg?: any): U[];
|
|
filter<S_1 extends any>(predicate: (value: any, index: number, array: any[]) => value is S_1, thisArg?: any): S_1[];
|
|
filter(predicate: (value: any, index: number, array: any[]) => unknown, thisArg?: any): any[];
|
|
reduce(callbackfn: (previousValue: any, currentValue: any, currentIndex: number, array: any[]) => any): any;
|
|
reduce(callbackfn: (previousValue: any, currentValue: any, currentIndex: number, array: any[]) => any, initialValue: any): any;
|
|
reduce<U_1>(callbackfn: (previousValue: U_1, currentValue: any, currentIndex: number, array: any[]) => U_1, initialValue: U_1): U_1;
|
|
reduceRight(callbackfn: (previousValue: any, currentValue: any, currentIndex: number, array: any[]) => any): any;
|
|
reduceRight(callbackfn: (previousValue: any, currentValue: any, currentIndex: number, array: any[]) => any, initialValue: any): any;
|
|
reduceRight<U_2>(callbackfn: (previousValue: U_2, currentValue: any, currentIndex: number, array: any[]) => U_2, initialValue: U_2): U_2;
|
|
find<S_2 extends any>(predicate: (value: any, index: number, obj: any[]) => value is S_2, thisArg?: any): S_2 | undefined;
|
|
find(predicate: (value: any, index: number, obj: any[]) => unknown, thisArg?: any): any;
|
|
findIndex(predicate: (value: any, index: number, obj: any[]) => unknown, thisArg?: any): number;
|
|
fill(value: any, start?: number | undefined, end?: number | undefined): any[];
|
|
copyWithin(target: number, start: number, end?: number | undefined): any[];
|
|
entries(): IterableIterator<[number, any]>;
|
|
keys(): IterableIterator<number>;
|
|
values(): IterableIterator<any>;
|
|
includes(searchElement: any, fromIndex?: number | undefined): boolean;
|
|
flatMap<U_3, This = undefined>(callback: (this: This, value: any, index: number, array: any[]) => U_3 | readonly U_3[], thisArg?: This | undefined): U_3[];
|
|
flat<A, D extends number = 1>(this: A, depth?: D | undefined): FlatArray<A, D>[];
|
|
at(index: number): any;
|
|
findLast<S_3 extends any>(predicate: (value: any, index: number, array: any[]) => value is S_3, thisArg?: any): S_3 | undefined;
|
|
findLast(predicate: (value: any, index: number, array: any[]) => unknown, thisArg?: any): any;
|
|
findLastIndex(predicate: (value: any, index: number, array: any[]) => unknown, thisArg?: any): number;
|
|
toReversed(): any[];
|
|
toSorted(compareFn?: ((a: any, b: any) => number) | undefined): any[];
|
|
toSpliced(start: number, deleteCount: number, ...items: any[]): any[];
|
|
toSpliced(start: number, deleteCount?: number | undefined): any[];
|
|
with(index: number, value: any): any[];
|
|
[Symbol.iterator](): IterableIterator<any>;
|
|
[Symbol.unscopables]: {
|
|
[x: number]: boolean | undefined;
|
|
length?: boolean | undefined;
|
|
toString?: boolean | undefined;
|
|
toLocaleString?: boolean | undefined;
|
|
pop?: boolean | undefined;
|
|
push?: boolean | undefined;
|
|
concat?: boolean | undefined;
|
|
join?: boolean | undefined;
|
|
reverse?: boolean | undefined;
|
|
shift?: boolean | undefined;
|
|
slice?: boolean | undefined;
|
|
sort?: boolean | undefined;
|
|
splice?: boolean | undefined;
|
|
unshift?: boolean | undefined;
|
|
indexOf?: boolean | undefined;
|
|
lastIndexOf?: boolean | undefined;
|
|
every?: boolean | undefined;
|
|
some?: boolean | undefined;
|
|
forEach?: boolean | undefined;
|
|
map?: boolean | undefined;
|
|
filter?: boolean | undefined;
|
|
reduce?: boolean | undefined;
|
|
reduceRight?: boolean | undefined;
|
|
find?: boolean | undefined;
|
|
findIndex?: boolean | undefined;
|
|
fill?: boolean | undefined;
|
|
copyWithin?: boolean | undefined;
|
|
entries?: boolean | undefined;
|
|
keys?: boolean | undefined;
|
|
values?: boolean | undefined;
|
|
includes?: boolean | undefined;
|
|
flatMap?: boolean | undefined;
|
|
flat?: boolean | undefined;
|
|
at?: boolean | undefined;
|
|
findLast?: boolean | undefined;
|
|
findLastIndex?: boolean | undefined;
|
|
toReversed?: boolean | undefined;
|
|
toSorted?: boolean | undefined;
|
|
toSpliced?: boolean | undefined;
|
|
with?: boolean | undefined;
|
|
[Symbol.iterator]?: boolean | undefined;
|
|
readonly [Symbol.unscopables]?: boolean | undefined;
|
|
};
|
|
};
|
|
export {};
|