Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

json-yieldify

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

json-yieldify

an async JSON.stringify that yields periodically to the event loop

  • 1.0.4
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

node-json-yieldify

An async JSON.stringify that yields periodically to the event loop.

const JsonYieldify = require('json-yieldify');

JsonYieldify.stringify({greetings: 'Hello!'}, (err, json) => {
  if (err) return cb(err);
  // json = {"greetings":"Hello!"}
});

Installation

$ npm install json-yieldify

Features

  • JSON.stringify that doesn't block the event loop
  • Supports the replacer argument
  • Supports the space argument (pretty-print)
  • Handles arbitrarily complex arrays and object graphs

Planned

  • Readable stream signature
  • Writeable stream signature (like JSONStream, but the values can be aribtrarily large)

API

A single function is exported.

JsonYieldify.stringify(value[, replacer[, space]], cb)

The first three arguments are identical to the native JSON.stringify. The final argument is a Node-style callback (e.g. (err, json) =>).

See here for an explanation of the JSON.stringify arguments.

Mutating the value while the function is running results in undefined behavior.

Alternatives

There are some other options in this space that may better meet your requirements.

  • If you are streaming a large array of small JavaScript values (e.g. rows from a Postgres table), you should use JSONStream.

Keywords

FAQs

Package last updated on 31 Mar 2017

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc