You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
pdfy/lib/stream-contains.coffee

13 lines
352 B
CoffeeScript

Promise = require "bluebird"
concatStream = require "concat-stream"
buffertools = require "buffertools"
module.exports = (stream, needle) ->
# CAUTION: This buffers up in memory!
new Promise (resolve, reject) ->
stream
.pipe concatStream (result) ->
resolve buffertools.indexOf(result, needle) != -1
.on "error", (err) ->
reject err