-
-
Save creationix/f43c29e3e6da09e4f8b6 to your computer and use it in GitHub Desktop.
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
function transform(emit) { | |
// any state kept between input chunks will be setup here | |
return function (item) { | |
// Forward the EOS marker | |
if (item === undefined) return emit(); | |
// Skip cheese items | |
if (item === "cheese") return; | |
// Double anything else | |
emit(item); | |
emit(item); | |
// This example is silly, but it shows that you can call emit 0 or more times for every item input. | |
}; | |
} | |
someObject.on("data", transform(function (out) { | |
// every data event will run through the filter and emit here. | |
})); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment