1.1.3 • Published 6 years ago

match-through v1.1.3

Weekly downloads
4
License
WTFPL
Repository
github
Last release
6 years ago

match-through

Match on patterns in a stream

npm Node version Build Status JavaScript Style Guide

  • Pipe data through a stream and get notified when something matches
  • Match once or multiple times

Install

$ npm install match-through --save

Usage

Print out the total file size in the current directory.

var match = require('match-through')
var spawn = require('child_process').spawn
spawn('ls', [ '-lh' ]).stdout.pipe(match(/^total\s+(\S+)/, function (m) {
  console.log(m[1])
})).pipe(process.stdout)

Api

match(opts, iter)

Returns a through stream that calls back when a regular expression is matched. Does nothing with the data passing through so it's a pure pass through stream.

  • opts (object|regex) Either options object with .regex and .matchAll properties or a single regular expression.
  • iter (function) Called when there is a match. Will call multiple times if there are several matches and .matchAll property is true. If opts is a regular expression the callback will be called at the first match only, if ever.

License

All code, unless stated otherwise, is licensed under the WTFPL.

1.1.3

6 years ago

1.1.2

6 years ago

1.1.1

7 years ago

1.1.0

9 years ago

1.0.2

9 years ago

1.0.1

9 years ago

1.0.0

9 years ago