Skip to content

Instantly share code, notes, and snippets.

@danmactough
Created December 2, 2013 17:21
Show Gist options
  • Save danmactough/7753019 to your computer and use it in GitHub Desktop.
Save danmactough/7753019 to your computer and use it in GitHub Desktop.
Pseudo-code for conditional piping
var feed = 'http://somefeed.com/rss'
var req = request(feed)
req.on('response', function (response) {
if (sometest(feed)) {
req.pipe(iconv).pipe(parser)
}
else {
req.pipe(parser)
}
})
@danmactough
Copy link
Author

The condition could also be something like, response.statusCode === 200.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment