take(x) 'takes' nothing when emitted exactly x elements #14

Open
salty-horse opened this Issue Jan 24, 2012 · 4 comments

Comments

Projects
None yet
2 participants
@salty-horse
Contributor

salty-horse commented Jan 24, 2012

This is a modified example from the readme.txt:

var Lazy = require('lazy');

var lazy = new Lazy;
lazy
  .take(4)
  .join(function (xs) {
    console.log(xs);
  });

// OK when there are five elements. Prints nothing when there are 4
[1,2,3,4].forEach(function (x) {
  lazy.emit('data', x);
});
@pkrumins

This comment has been minimized.

Show comment Hide comment
@pkrumins

pkrumins Jan 29, 2012

Owner

I wonder if it's because you never sent 'end' event?

Owner

pkrumins commented Jan 29, 2012

I wonder if it's because you never sent 'end' event?

@salty-horse

This comment has been minimized.

Show comment Hide comment
@salty-horse

salty-horse Jan 29, 2012

Contributor

lazy.emit('end') after the 4 'data' emits doesn't seem to help.

Frankly, I'm new to node and its conventions, and the Lazy documentation seems to assume some background knowledge.
If you don't think it's a bug, maybe you could clarify how Lazy behaves with events?

Contributor

salty-horse commented Jan 29, 2012

lazy.emit('end') after the 4 'data' emits doesn't seem to help.

Frankly, I'm new to node and its conventions, and the Lazy documentation seems to assume some background knowledge.
If you don't think it's a bug, maybe you could clarify how Lazy behaves with events?

@pkrumins

This comment has been minimized.

Show comment Hide comment
@pkrumins

pkrumins Jan 29, 2012

Owner

It's a bug then! I'm gonna fix it.

re events: basically lazy eats 'data' events and terminates processing when it receives 'end' event.

Owner

pkrumins commented Jan 29, 2012

It's a bug then! I'm gonna fix it.

re events: basically lazy eats 'data' events and terminates processing when it receives 'end' event.

@salty-horse

This comment has been minimized.

Show comment Hide comment
@salty-horse

salty-horse Jan 29, 2012

Contributor

Correction: emit('end') works. Sorry :/ (I probably forgot to save the file before testing)

Just to understand, why does take(x) have to wait for an 'end' if it already received x elements?

Contributor

salty-horse commented Jan 29, 2012

Correction: emit('end') works. Sorry :/ (I probably forgot to save the file before testing)

Just to understand, why does take(x) have to wait for an 'end' if it already received x elements?

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