
Research
NPM targeted by malware campaign mimicking familiar library names
Socket uncovered npm malware campaign mimicking popular Node.js libraries and packages from other ecosystems; packages steal data and execute remote code.
delayed-loop
Advanced tools
Supply Chain Security
Vulnerability
Quality
Maintenance
License
Unpopular package
QualityThis package is not very popular.
Found 1 instance in 1 package
A very simple function that iterates over an array asynchronously. Getting tired of copying this whole function out of my Github Gists so I'm publishing on NPM for convenience.
/**
* Execute the loopBody function once for each item in the items array,
* waiting for the done function (which is passed into the loopBody function)
* to be called before proceeding to the next item in the array.
* @param {Array} items - The array of items to iterate through
* @param {Function} loopBody - A function to execute on each item in the array.
* This function is passed 3 arguments -
* 1. The item in the current iteration,
* 2. The index of the item in the array,
* 3. A function to be called when the iteration may continue.
* @returns {Promise} - A promise that is resolved when all the items in the
* in the array have been iterated through.
*/
function delayedLoop(items, loopBody) {
return new Promise(f => {
let done = arguments[2] || f;
let idx = arguments[3] || 0;
let cb = items[idx + 1] ? () => delayedLoop(items, loopBody, done, idx + 1) : done;
loopBody(items[idx], idx, cb);
});
}
const dLoop = require('delayed-loop');
var arr = ['do','re','mi','fa','so','la','ti'];
const loop = dLoop(arr, (itm, idx, fin)=>{
// do something async,
// call fin() when ready to continue the loop
setTimeout(()=>{
console.log(`Item #${idx} is ${itm}`);
fin();
}, 1000);
});
// Promise resolves when all items have finished looping
loop.then(()=>{
console.log('done looping');
});
FAQs
function to handle async looping
The npm package delayed-loop receives a total of 12 weekly downloads. As such, delayed-loop popularity was classified as not popular.
We found that delayed-loop 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.
Research
Socket uncovered npm malware campaign mimicking popular Node.js libraries and packages from other ecosystems; packages steal data and execute remote code.
Research
Socket's research uncovers three dangerous Go modules that contain obfuscated disk-wiping malware, threatening complete data loss.
Research
Socket uncovers malicious packages on PyPI using Gmail's SMTP protocol for command and control (C2) to exfiltrate data and execute commands.