Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
in-parallel
Advanced tools
A small library for Runs a function on the elements of the provided collection in parallel
A node module for running async tasks on an array and finishing together to run a final function.
npm install in-parallel --save
Initialize inParallel like so:
//the proceedAfterParallelAction() method is provided
var inParallel = require('in-parallel');
###A Simple Example
var collection = [1,2,3];
inParallel.run(collection, function(element){
element++;
this.proceedAfterParallelAction();
}, function(){
collection.push(5);
});
###A Less Simple Example With MongoDB Queries Imagine you have a bunch of users and each user has a bunch of photos all stored in a mongodb. If you have to get each user's photo and do something with them, it'd probably be best to run such tasks in parallel:
//a less simple use case with a MongoDB query
var users = [user1,user2,user3];
inParallel.run(users, function(user){
//find the user's photos
db.collection(PHOTOS_COLLECTION).findOne(searchQuery,function(err, doc) {
if(err || !doc) {
//handle the error
if(err) console.log("Failed to find one doc: " + err.message);
//call the provided proceed method after this user is done
this.proceedAfterInParallelAction();
} else {
//find succeeded
//do something with the result
//call the provided proceed method after this user is done
this.proceedAfterInParallelAction();
}
});
}, function(){
//everything is done
//do something afterwards
console.log("FINISHED!");
}, function(err){
//error. handle it
console.log(err.message)
});
###Debug Messages Debug messages are printed to the console by default but you can choose not have that like so:
inParallel.config({showDebugMessages:false});
npm test
In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code.
##Credits I used this article to learn how to publish npm articles: https://quickleft.com/blog/creating-and-publishing-a-node-js-module/
FAQs
A small library for Runs a function on the elements of the provided collection in parallel
The npm package in-parallel receives a total of 0 weekly downloads. As such, in-parallel popularity was classified as not popular.
We found that in-parallel 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
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.