
Product
Rust Support Now in Beta
Socket's Rust support is moving to Beta: all users can scan Cargo projects and generate SBOMs, including Cargo.toml-only crates, with Rust-aware supply chain checks.
datacollector
Advanced tools
(C) Patrick Lodder 2012, Licensed under the MIT-LICENSE
Collects data from one to many async calls and pushes out events based on the data collected.
npm install datacollector
var DataCollector = require('datacollector');
var dc = new DataCollector(2);
dc.on('complete', function(err, data) {
console.log(JSON.stringify(data));
});
dc.collect('1st');
dc.collect('2nd');
// ['1st', '2nd']
var DataCollector = require('datacollector');
var dc = new DataCollector(['1st', '2nd']);
dc.on('complete', function(err, data) {
console.log(JSON.stringify(data));
});
dc.collect('1st', 'first');
dc.collect('2nd', 'second');
// {'1st': 'first', '2nd': 'second'}
var DataCollector = require('datacollector');
var dc = new DataCollector(['1st', '2nd']).timeout(50);
dc.on('complete', function(err, data) {
console.log(err.message, JSON.stringify(data));
});
dc.collect('1st', 'first');
// "timed out", {'1st': 'first'}
var parallel = require('datacollector').parallel;
var data = ['1st', '2nd'];
parallel(data.map(function (elem) {
return function (cb) { cb(elem); };
})).exec(console.log);
// ['1st', '2nd']
var parallel = require('datacollector').parallel;
var pp = parallel({
'1st': function (cb) { cb(null, 'first'); },
'2nd': function (cb) { cb(null, 'second'); }
});
pp.exec(console.log);
// {'1st': 'first', '2nd': 'second'}
instantiates a new data collector
Array
- keys that are to be collected, ornumber
- number of expected collectsbool
- record null and undefined values. Optional, default: false
.bool
- record keys that were not expected. Optional, default: false
.Passing an array as the first argument will collect named values in an object, passing a number will record values anonymously in an array.
Error out after milliseconds
amount of time. Overrides previous timeouts.
milliseconds
- amount of milliseconds that collection must complete within.Chainable command, returns self.
Collect a value
string
- key to collect, optionalany
- the value to collectCollect an error for a key
string
- key to collect, optionalError
- the error to collectRetrieve a value from the collection. Executes callback
immediately when the value is already collected, otherwise it calls the callback on collection of the value. Returns an error if the collected value is an instance of Error or when calling this on an anonymous collector.
string
- key to get the value forfunction (error, value)
- callback to pass the error/value to.key
has been collectedInitiates a ParallelProcessor
that will execute given instructions.
instructions:
Array
- array of functions to execute.Object
- hash of named functions to execute.npm test
- runs all tests
FAQs
Asynchronous data collector
The npm package datacollector receives a total of 0 weekly downloads. As such, datacollector popularity was classified as not popular.
We found that datacollector 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.
Product
Socket's Rust support is moving to Beta: all users can scan Cargo projects and generate SBOMs, including Cargo.toml-only crates, with Rust-aware supply chain checks.
Product
Socket Fix 2.0 brings targeted CVE remediation, smarter upgrade planning, and broader ecosystem support to help developers get to zero alerts.
Security News
Socket CEO Feross Aboukhadijeh joins Risky Business Weekly to unpack recent npm phishing attacks, their limited impact, and the risks if attackers get smarter.