MCPcopy Create free account
hub / github.com/pacexy/flow / enqueue

Method enqueue

packages/epubjs/src/utils/queue.js:21–63  ·  view source on GitHub ↗

* Add an item to the queue * @return {Promise}

()

Source from the content-addressed store, hash-verified

19 * @return {Promise}
20 */
21 enqueue() {
22 var deferred, promise
23 var queued
24 var task = [].shift.call(arguments)
25 var args = arguments
26
27 // Handle single args without context
28 // if(args && !Array.isArray(args)) {
29 // args = [args];
30 // }
31 if (!task) {
32 throw new Error('No Task Provided')
33 }
34
35 if (typeof task === 'function') {
36 deferred = new defer()
37 promise = deferred.promise
38
39 queued = {
40 task: task,
41 args: args,
42 //"context" : context,
43 deferred: deferred,
44 promise: promise,
45 }
46 } else {
47 // Task is a promise
48 queued = {
49 promise: task,
50 }
51 }
52
53 this._q.push(queued)
54
55 // Wait to start queue flush
56 if (this.paused == false && !this.running) {
57 // setTimeout(this.flush.bind(this), 0);
58 // this.tick.call(window, this.run.bind(this));
59 this.run()
60 }
61
62 return queued.promise
63 }
64
65 /**
66 * Run one item

Callers 14

constructorMethod · 0.80
attachToMethod · 0.80
displayMethod · 0.80
nextMethod · 0.80
prevMethod · 0.80
reportLocationMethod · 0.80
generateMethod · 0.80
generateFromWordsMethod · 0.80
fillMethod · 0.80
updateMethod · 0.80
checkMethod · 0.80
scrolledMethod · 0.80

Calls 1

runMethod · 0.95

Tested by

no test coverage detected