onmatch

1.0.0 • Public • Published

onmatch

Build Status

Watch streams for patterns.

import onMatch from 'onmatch'
 
const pattern = /start.*end/
const handleMatch = (match) => {}
 
const stream = onMatch(pattern)
stream.on('match', handleMatch)
 
stream.write('foo')
stream.write('bar', 'ascii')
stream.write(Buffer.from('start')) // assumed to be utf8
stream.write('boop')
stream.write('end') // handleMatch('startboopend')

You'd probably want to pipe the incoming stream in practice.

const stream = onMatch(pattern)
stream.on('match', handleMatch)
readable.pipe(stream)

/onmatch/

    Package Sidebar

    Install

    npm i onmatch

    Weekly Downloads

    1

    Version

    1.0.0

    License

    ISC

    Unpacked Size

    2.68 kB

    Total Files

    3

    Last publish

    Collaborators

    • reergymerej