Simply pass functions to sparallel and call the done (or resolve) callback when each finishes. Sparallel returns a promise so the then method takes a callback that will run after all other functions have called the done callback.
Sounds confusing, so here's an example:
importsparallelfrom'sparallel';
sparallel(
done=>{
console.log('code 1');
done();
},
done=>{
console.log('code 2');
done();
},
done=>{
console.log('code 3');
done();
}
).then(()=>{
console.log('all done.');
});
The Best Part
The best part of sparallel is that you can pass an object to each done callback and all of the objects will be merged into a single object and passed to the then callback.