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

split

Package Overview
Dependencies
Maintainers
1
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

split

split a Text Stream into a Line Stream

  • 1.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
6.6M
decreased by-27.41%
Maintainers
1
Weekly downloads
 
Created

What is split?

The 'split' npm package is a stream utility that splits a stream of data into a stream of lines or any other delimited chunks. It's useful for processing streams of text data, such as logs or other outputs that are line-delimited.

What are split's main functionalities?

Splitting stream by newlines

This code sample demonstrates how to use the 'split' package to read data from the standard input and split it into lines. Each line is then logged to the console.

"use strict";
const split = require('split');
process.stdin.pipe(split()).on('data', function (line) {
  console.log('Line: ' + line);
});

Custom delimiter

This code sample shows how to use a custom delimiter (';') to split the stream into chunks. Each chunk is logged to the console.

"use strict";
const split = require('split');
process.stdin.pipe(split(';')).on('data', function (chunk) {
  console.log('Chunk: ' + chunk);
});

Mapping lines

This code sample uses the 'split' package to map each line of the input to uppercase before emitting it. The mapped lines are logged to the console.

"use strict";
const split = require('split');
function map(line) {
  return line.toUpperCase();
}
process.stdin.pipe(split(map)).on('data', function (line) {
  console.log('Mapped Line: ' + line);
});

Other packages similar to split

FAQs

Package last updated on 03 Aug 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