
Security News
Axios Maintainer Confirms Social Engineering Attack Behind npm Compromise
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.
I was specifically wanting to try using transducers to modify a stream of data generated from an asynchronous iterator.
e.g.
async function(){
for await (const v of generator) {
console.log(v)
}
}
Where the generator is an async generator such as
async function * makeAsyncRangeIterator (start = 0, end = Infinity, step = 1, delay = 10) {
let iterationCount = 0
for (let i = start; i < end; i += step) {
iterationCount++
yield new Promise((resolve, reject) => {
setTimeout(() => {
resolve(i)
}, delay)
})
}
return iterationCount
}
or another example would be to process of stream of documents being inserted into a Mongo DB database
async function makeGenerator(config){
const client = await mongoClient.connect(config.MONGO_SERVER);
const collection = client.db(config.MONGO_DB).collection(config.MONGO_COLLECTION);
return async function* () {
const pipeline = [
{ $project : {
"AssetId": "$fullDocument.AssetId",
"Epoch": "$fullDocument.Epoch",
"Value": "$fullDocument.Value",
"SiteId": "$fullDocument.SiteId" } }
]
const changeStream = collection.watch(pipeline,{
startAtOperationTime: new Date( )
});
while(true){
var change = await new Promise( (resolve) =>{
changeStream.on("change", function(change) {
resolve(change)
});
})
delete change._id
yield change
}
}()
}
I found a number of functional programming libraries (tranducer.js, ramda) but found they didnt support asynchronous iterators. They appear to only support synchronous functionality.
npm install funprog
Then use the functionality that you require (which is visible in index.js)
const { compose, transduceArray, transduceIterator,mapping, filtering } = require('funprog')
There are a number of operators which generally take a value and return another value
The transforms operate the stream of values
There are a number of functions to produce generators
There are a set of transducer functions. A transducer is a function taking 4 parameters
The transducer reads from the generator transforms the value and reduces using the reduce function and initial accumulation
Functions that compose functions together
Use npm start to run the unit tests
FAQs
A simple library for functional programming
We found that funprog 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
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.

Security News
The Axios compromise shows how time-dependent dependency resolution makes exposure harder to detect and contain.