node package manager

Introducing npm Enterprise add-ons. Integrate third-party dev tools into npm…


A transform stream which segregates a sentinel value into its own 'data' event.


A transform stream that finds a sentinal value in a data stream, and then emits it as a seperate data event.

Any time you want to take a particular action if a certain value appears in a stream, e.g. splitting a stream, stopping a stream early, etc.

sentinal = new Sentinal(sep) returns a transform stream. sep is a buffered string. It will be stored on sentinal.seperator.


var Sentinal = require('sentinal-stream')
  , through = require('through') // 
  , from = require('from') // 
  , sentence = ''
var periods = new Sentinal(new Buffer('|||'))
var source = from([
    '||| is the delimiter.'
  , ' Sometimes it fits|||'
  , 'Sometimes it might take'
  , 'more than one line|||'
  , 'Look||| two per chunk|||'
  , '||| or ||| even ||| three!'
  , 'And sometimes only part ||'
  , '| Of the separator fits.'
var gather_wipe = through(function(data) {
  if(data === periods.seperator) {
    sentence && console.log(sentence + '.')
    sentence = ''
  sentence += data 


is the delimiter. Sometimes it fits.
Sometimes it might take more than one line.
Look. two per chunk.
or even three! And sometimes only part .
 Of the seperator fits.