
Product
Introducing Custom Tabs for Org Alerts
Create and share saved alert views with custom tabs on the org alerts page, making it easier for teams to return to consistent, named filter sets.
json-format-stream
Advanced tools
Streaming JSON serializer that allows you to add metadata and will forward an error message if the stream is destroyed prematurely
Streaming JSON serializer that allows you to add metadata and will forward an error message if the stream is destroyed prematurely
npm install json-format-stream
var format = require('json-format-stream')
var stream = format({some: 'metadata'})
stream.write({some: 'data'})
stream.write({more: 'data'})
stream.destroy(new Error('an error occurred'))
stream.pipe(process.stdout)
Running the above will print out
{
"some": "metadata",
"result": [
{
"some": "data"
},
{
"more": "data"
}
],
"error": "an error occurred"
}
If you don't call destroy the error property in the result will be set to null when the stream finishes.
The main result is streamed using JSONStream which makes this memory efficient
stream = format(metadata, options)Creates a new JSON formatter. Any metadata properties you provide in the constructor will be set in the beginning of the JSON response.
Pass options.outputKey to specify which key data is added to. Defaults to result.
var stream = format(null, {outputKey: 'data'})
MIT
FAQs
Streaming JSON serializer that allows you to add metadata and will forward an error message if the stream is destroyed prematurely
We found that json-format-stream demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Product
Create and share saved alert views with custom tabs on the org alerts page, making it easier for teams to return to consistent, named filter sets.

Product
Socket’s Rust and Cargo support is now generally available, providing dependency analysis and supply chain visibility for Rust projects.

Security News
Chrome 144 introduces the Temporal API, a modern approach to date and time handling designed to fix long-standing issues with JavaScript’s Date object.