Home
Docs
GitHub
Pricing
Blog
Log In

Run Sandworm Audit for your App

Get started
Hold on, we're currently generating a fresh version of this report
Generated on May 6, 2024 via pnpm

split2 4.2.0

split a Text Stream into a Line Stream, using Stream 3
Package summary
Share
0
issues
1
license
1
ISC
Package created
12 Mar 2014
Version published
26 Mar 2023
Maintainers
1
Total deps
1
Direct deps
0
License
ISC

Issues

0
This package has no issues

Licenses

ISC License

Permissive
OSI Approved
This is a human-readable summary of (and not a substitute for) the license. Disclaimer.
Can
commercial-use
modify
distribute
Cannot
hold-liable
Must
include-copyright
include-license
1 Packages, Including:
split2@4.2.0
Disclaimer

This deed highlights only some of the key features and terms of the actual license. It is not a license and has no legal value. You should carefully review all of the terms and conditions of the actual license before using the licensed material.

Sandworm is not a law firm and does not provide legal services. Distributing, displaying, or linking to this deed or the license that it summarizes does not create a lawyer-client or any other relationship.

Direct Dependencies

0
All Dependencies CSV
β“˜ This is a list of split2 's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.
NameVersionSizeLicenseTypeVulnerabilities

Visualizations

Frequently Asked Questions

What does split2 do?

Split2 is a powerful Node.js module designed to break up a stream and reassemble it in a way where each line is a standalone chunk. Drawing inspiration from the Split module developed by Dominic Tarr, Split2 differs by utilizing the Transform API from Node.js core rather than operating independently. The functionality of Split2 is versatile as it accepts Strings or RegEx as matcher parameters.

How do you use split2?

To incorporate Split2 into your project, begin by installing the npm package. After ensuring the module is included in your file with var split2 = require('split2');, you can then use it as a pipe in a stream of data. The following JS snippet displays every line in a file as a separate chunk:

var fs = require('fs');
var split2 = require('split2');

fs.createReadStream('my_file.txt')
    .pipe(split2())
    .on('data', function (line) {
        console.log(line); // Outputs each line from 'my_file.txt'
    });

Split2 also provides a way to handle potential errors, you just need to add an 'error' event listener on your stream:

fs.createReadStream('my_file.txt')
    .pipe(split2())
    .on('data', function (line) {
        console.log(line); // Outputs each line from 'my_file.txt'
    })
    .on('error', function (err) {
        console.error(err); // Outputs any error that occurred 
    });

And if you're working with JSON objects in a Newline Delimited Json (NDJ) format, Split2 can handle that too. By using JSON.parse, the module transforms each line into an object:

fs.createReadStream('my_file.ndjson')
  .pipe(split2(JSON.parse))
  .on('data', function (obj) {
    console.log(obj); // Outputs each JSON object from 'my_file.ndjson'
  })
  .on('error', function (error) {
    console.error(error); // Outputs any error that occurred
  });

Where are the split2 docs?

To access the Split2 documentation, you can head over to GitHub repository. The readme file provides comprehensive instructions and examples to get you started. As a reference guide, it includes details about its implementation, compatibility, optional settings, NDJ support, and error handling procedures. If String splitting parameters are of interest, be sure to review the MDN web docs linked directly in the readme.