Skip to content

Instantly share code, notes, and snippets.

@riston
Created February 22, 2014 10:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save riston/9151793 to your computer and use it in GitHub Desktop.
Save riston/9151793 to your computer and use it in GitHub Desktop.
Highland stream
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'));
google
// 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