- JSONStream ⇐
EventEmitter Class representing a JSONStream.
- Parser ⇐
EventEmitter Class to parse JSON strings into tokens
- Renderer ⇐
EventEmitter Class representing a JSON renderer
Class representing a JSONStream.
Kind: global class
Extends: EventEmitter
- JSONStream ⇐
EventEmitter- new JSONStream([opts])
- instance
- .write(string) ⇒
Promise - .end(string) ⇒
Promise - "data"
- "drain"
- "end"
- .write(string) ⇒
- static
- .parse(string, [opts]) ⇒
string - .stringify(object, [opts]) ⇒
string
- .parse(string, [opts]) ⇒
Constructor
| Param | Type | Default | Description |
|---|---|---|---|
| [opts] | object |
{} |
Options, @see Renderer#constructor |
Write a chunk of data to the stream.
Kind: instance method of JSONStream
Returns: Promise - Resolves when the chunk has been written.
| Param | Type | Description |
|---|---|---|
| string | string |
The chunk of data to write. |
Write a chunk of data to the stream, then close it
Kind: instance method of JSONStream
Returns: Promise - Resolves when the stream has been closed
| Param | Type | Description |
|---|---|---|
| string | string |
The chunk of data to write. |
TODO
Kind: event emitted by JSONStream
TODO
Kind: event emitted by JSONStream
TODO
Kind: event emitted by JSONStream
Statically parse a JSON string.
Kind: static method of JSONStream
Returns: string - The parsed JSON string.
| Param | Type | Default | Description |
|---|---|---|---|
| string | string |
The JSON string to parse. | |
| [opts] | object |
{} |
Options, @see Renderer#constructor |
Statically parse a javascript object into a JSON string.
Kind: static method of JSONStream
Returns: string - The parsed JSON string.
| Param | Type | Default | Description |
|---|---|---|---|
| object | object | Array |
The javascript object to parse | |
| [opts] | object |
{} |
Options, @see Renderer#constructor |
Class to parse JSON strings into tokens
Kind: global class
Extends: EventEmitter
- Parser ⇐
EventEmitter- new Parser()
- instance
- .closed :
boolean - .write(chunk) ⇒
Promise - .end(chunk) ⇒
Promise - "close"
- "drain"
- "error"
- "token"
- .closed :
- static
- .parse(text) ⇒
Promise.<Array.<object>>
- .parse(text) ⇒
Constructor
Has the stream been closed?
Kind: instance property of Parser
Add the following chunk to the parser's data stack
Kind: instance method of Parser
Returns: Promise - Resolves when the chunk has been parsed
| Param | Type |
|---|---|
| chunk | string |
Add the following chunk to the parser's data stack, and declare this the end
Kind: instance method of Parser
Returns: Promise - Resolves when the parser has finished
| Param | Type |
|---|---|
| chunk | string |
TODO
Kind: event emitted by Parser
TODO
Kind: event emitted by Parser
TODO
Kind: event emitted by Parser
TODO
Kind: event emitted by Parser
Parse the provided text into tokens
Kind: static method of Parser
Returns: Promise.<Array.<object>> - Array of tokens
| Param | Type |
|---|---|
| text | string |
Class representing a JSON renderer
Kind: global class
Extends: EventEmitter
- Renderer ⇐
EventEmitter- new Renderer([options])
- instance
- .render(tokens) ⇒
string - .render_token(token)
- "data"
- .render(tokens) ⇒
- static
- .render(tokens, [opts]) ⇒
string
- .render(tokens, [opts]) ⇒
Constructor
| Param | Type | Default | Description |
|---|---|---|---|
| [options] | object |
Options | |
| [options.indent] | string |
"' '" |
The string to use for indentation |
| [options.EOL] | string |
"\n" |
The string to use for EOL |
| [options.colon] | string |
":" |
The string to use for colons |
| [options.suppress_quotes] | boolean |
true |
Whether to suppress quotes |
| [options.escape_whitespace] | boolean |
true |
Whether to escape (non-space) whitespace |
| [options.escape_unicode] | boolean |
false |
Whether to escape unicode characters |
| [options.colorize] | boolean |
true |
Whether to colorize the output |
| [options.quotes_color] | string |
"default" |
- |
| [options.quotes_faint] | boolean |
true |
- |
| [options.colon_color] | string |
"default" |
- |
| [options.colon_faint] | boolean |
true |
- |
| [options.comma_color] | string |
"default" |
- |
| [options.comma_faint] | boolean |
true |
- |
| [options.bracket_color] | string |
"default" |
- |
| [options.bracket_faint] | boolean |
true |
- |
| [options.key_color] | string |
"white" |
- |
| [options.string_color] | string |
"yellow" |
- |
| [options.null_color] | string |
"cyan" |
- |
| [options.null_bold] | string |
true |
- |
| [options.true_color] | string |
"green" |
- |
| [options.false_color] | string |
"red" |
- |
| [options.number_color] | string |
"#810895" |
- |
Render a list of parsed tokens to a string
Kind: instance method of Renderer
Returns: string - The rendered string
| Param | Type | Description |
|---|---|---|
| tokens | Array.<object> |
The list of tokens to render |
Ingest a token for rendering
Kind: instance method of Renderer
| Param | Type | Description |
|---|---|---|
| token | object |
The token to render |
TODO
Kind: event emitted by Renderer
Render a list of parsed tokens to a string
Kind: static method of Renderer
Returns: string - The rendered string
| Param | Type | Description |
|---|---|---|
| tokens | Array.<object> |
The list of tokens to render |
| [opts] | object |
Options, @see Renderer.constructor |