UNPKG

json-web-streams

Version:

Streaming JSON parser built on top of the Web Streams API, so it works in web browsers, Node.js, and many other environments

58 lines 1.87 kB
//#region src/JSONParseStreamRaw.d.ts type Token = "LEFT_BRACE" | "RIGHT_BRACE" | "LEFT_BRACKET" | "RIGHT_BRACKET" | "COLON" | "COMMA" | "TRUE" | "FALSE" | "NULL" | "STRING" | "NUMBER"; type ParserState = "VALUE" | "KEY" | "VALUE_AFTER_COMMA" | "KEY_AFTER_COMMA"; type TokenizerState = "START" | "TRUE1" | "TRUE2" | "TRUE3" | "FALSE1" | "FALSE2" | "FALSE3" | "FALSE4" | "NULL1" | "NULL2" | "NULL3" | "NUMBER-" | "NUMBER0" | "NUMBER" | "STRING1" | "STRING2" | "STRING3" | "STRING4" | "STRING5" | "STRING6"; type Mode = "OBJECT" | "ARRAY"; type Key = string | number; type Value = any; type Stack = { key: Key | undefined; value: Value | undefined; mode: Mode | undefined; }[]; type OnPopPush = (stackLength: number) => void; type OnValue = (value: Value) => void; declare class JSONParseStreamRaw { tokenizerState: TokenizerState; state: Token | ParserState; mode: Mode | undefined; stack: Stack; string: string | undefined; key: Key | undefined; value: Value; position: number; onKey: OnPopPush | undefined; onPop: OnPopPush | undefined; onPush: OnPopPush | undefined; onValue: OnValue; unicode: string | undefined; highSurrogate: number | undefined; seenRootObject: boolean; multi: boolean | undefined; multiIndex: number; constructor({ multi, onKey, onPop, onPush, onValue }: { multi?: boolean; onKey?: OnPopPush; onPop?: OnPopPush; onPush?: OnPopPush; onValue: OnValue; }); charError(char: string, i: number): void; parseError(token: Token, value: Value, i: number): void; write(text: string): void; push(): void; pop(): void; setKey(key: number | string | undefined): void; emit(value: Value): void; onToken(token: Token, value: Value, i: number): void; numberReviver(text: string, i: number): void; checkEnd(): void; } //#endregion export { JSONParseStreamRaw };