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

each-part

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

each-part

Transform stream which emits each part and pushes object with part

  • 0.9.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

each-part

Build Status Dependency Status npm version

Transform stream which emits each part and pushes object with part.

Uses newline and carriage return for default delimiter (one or both in either order).

Install

npm install each-part --save

Usage

buildEach = require 'each-part'

# uses newline or carriage return by default
# outputs `part` object by default, which contains `string` and `delim`
eachLine = buildEach()

eachLine.on 'part', (part, delim) ->
  # do something with the part.
  # when readableObjectMode is true, the default, then `part` is an object
  # with two properties: `string` and `delim`
  # when it's not true (you specify it as false in options) then `part` is the
  # string. The second arg is always `delim`

eachLine.on 'error', (error) -> # do something with the error...

eachLine.on 'finish', (error) -> # all done...

# part is also passed on as an object to the next stream using objectMode:true
targetStream = require('through2') (part, _, next) ->
  # do something with the part: part.string
  console.log 'part:',part.string
  next()

someStream.pipe(eachLine)

# can provide options to override the delimiter used:
eachPipe = buildEach delim:'|'

# can be a regular expression:
eachBlah = buildEach delim:/blah/


# to pass `string` to the next stream, set readableObjectMode to false:
eachLine = buildEach readableObjectMode:false
# when you do that, then:
#   1. the stream it pipes to will receive strings as chunks
#   2. the 'part' event will provide the string as the first arg, not an object
#  Note: this means the next stream will not know the delimiter found

MIT License

FAQs

Package last updated on 02 Oct 2016

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