-
-
Save 1N50MN14/afe1b2b94fb5a8acae2a to your computer and use it in GitHub Desktop.
binarize-stream
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var binarize = require('binarize.js') | |
var es = require('event-stream') | |
function createEncodeStream() { | |
var stream | |
return stream = es.through(function (data) { | |
binarize.pack(data, function(r) { | |
stream.emit('data', r.buffer) | |
}); | |
}) | |
} | |
function createDecodeStream() { | |
var stream | |
return stream = es.through(function (data) { | |
binarize.unpack(data, function(r) { | |
stream.emit('data', r) | |
}) | |
}) | |
} | |
exports.getStream = function(stream) { | |
return es.pipeline(createDecodeStream(), stream, createEncodeStream()) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment