Skip to content

Latest commit

 

History

History
105 lines (64 loc) · 2.71 KB

api.md

File metadata and controls

105 lines (64 loc) · 2.71 KB

Table of Contents

createParseStream

Create a JSON.parse that uses a stream interface. The underlying implementation is handled by JSONStream. This is merely a thin wrapper for convenience that handles the reconstruction/accumulation of each individually parsed field.

The advantage of this approach is that by also using a streams interface, any JSON parsing or stringification of large objects won't block the CPU.

Returns Stream

createStringifyStream

create a JSON.stringify readable stream.

Parameters

  • opts Object an options object
    • opts.body Object the JS object to JSON.stringify

Returns Stream

_parse

stream based JSON.parse. async function signature to abstract over streams.

Parameters

  • opts Object options to pass to parse stream
  • callback Function a callback function

Returns (Object | Array) the parsed JSON

parse

stream based JSON.parse. async function signature to abstract over streams. variadic arguments to support both promise and callback based usage.

Parameters

  • opts Object options to pass to parse stream
    • opts.body String string to parse
  • callback Function? a callback function. if empty, returns a promise.

Returns (Object | Array) the parsed JSON

stringify

stream based JSON.stringify. async function signature to abstract over streams. variadic arguments to support both promise and callback based usage.

Parameters

  • opts Object options to pass to stringify stream
  • callback Function? a callback function. if empty, returns a promise.

Returns Object the parsed JSON object