
Security News
npm Introduces minimumReleaseAge and Bulk OIDC Configuration
npm rolls out a package release cooldown and scalable trusted publishing updates as ecosystem adoption of install safeguards grows.
Transducers for JavaScript using the transduce libraries. Collected as a convenience for an aggregated API. Any library below can be installed standalone and bundled seperately in browserify builds.
Compatible with and inspired by both transducers-js and transducers.js.
If you are not familiar with transducers, check out Transducers Explained.
Currently supports the following methods:
reduce: function(f, init, coll);
transduce: function(xf, f, init, coll);
into: function(to, xf, from);
toArray: function(xf?, coll);
compose: function(/*fns*/){}
// transducers
map: function(mappingFunction);
filter: function(predicate);
remove: function(predicate);
take: function(n);
takeWhile: function(predicate);
drop: function(n);
dropWhile: function(predicate);
cat: transducer
mapcat: function(f);
partitionAll: function(n);
partitionBy: function(f);
// iterator-protocol
isIterable: function(value);
isIterator: function(value);
iterable: function(value);
iterator: function(value);
// transformer-protocol
isTransformer: function(value){},
transformer: function(value){},
// transduce-reduced
isReduced: function(value){}
reduced: function(value, force?){}
unreduced: function(value){}
deref: unreduced
// transduce-util
protocols: {iterator, transformer}
isFunction: function(value){}
isArray: function(value){}
isString: function(value){}
isRegExp: function(value){}
isNumber: function(value){}
isUndefined: function(value){}
identity: function(value){}
arrayPush: function(arr, item){}
objectMerge: function(obj, item){}
stringAppend: function(str, item){}
Reduces over a transformation, f is converted to a transformer and coll is converted to an iterator using transduce-protocol. Arrays are special cased to reduce using for loop.
From transduce-reduce
Transduces over a transformation, f is converted to a transformer using transduce-protocol and the initialized transformer is passed to transduce-reduce.
From transduce-transduce
Returns a new collection appending all items into the empty collection to by passing all items from source collection from through the transformation xf. Chooses appropriate step function from type of to. Can be array, object, string or have @@transformer.
From transduce-into
Transduce a collection into an array with an optional transformation.
From transduce-toarray
Simple function composition of arguments. Useful for composing (combining) transducers.
From transduce-compose
Transducer that steps all items after applying a mappingFunction to each item.
From transduce-map
Transducer that steps items which pass predicate test.
From transduce-filter
Transducer that removes all items that pass predicate.
From transduce-remove
Transducer that steps first n items and then terminates with reduced.
From transduce-take
Transducer that take items until predicate returns true. Terminates with reduce when predicate returns true.
From transduce-takewhile
Transducer that drops first n items and steps remaining untouched.
From transduce-drop
Transducer that drops items until predicate returns true and steps remaining untouched.
From transduce-dropwhile
Concatenating transducer. Reducing over every item in the transformation using provided transformer.
From transduce-cat
Transducer that applies a mappingFunction to each item, then concatenates the result of the mapping function. Same is compose(map(mappingFunction), cat)
From transduce-mapcat
Partitions the source into arrays of size n. When transformer completes, the transformer will be stepped with any remaining items.
Partitions the source into sub arrays when the value of the function f changes equality. When transformer completes, the transformer will be stepped with any remaining items.
Mixes in all methods and iterator-protocol.
Does the parameter conform to the iterable protocol?
Returns the iterable for the parameter. Returns value if conforms to iterable protocol. Returns undefined if cannot return en iterable.
The return value will either conform to iterator protocol that can be invoked for iteration or will be undefined.
Supports anything that returns true for isIterable and converts arrays to iterables over each indexed item. Converts to functions to infinite iterables that always call function on next
Does the parameter have an iterator protocol or have a next method?
Returns the iterator for the parameter, invoking if has an iterator protocol or returning if has a next method. Returns undefined if cannot create an iterator.
The return value will either have a next function that can be invoked for iteration or will be undefined.
Supports anything that returns true for isIterator and converts arrays to iterators over each indexed item. Converts to functions to infinite iterators that always call function on next.
Mixes in all methods transformer-protocol.
Does the parameter have a transformer protocol or have init, step, result methods?
Attempts to convert the parameter into a transformer. If cannot be converted, returns undefined. If defined, the return value will have init, step, result methods that can be used for transformation. Converts arrays (arrayPush), strings (stringAppend), objects (objectMerge), functions (wrap as reducing function) or anything that isTransformer into a transformer.
Mixes in all methods from transduce-reduced.
Is the value reduced? (signal for early termination)
Ensures the value is reduced (useful for early termination). If force is not provided or false, only wraps with Reduced value if not already isReduced. If force is true, always wraps value with Reduced value.
Ensure the value is not reduced (unwraps reduced values if necessary)
Mixes in all methods from transduce-util.
Symbols (or strings that act as symbols) for @@iterator and @@transformer that you can use to configure your custom objects.
Always returns value
Array.push as a reducing function. Calls push and returns array;
Merges the item into the object. If item is an array of length 2, uses first (0 index) as the key and the second (1 index) as the value. Otherwise iterates over own properties of items and merges values with same keys into the result object.
Appends item onto result using +.
FAQs
JavaScript transducers and iterators
The npm package transduce receives a total of 41 weekly downloads. As such, transduce popularity was classified as not popular.
We found that transduce demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
npm rolls out a package release cooldown and scalable trusted publishing updates as ecosystem adoption of install safeguards grows.

Security News
AI agents are writing more code than ever, and that's creating new supply chain risks. Feross joins the Risky Business Podcast to break down what that means for open source security.

Research
/Security News
Socket uncovered four malicious NuGet packages targeting ASP.NET apps, using a typosquatted dropper and localhost proxy to steal Identity data and backdoor apps.