
Security News
NVD Concedes Inability to Keep Pace with Surging CVE Disclosures in 2025
Security experts warn that recent classification changes obscure the true scope of the NVD backlog as CVE volume hits all-time highs.
Wrap a bunch of async operations into one function and iterate each step consecutively
seamlessly returning
a promise resolving with the end returned value. If an error is throw along the way or a yield promise
fails then the promise rejects allowing you to catch the error.
$ npm install consec
var consec = require('consec')
consec(function * () {
var res1 = yield Promise.resolve('abc')
return yield Promise.resolve(res1)
}).then(function (res) {
res // => 'abc'
})
// you can also yield regular values
consec(function * () {
var res1 = yield 'abc'
return yield res1
}).then(function (res) {
res // => 'abc'
})
// you can pass in the function context and parameters
var ctx = {}
function * gen(a, b, c) {
this // => ctx
return yield ['a', 'b', 'c']
}
consec.call(ctx, gen, 'a', 'b', 'c')
.then(function (abc) {
abc // => ['a', 'b', 'c']
})
// if an error is throwm then the chain ends there
var error = new Error()
consec(function * () {
throw error
}).catch(function (err) {
err // => error
})
// if a promise is rejected then the chain ends there
var error = new Error()
consec(function * () {
yield Promise.reject(error)
// this is never reached
return 'abc'
}).catch(function (err) {
err // => error
})
// a generator can also be yielded
function * g() {
return yield Promise.resolve('abc')
}
consec(function * () {
var a = yield * g()
t.equals(a, 'abc')
})
// finally you can even nest consec calls inside one another
function * g(abc) {
return yield Promise.resolve(abc)
}
return consec(function * () {
return yield consec(g, 'abc')
}).then(function (res) {
res // => 'abc'
})
FAQs
Consecutively iterate generator functions
The npm package consec receives a total of 1 weekly downloads. As such, consec popularity was classified as not popular.
We found that consec 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
Security experts warn that recent classification changes obscure the true scope of the NVD backlog as CVE volume hits all-time highs.
Security Fundamentals
Attackers use obfuscation to hide malware in open source packages. Learn how to spot these techniques across npm, PyPI, Maven, and more.
Security News
Join Socket for exclusive networking events, rooftop gatherings, and one-on-one meetings during BSidesSF and RSA 2025 in San Francisco.