MCPcopy
hub / github.com/caolan/async / _insert

Function _insert

lib/internal/queue.js:23–51  ·  view source on GitHub ↗
(data, insertAtFront, callback)

Source from the content-addressed store, hash-verified

21 var workersList = [];
22
23 function _insert(data, insertAtFront, callback) {
24 if (callback != null && typeof callback !== 'function') {
25 throw new Error('task callback must be a function');
26 }
27 q.started = true;
28 if (!isArray(data)) {
29 data = [data];
30 }
31 if (data.length === 0 && q.idle()) {
32 // call drain immediately if there are no tasks
33 return setImmediate(function() {
34 q.drain();
35 });
36 }
37
38 for (var i = 0, l = data.length; i < l; i++) {
39 var item = {
40 data: data[i],
41 callback: callback || noop
42 };
43
44 if (insertAtFront) {
45 q._tasks.unshift(item);
46 } else {
47 q._tasks.push(item);
48 }
49 }
50 setImmediate(q.process);
51 }
52
53 function _next(tasks) {
54 return rest(function(args){

Callers 1

queueFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…