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 Apr 29, 2024 via pnpm

split 1.0.1

split a Text Stream into a Line Stream
Package summary
Share
0
issues
1
license
2
MIT
Package created
30 Aug 2012
Version published
3 Aug 2017
Maintainers
1
Total deps
2
Direct deps
1
License
MIT

Issues

0
This package has no issues

Licenses

MIT License

Permissive
OSI Approved
This is a human-readable summary of (and not a substitute for) the license. Disclaimer.
Can
commercial-use
modify
distribute
sublicense
private-use
Cannot
hold-liable
Must
include-copyright
include-license
2 Packages, Including:
split@1.0.1
through@2.3.8
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

1
All Dependencies CSV
β“˜ This is a list of split 's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.
NameVersionSizeLicenseTypeVulnerabilities
through2.3.84.36 kBMIT
prod

Visualizations

Frequently Asked Questions

What does split do?

Split is an npm package that works as a stream utility to split a text stream into a line stream. This is particularly useful when dealing with a large amount of data that needs line-by-line processing. The matcher for the split can be a string or a regular expression, offering flexibility in defining the chunk separators.

How do you use split?

To utilize the Split package in JavaScript, you'll first need to install it via npm, using npm install split. Then, you can import and use it in your code. Here is a basic example of reading every line from a file:

const fs = require('fs');
const split = require('split');

fs.createReadStream('yourfile.txt')
  .pipe(split())
  .on('data', function (line) {
    // Each chunk is now a separate line of data!
    console.log(line);
  });

Split also accepts optional parameters allowing you to define a maximum buffer length and whether the last buffer not delimited by a newline or matcher should be emitted. It also allows you to transform each emitted line with a provided function such as JSON.parse:

fs.createReadStream('yourfile.json')
  .pipe(split(JSON.parse))
  .on('data', function (obj) {
    // Each emitted chunk is now a JavaScript object
    console.log(obj);
  })
  .on('error', function (err) {
    // Syntax errors will be handled here
    console.log(err);
  });

Where are the split docs?

Split's detailed documentation on how to use the package with various options and examples can be found the official GitHub repository. For quicker reference, developers can also look at JavaScript's String#split documentation, which offers a similar usage to the package. Being adept with Split will be beneficial to developers working with stream data, making the process of separating and analyzing such data much more efficient and manageable.