Socket
Socket
Sign inDemoInstall

ldjson-stream

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

ldjson-stream

streaming line delimited json parser + serializer


Version published
Maintainers
1
Created

What is ldjson-stream?

The ldjson-stream npm package is designed to handle line-delimited JSON (LDJSON) streams. It provides utilities for parsing and stringifying LDJSON data, which is useful for processing large datasets in a memory-efficient manner.

What are ldjson-stream's main functionalities?

Parsing LDJSON

This feature allows you to parse a stream of line-delimited JSON data. The code sample reads from a file named 'data.ldjson' and parses each line as a JSON object, logging each object to the console.

const ldjson = require('ldjson-stream');
const fs = require('fs');

fs.createReadStream('data.ldjson')
  .pipe(ldjson.parse())
  .on('data', obj => {
    console.log(obj);
  });

Stringifying LDJSON

This feature allows you to stringify a stream of JSON objects into line-delimited JSON format. The code sample takes an array of objects and writes them to a file named 'output.ldjson' in LDJSON format.

const ldjson = require('ldjson-stream');
const fs = require('fs');

const data = [
  { name: 'Alice', age: 30 },
  { name: 'Bob', age: 25 }
];

const writeStream = fs.createWriteStream('output.ldjson');
const stringifyStream = ldjson.serialize();

stringifyStream.pipe(writeStream);
data.forEach(item => stringifyStream.write(item));
stringifyStream.end();

Other packages similar to ldjson-stream

FAQs

Package last updated on 12 Aug 2014

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