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

bfj

Package Overview
Dependencies
Maintainers
0
Versions
48
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bfj

Big-friendly JSON. Asynchronous streaming functions for large JSON data sets.

  • 9.1.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
4M
increased by5.26%
Maintainers
0
Weekly downloads
 
Created

What is bfj?

The bfj (Big Friendly JSON) npm package is designed to handle large JSON files efficiently. It provides functions to parse and stringify JSON asynchronously, which helps in managing large datasets without blocking the Node.js event loop. This is particularly useful for server-side applications where performance and non-blocking operations are critical.

What are bfj's main functionalities?

Parse JSON asynchronously

This feature allows asynchronous parsing of JSON files. The 'read' method returns a promise that resolves with the parsed JSON data, making it suitable for large files that could block the event loop if parsed synchronously.

const bfj = require('bfj');
bfj.read('./large-file.json').then(data => {
  console.log(data);
}).catch(err => {
  console.error('Error parsing JSON!', err);
});

Stringify JSON asynchronously

This feature allows for asynchronous JSON stringification. The 'write' method writes JSON data to a file asynchronously and returns a promise, which is useful for handling large amounts of data without freezing the server.

const bfj = require('bfj');
const data = { large: 'data' };
bfj.write('./output.json', data).then(() => {
  console.log('Data has been written successfully');
}).catch(err => {
  console.error('Error writing JSON!', err);
});

Stream JSON data

This feature supports streaming JSON data using 'walk', which processes a stream of JSON data and returns a promise. It is ideal for processing data that is too large to fit into memory all at once.

const bfj = require('bfj');
const fs = require('fs');
const stream = fs.createReadStream('large-input.json');
bfj.walk(stream).then(data => {
  console.log('Streamed JSON data:', data);
}).catch(err => {
  console.error('Error streaming JSON!', err);
});

Other packages similar to bfj

Keywords

FAQs

Package last updated on 20 Oct 2024

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