Questions tagged [highland.js]

The high-level streams library for Node.js and the browser.

Re-thinking the JavaScript utility belt, Highland manages synchronous and asynchronous code easily, using nothing more than standard JavaScript and Node-like Streams. You may be familiar with Promises, EventEmitters and callbacks, but moving between them is far from seamless. Thankfully, there exists a deeper abstraction which can free our code. By updating the tools we use on Arrays, and applying them to values distributed in time instead of space, we can discard plumbing and focus on the important things. With Highland, you can switch between synchronous and asynchronous data sources at will, without having to re-write your code.

76 questions
12
votes
2 answers

What are the differentiating features between Highland.js, Kefir.js, and Rx.js?

Since subjective answers are to be avoided on SO, I'm specifically asking: What are the functional and/or performance differences between these three functional/reactive libraries that would make me choose one of them over the others? I have…
Ville
  • 3,657
  • 1
  • 32
  • 36
12
votes
1 answer

how to destroy a highland stream

I have the following example const input = _(); const output = _() .each(x => console.log('out', x)); input .pipe(output); input.write(1) output.destroy(); input.write(2); As far as I can read in the documentation…
Andreas Møller
  • 819
  • 5
  • 9
9
votes
3 answers

mocha with nodejs assert hangs/timeouts for assert(false) instead of error

I have this kind of a mocha test: describe 'sabah', → beforeEach → @sabahStrategy = _.filter(@strats, { name: 'sabah2' })[0] .strat it 'article list should be populated', (done) → @timeout 10000 strat =…
user3995789
  • 3,382
  • 1
  • 15
  • 29
8
votes
2 answers

Circular data flow in highlandjs

I'm just learning highland.js after being inspired by NoFlo.js. I want to be able to have streams operate recursively. In this contrived example I will provide a number that get's multiplied by two and we filter results <= 512. Once the number is…
Michael Connor
  • 3,752
  • 21
  • 21
6
votes
1 answer

Reduce nodejs application memory using stream?

This is probably a newbie question but I searched and couldn't find a satisfying answer. My node.js application seems to consume a lot of memory. Each process consumes about 100MB. I heard that nodejs itself has a ~30MB memory footprint per…
yichen
  • 511
  • 1
  • 7
  • 14
5
votes
1 answer

How can I throttle a Highland.js or Node.js stream to one object per second?

I'd like to be able to throttle the calls to getPagerank() to one per second. I've tried various things but can't get it to work. var pagerank = require('pagerank'); var _ = require('highland'); var urls = [ 'google.com', 'yahoo.com', …
Jason
  • 10,825
  • 23
  • 72
  • 128
5
votes
2 answers

Async Map with Highland.js

I have a Highland stream that is periodically getting data from a server. I need to do a database lookup inside of a map. I can't find any mention of doing anything async in any of Highland's transformers.
giodamelio
  • 4,885
  • 14
  • 39
  • 70
4
votes
2 answers

How do I resolve promises within stream?

I have a highland stream in which each element is a promise for a get request: const stream = _[promise1, promise2, promise3, ...]; so of course when I run: const stream.each(console.log) I only see: Promise { } Promise {
k0pernikus
  • 41,137
  • 49
  • 170
  • 286
3
votes
1 answer

Highland.js for CSV parsing

I'm trying to write a very functional manner. We're using Highland.js for managing the stream processing, however because I'm so new I think I'm getting really confused with how I can deal with this unique situation. The issue here is that all the…
ddibiase
  • 1,192
  • 1
  • 12
  • 31
3
votes
2 answers

Slowing stream down to one chunk per second

I have a highland stream that is reading a file line by line, and I want to slow it down to one chunk per second. I have looked through the docs, and the only functions I found were throttle() and debounce(). Both of those drop values. I need to…
giodamelio
  • 4,885
  • 14
  • 39
  • 70
3
votes
2 answers

How to use errors in highland.js map

This function var _ = require('highland'); var accounts = ['ack', 'bar', 'foo']; _(accounts).map(function (x) { return new Error(x); }).errors(function (err, push) { push(null, 'fark'); }).each(function (x) { console.log(x); }); logs [Error:…
Jehan
  • 2,451
  • 2
  • 18
  • 27
2
votes
0 answers

handling back pressure with mongoose while retrieving documents

I'm using highland to handle back pressure. My code is: const pipeline = [{ $match: { 'published': true, status: 'Approved' } }]; const cursor = UserModel.aggregate(pipeline) .cursor().exec(); //…
Sandeep Sharma
  • 1,537
  • 2
  • 12
  • 33
2
votes
2 answers

How to iterate over array of objects using oboe?

I have a json response in the form of: [{ "id": 425055, "title": "Foo" }, { "id": 425038, "title": "Bar" }, { "id": 425015, "title": "Narf" }] I use oboe.js to create a highland stream: const cruiseNidStream = _((push, next) => { …
k0pernikus
  • 41,137
  • 49
  • 170
  • 286
2
votes
1 answer

How can I read a stream of JSON objects into browser

Given a node.js style object stream as the example below shows, how can this be read by an http request on a webpage and processed: {"id":"one", "value":"the first object"} {"id":"two", "value":"the second object"} {"id":"three", "value":"the…
Fergie
  • 4,643
  • 5
  • 34
  • 40
2
votes
2 answers

streaming from large files and creating an array

I'm having problems with highland.js. I need to create an array of functions from my stream data, but can't get it to work. Here's my code, however requests is always empty. var requests = []; _(fs.createReadStream("small.txt", {…
user1513388
  • 6,151
  • 8
  • 52
  • 98
1
2 3 4 5 6