jlongster / transducers.js

A small library for generalized transformation of data (inspired by Clojure's transducers)
BSD 2-Clause "Simplified" License
1.73k stars 54 forks source link

Let reducer transform arg if it's not a function #25

Closed Gozala closed 9 years ago

Gozala commented 9 years ago

Current transducers API is good, but I think it could be made better if it was:

var transform = compose(
  map(x => x * 3),
  filter(x => x % 2 === 0),
  take(2)
);

transform([1, 2, 3, 4, 5]);

Idea is to allow transducer transform given argument if it is not an xform.

Gozala commented 9 years ago

Ideally this would dispatch on the transform (or other) protocol so that channels and streams & signals would be able to take advantage of this rather then introducing their own API to transduce.

jlongster commented 9 years ago

Gozala has started his own lib with this API, as I was unsure about it: https://github.com/Gozala/transducers