Created
February 22, 2014 10:35
-
-
Save riston/9151793 to your computer and use it in GitHub Desktop.
Highland 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 _ = require('highland'), | |
request = require('request'); | |
// This works but not using the stream approach | |
// function get(path) { | |
// return _(function (push, next) { | |
// request(path, function (error, response, body) { | |
// // The response itself also contains the body | |
// push(error, response); | |
// push(null, _.nil); | |
// }); | |
// }); | |
// } | |
var google = _(request.get('https://www.google.com')); | |
// res is empty array | |
.map(function (res) { | |
console.log(res); | |
}) | |
// res is empty array | |
.toArray(function (res) { | |
console.log(res); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment