
Security News
Axios Supply Chain Attack Reaches OpenAI macOS Signing Pipeline, Forces Certificate Rotation
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.
@subiz/flow
Advanced tools
[![npm][npm]][npm-url] [![deps][deps]][deps-url] [![size][size]][size-url]
Just a few simple functions to help you write asynchronous functions easier
npm i --save @subiz/flow
Sleep pauses the current execution flow
var flow = require('@subiz/flow')
console.log('sleeping for 1 sec')
await flow.sleep(1000)
console.log('ok, I am up')
Loop is just like do/while, but it runs on both sync and async function
var flow = require('@subiz/flow')
var n = 0
// call an async function 10 times
await flow.loop(async () => {
await flow.sleep(10)
n++
if (n === 10) return false
return true
})
console.log(n) // 10
Caution: The above code is just a super complicated version of
for (var i = 0; i < 10; i++) await doSomethind()
The loop function only make sense when you have to write code that run on older browsers which do not support async/await (and you hate babel). Here is an example of asynchronous looping without async/await
var n = 0
// call a async function 10 times
flow.loop(function() {
return flow.sleep(10).then(function() {
n++
return n === 10
})
}).then(function() {
console.log(n) // 10
})
But again, please do not use this function when a simple for-loop will do.
Map is like js array.prototype.map but run concurrently.
var flow = require('@subiz/flow')
outs = await flow.map([1, 2, 3, 4], async i => {
await flow.sleep(1000)
return i * 2
}, 2)
// after 2 seconds
console.log(outs) // [2, 4, 6, 8]
On the example above, we have 4 items to process, each item need 1 second to process. With concurrency level of 2, it would only takes 2 seconds to finish.
FAQs
[![npm][npm]][npm-url] [![deps][deps]][deps-url] [![size][size]][size-url]
The npm package @subiz/flow receives a total of 48 weekly downloads. As such, @subiz/flow popularity was classified as not popular.
We found that @subiz/flow demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers 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
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.

Security News
Open source is under attack because of how much value it creates. It has been the foundation of every major software innovation for the last three decades. This is not the time to walk away from it.

Security News
Socket CEO Feross Aboukhadijeh breaks down how North Korea hijacked Axios and what it means for the future of software supply chain security.