
Security News
CVE Volume Surges Past 48,000 in 2025 as WordPress Plugin Ecosystem Drives Growth
CVE disclosures hit a record 48,185 in 2025, driven largely by vulnerabilities in third-party WordPress plugins.
transduce-gen
Advanced tools
Create Transducers using ES6 Generators. Generator is created with a step function and each item in transformation is yielded through the generator. Calling step function will step value to next transformer in the pipeline. An optional completing function can be provided that will be called on transformer result.
Works with transduce, transducers-js or transducers.js.
Requires support for ES6 generators. If using Node.js run with node --harmony and version 0.11 or better.
Mapping transducer loops infinitely and transforms each yieled item with mapping function.
var gen = require('transduce-gen');
function map(f){
return gen(function*(step){
while(true){
step(f(yield 0));
}
});
}
var doubled = map(function(num){ return num * 2; });
tr.into([], doubled, [1,2,3]);
// [2,4,6]
Filter only calls step if it passes a predicate.
var gen = require('transduce-gen');
function filter(p){
return gen(function*(step){
while(true){
var val = yield 0;
if(p(val)){
step(val);
}
}
});
}
function isEven(x){
return x%2 === 0;
}
var evenArray = [1, 2, 3, 4, 5, 6];
tr.into([], filter(isEven), evenArray);
// [2,4,6]
Early termination (reduced) can be signalled by completing generator function.
var gen = require('transduce-gen');
function take(n){
return gen(function*(step){
var i = 0;
for(; i < n; i++){
step(yield 0);
}
});
}
tr.into([], take(2), [1, 2, 3]))
// [1, 2]
Provide optional completing function to be called on result.
var gen = require('transduce-gen');
function push(){
var args = slice.call(arguments);
return gen(function*(step){
while(true){
step(yield 0);
}
},
function(step){
args.forEach(step);
});
}
tr.into([], comp(push(4), push(5,6)), [1,2,3]))
// [1,2,3,4,5,6]
FAQs
Create Transducers with ES6 Generators
We found that transduce-gen 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
CVE disclosures hit a record 48,185 in 2025, driven largely by vulnerabilities in third-party WordPress plugins.

Security News
Socket CEO Feross Aboukhadijeh joins Insecure Agents to discuss CVE remediation and why supply chain attacks require a different security approach.

Security News
Tailwind Labs laid off 75% of its engineering team after revenue dropped 80%, as LLMs redirect traffic away from documentation where developers discover paid products.