lazy.js icon indicating copy to clipboard operation
lazy.js copied to clipboard

auto-curried, data-last functions

Open graingert opened this issue 8 years ago • 4 comments

Like lodash/fp but lazy, or https://github.com/ReactiveX/IxJS

graingert avatar Nov 09 '17 15:11 graingert

Could you elaborate on what you mean by "auto-curried"? Is this essentially a duplicate of #24?

dtao avatar Feb 05 '18 16:02 dtao

@dtao no not sure what that's about. I'm talking:

var result = Lazy(people)
  .pluck('lastName')
  .filter(function(name) { return name.startsWith('Smith'); })
  .take(5);

becomes:

var result = l.flow(
  l.pluck('lastName'),
  l.filter(function(name) { return name.startsWith('Smith'); }),
  l.take(5),
)(people)

graingert avatar Feb 05 '18 17:02 graingert

Ah, gotcha. Yes, someone asked about something similar before... unfortunately I can't seem to find it.

Anyway, I think something like this exists already. It is called apply():

var result = Lazy([])
  .pluck('lastName'),
  .filter(function(name) { return name.startsWith('Smith'); }),
  .take(5)
  .apply(people);

Granted, this interface is very odd (passing in an empty array initially—weird); and the implementation is very hacky. I'm not pleased with it at all. But it does exist.

Probably I will consider changing how this works and introducing something more like what you've suggested in a future version.

dtao avatar Feb 05 '18 18:02 dtao

Those are methods. I'm looking for something like lodash/fp

On 5 Feb 2018 18:21, "Dan Tao" [email protected] wrote:

Ah, gotcha. Yes, someone asked about something similar before... unfortunately I can't seem to find it.

Anyway, I think something like this exists already. It is called apply():

var result = Lazy([]) .pluck('lastName'), .filter(function(name) { return name.startsWith('Smith'); }), .take(5) .apply(people);

Granted, this interface is very odd (passing in an empty array initially—weird); and the implementation is very hacky. I'm not pleased with it at all. But it does exist.

Probably I will consider changing how this works and introducing something more like what you've suggested in a future version.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/dtao/lazy.js/issues/215#issuecomment-363173803, or mute the thread https://github.com/notifications/unsubscribe-auth/AAZQTFpZ0Zyy8Wb8V7lK5OdK83p3JCgXks5tR0azgaJpZM4QYJRU .

graingert avatar Feb 05 '18 18:02 graingert