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

Fix iterator protocol support + npm build scripts #44

Open jaawerth opened 7 years ago

jaawerth commented 7 years ago

closes #37 replaces #38

Ensured that the .iterator and .toIter methods are compliant with iterator-protocol by adding a self-returning Symbol.iterator/@@iterator method to all returned iterators, rather than just those produced by LazyTransformer. Also added some additional tests to make sure it checks iterators produced from LazyTransformer and WrappedIterator.

I noticed that dist/transducers.js was already out of date compared to the source code, so I had also added some build and test scripts, as well as a prepublish script to ensure dist is built before it's published. Let me know if you'd rather that go in a separate PR and I'll gladly remove them, but I figured it would help keep things in sync between the module/global versions. I didn't check in a new version of dist/transducers.js, though.

ScriptedAlchemy commented 5 years ago

Due to abandonment, I’ve forked this and am actively working on it.

One thing I’d love is the ability to replace the prototype chain with these. So people doesn’t need to know that performance is drastically improved. https://github.com/ScriptedAlchemy/fast-transducers

jaawerth commented 2 years ago

@ScriptedAlchemy Now that I'm back to being knee-deep in JS-land and finding it hard to find a transducer library that's both tiny and maintained (and with an API that desn't drop me into weird typescript config object0 I finally realized I missed your comment after being like "welp, might as well work from my stale PR." i even saw your package in npm, just hadn't looked into it yet 😆

Anyway, sorry it took me 3 years to notice it, but thanks for dropping me the note!