
Security News
TypeScript is Porting Its Compiler to Go for 10x Faster Builds
TypeScript is porting its compiler to Go, delivering 10x faster builds, lower memory usage, and improved editor performance for a smoother developer experience.
A simple concurrency pattern: fan-in
Status: Untested in production, but ready to be.
n
asynchronous calls simultaneously and make a callback when all have finished.Usage:
var fanin = require('fanin')
, fan = fanin(number_of_callbacks, final_callback);
asyncCall(fan); // repeat...
asyncCall(fan.capture('field'));
asyncCall(fan.ordered(index));
...
fan.timeout(err)
// final_callback( error_array, return_value_object );
Basic Usage (no return values, just an unorded list of errors):
var fan = fanin(2, cb);
foo(fan);
bar(fan);
function foo(cb) { cb(new Error('some error')); }
function bar(cb) { cb(null); }
// cb([ Error('some error') ]);
Storing return value(s):
var fan = fanin(2, cb);
foo(fan.capture('foo'));
bar(fan.capture('bar'));
function foo(cb) { cb(null, 'foobaz'); }
function bar(cb) { cb(null, 'bar', 'baz'); }
// cb(undefined, { foo: 'foobaz', bar: [ 'bar', 'baz' ] } );
Storing return values in an ordered array:
var fan = fanin(2, cb);
foo(fan.ordered(1));
bar(fan.ordered(0));
function foo(cb) { cb(null, 'foobaz'); }
function bar(cb) { cb(null, 'barbaz'); }
// cb(undefined, { ordered: [ 'barbaz', 'foobaz' ] } );
Timeouts on these calls:
var fan = fanin(2, cb);
fan.timeout(new Error('timeout!'));
// cb([ Error('timeout!') ])
npm install fanin
npm test
MIT License found in the LICENSE file.
FAQs
fanin - the fan-in concurrency pattern
The npm package fanin receives a total of 5 weekly downloads. As such, fanin popularity was classified as not popular.
We found that fanin 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
TypeScript is porting its compiler to Go, delivering 10x faster builds, lower memory usage, and improved editor performance for a smoother developer experience.
Research
Security News
The Socket Research Team has discovered six new malicious npm packages linked to North Korea’s Lazarus Group, designed to steal credentials and deploy backdoors.
Security News
Socket CEO Feross Aboukhadijeh discusses the open web, open source security, and how Socket tackles software supply chain attacks on The Pair Program podcast.