-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
23 lines (20 loc) · 709 Bytes
/
index.js
File metadata and controls
23 lines (20 loc) · 709 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
'use strict';
var ConcurrencyQueue = require('./lib/ConcurrencyQueue');
module.exports.createInstance = function (options) {
var cQ = new ConcurrencyQueue(options);
var events = ['ready', 'queued', 'drained', 'empty', 'unknown'];
events.forEach(function (eventName) {
var optionName = 'on' + eventName.charAt(0).toUpperCase() + eventName.slice(1);
if (options[optionName]) {
var eventHandler = options[optionName];
cQ.on(eventName, eventHandler);
}
});
return {
push: cQ.push.bind(cQ),
drain: cQ.drain.bind(cQ),
on: function(eventName, eventHandler) {
cQ.on(eventName, eventHandler);
}
}
};