
Research
TeamPCP Compromises Telnyx Python SDK to Deliver Credential-Stealing Malware
Malicious versions of the Telnyx Python SDK on PyPI delivered credential-stealing malware via a multi-stage supply chain attack.
Transducers for JavaScript. Collected as a convenience for an aggregated API. Any function or transducer below can be bundled seperately in browserify builds by requiring with path from transduce.
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)
// base 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)
// array
forEach: function(callback)
find: function(predicate)
push: function(/*args*/)
unshift: function(/*args*/)
every: function(predicate)
some: function(predicate)
contains: function(target)
slice: function(begin?, end?)
initial: function(n?)
last: function(n?)
// math
min: function(f?)
max: function(f?)
// push
tap: function(interceptor)
asCallback: function(xf, reducer)
asyncCallback: function(xf, continuation, reducer)
// string
split: function(separator, limit)
join: function(separator)
nonEmpty: function()
lines: function(limit)
chars: function(limit)
words: function(delimiter, limit)
// unique
dedupe: function();
unique: function(f?);
// iterator
isIterable: function(value)
isIterator: function(value)
iterable: function(value)
iterator: function(value)
// transformer
isTransformer: function(value)
transformer: function(value)
// util
compose: function(/*fns*/)
isReduced: function(value)
reduced: function(value, force?)
unreduced: function(value)
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. Arrays are special cased to reduce using for loop.
Transduces over a transformation, f is converted to a transformer and the initialized transformer is passed to reduce.
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.
Transduce a collection into an array with an optional transformation.
Transducer that steps all items after applying a mappingFunction to each item.
Transducer that steps items which pass predicate test.
Transducer that removes all items that pass predicate.
Transducer that steps first n items and then terminates with reduced.
Transducer that take items until predicate returns true. Terminates with reduce when predicate returns true.
Transducer that drops first n items and steps remaining untouched.
Transducer that drops items until predicate returns true and steps remaining untouched.
Concatenating transducer. Reducing over every item in the transformation using provided transformer.
Transducer that applies a mappingFunction to each item, then concatenates the result of the mapping function. Same is compose(map(mappingFunction), cat)
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.
Use Array methods as Transducers. Treats each stepped item as an item in the array, and defines transducers that step items with the same contract as array methods.
Passes every item through unchanged, but after executing callback(item, idx). Can be useful for "tapping into" composed transducer pipelines. The return value of the callback is ignored, item is passed unchanged.
Like filter, but terminates transducer pipeline with the result of the first item that passes the predicate test. Will always step either 0 (if not found) or 1 (if found) values.
Passes all items straight through until the result is requested. Once completed, steps every argument through the pipeline, before returning the result. This effectively pushes values on the end of the stream.
Before stepping the first item, steps all arguments through the pipeline, then passes every item through unchanged. This effectively unshifts values onto the beginning of the stream.
Checks to see if every item passes the predicate test. Steps a single item true or false. Early termination on false.
Checks to see if some item passes the predicate test. Steps a single item true or false. Early termination on true.
Does the stream contain the target value (target === item)? Steps a single item true or false. Early termination on true.
Like array slice, but with transducers. Steps items between begin (inclusive) and end (exclusive). If either index is negative, indexes from end of transformation. If end is undefined, steps until result of transformation. If begin is undefined, begins at 0.
Note that if either index is negative, items will be buffered until completion.
Steps everything but the last entry. Passing n will step all values excluding the last N.
Note that no items will be sent and all items will be buffered until completion.
Step the last element. Passing n will step the last N values.
Note that no items will be sent until completion.
Steps the min/max value on the result of the transformation. if f is provided, it is called with each item and the return value is used to compare values. Otherwise, the items are compared as numbers
Normally transducers are used with pull streams: reduce "pulls" values out of an array, iterator, etc. This library adds basic support for using transducers with push streams. See transduce-stream for using transducers with Node.js streams, or the underscore-transducer demo for an example of using transducers as event listeners.
Transducer that invokes interceptor with each result and input, and then passes through input. The primary purpose of this method is to "tap into" a method chain, in order to perform operations on intermediate results within the chain. Executes interceptor with current result and input.
Creates a callback that starts a transducer process and accepts parameter as a new item in the process. Each item advances the state of the transducer. If the transducer exhausts due to early termination, all subsequent calls to the callback will no-op and return the computed result. If the callback is called with no argument, the transducer terminates, and all subsequent calls will no-op and return the computed result. The callback returns undefined until completion. Once completed, the result is always returned. If reducer is not defined, maintains last value and does not buffer results.
Creates an async callback that starts a transducer process and accepts parameter cb(err, item) as a new item in the process. The returned callback and the optional continuation follow Node.js conventions with fn(err, item). Each item advances the state of the transducer, if the continuation is provided, it will be called on completion or error. An error will terminate the transducer and be propagated to the continuation. If the transducer exhausts due to early termination, any further call will be a no-op. If the callback is called with no item, it will terminate the transducer process. If reducer is not defined, maintains last value and does not buffer results.
Transduce over sequences of strings. Particularly useful with transduce-stream.
Treats every item as a substring, and splits across the entire transducer sequence. This allows methods to work with chunks sent through streams. When using transducers with streams, it is helpful to compose the transformation that you want with one of these methods to operate against a given line/word/etc.
Works like ''.split but splits across entire sequence of items. Accepts separator (String or RegExp) and limit of words to send.
Buffers all items and joins results on transducer result.
Only steps items that are non empty strings (input.trim().length > 0).
Split chunks into and steps each line/char/word.
Transducers to remove duplicate values from the transformation.
Removes consecutive duplicates from the transformation. Subsequent stepped values are checked for equality using ===.
Produce a duplicate-free version of the transformation. If f is passed, it will be called with each item and the return value for uniqueness check. Uniqueness is checked across all values already seen, and as such, the items (or computed checks) are buffered.
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.
Converts the value to an iterator and iterates into an array.
Create an ES6 Iterable by transforming an input source using transducer xf.
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.
Simple function composition of arguments. Useful for composing (combining) transducers.
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)
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
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.

Research
Malicious versions of the Telnyx Python SDK on PyPI delivered credential-stealing malware via a multi-stage supply chain attack.

Security News
TeamPCP is partnering with ransomware group Vect to turn open source supply chain attacks on tools like Trivy and LiteLLM into large-scale ransomware operations.

Security News
/Research
Widespread GitHub phishing campaign uses fake Visual Studio Code security alerts in Discussions to trick developers into visiting malicious website.