-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathindex.d.ts
More file actions
60 lines (54 loc) · 2.76 KB
/
index.d.ts
File metadata and controls
60 lines (54 loc) · 2.76 KB
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
57
58
59
60
declare module '@discoveryjs/json-ext' {
type Chunk = string | Uint8Array | Buffer;
type Reviver = (this: any, key: string, value: any) => any;
type ParseChunkState = {
readonly mode: 'json' | 'jsonl';
readonly rootValuesCount: number;
readonly consumed: number;
readonly parsed: number;
};
type OnRootValue = (value: any, state: ParseChunkState) => void;
type OnChunk = (chunkParsed: number, chunk: string | null, pending: string | null, state: ParseChunkState) => void;
type ParseOptions = {
reviver?: Reviver;
mode?: 'json' | 'jsonl' | 'auto';
onRootValue?: OnRootValue;
onChunk?: OnChunk;
};
type Replacer =
| ((this: any, key: string, value: any) => any)
| (string | number)[]
| null;
type Space = string | number | null;
type StringifyOptions = {
replacer?: Replacer;
space?: Space;
mode?: 'json' | 'jsonl';
highWaterMark?: number;
}
type StringifyInfoOptions = {
replacer?: Replacer;
space?: Space;
mode?: 'json' | 'jsonl';
continueOnCircular?: boolean;
}
type StringifyInfoResult = {
bytes: number;
spaceBytes: number;
circular: object[];
};
export function parseChunked(input: Iterable<Chunk> | AsyncIterable<Chunk>, reviver?: Reviver): Promise<any>;
export function parseChunked(input: Iterable<Chunk> | AsyncIterable<Chunk>, options: ParseOptions & { onRootValue: OnRootValue }): Promise<number>;
export function parseChunked(input: Iterable<Chunk> | AsyncIterable<Chunk>, options?: ParseOptions): Promise<any>;
export function parseChunked(input: () => (Iterable<Chunk> | AsyncIterable<Chunk>), reviver?: Reviver): Promise<any>;
export function parseChunked(input: () => (Iterable<Chunk> | AsyncIterable<Chunk>), options: ParseOptions & { onRootValue: OnRootValue }): Promise<number>;
export function parseChunked(input: () => (Iterable<Chunk> | AsyncIterable<Chunk>), options?: ParseOptions): Promise<any>;
export function stringifyChunked(value: any, replacer?: Replacer, space?: Space): Generator<string>;
export function stringifyChunked(value: any, options: StringifyOptions): Generator<string>;
export function stringifyInfo(value: any, replacer?: Replacer, space?: Space): StringifyInfoResult;
export function stringifyInfo(value: any, options?: StringifyInfoOptions): StringifyInfoResult;
// Web streams
export function parseFromWebStream(stream: ReadableStream<Chunk>): Promise<any>;
export function createStringifyWebStream(value: any, replacer?: Replacer, space?: Space): ReadableStream<string>;
export function createStringifyWebStream(value: any, options: StringifyOptions): ReadableStream<string>;
}