Security News
Node.js EOL Versions CVE Dubbed the "Worst CVE of the Year" by Security Experts
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
async-by-page
Advanced tools
When you need to operate on a list of things, but you can only get 1 page at a time.
When you need to operate on a list of things, but you can only get 1 page at a time.
This might already exist, but it's something I've had to do a few times recently so it's time to make a lib.
const byPage = require('async-by-page')
byPage(fetchNextPage, (item, next) => {
// Let's say we only want to operate on items
// that have a certain flag set. We can just call `next()`
// with no args to skip.
if (item.isSubscribedToNewsletter) { return next() }
// For the others, we can perform an action (like sending an email)
// and then call `next()` when it's done.
sendEmail(item, next)
})
// Here we define out "fetch next page" function, that is called from `async-by-page`.
// It takes a single callback argument. If the callback is called with an error,
// the iteration terminates.
//
// The main thing to know with this function is that it is stateful.
// It should keep track of its own state, and return the next page of results
// each time it is called.
let page = 1
function fetchNextBatch (cb) {
getLeadsBatch(page, (err, res) => {
page += 1
return cb(err, res)
})
}
Not really :) I'm going to be trying a few different things first, and adding a couple of extra features (eg. option for running in parallel VS series). But your feedback is still welcome. I'd also like to write an implementation with pull-streams because I think it would be a very useful comparison (and probs much cleaner too!).
MIT
FAQs
When you need to operate on a list of things, but you can only get 1 page at a time.
We found that async-by-page 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
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
Security News
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.