@leaddreamer/inventorylogic 0.0.3-beta.78 → 0.0.3-beta.80

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (80) hide show
  1. package/README.md +16 -20
  2. package/business/Utilities/index.js +1 -0
  3. package/business/Utilities/other.js +1 -3
  4. package/business/Utilities/promise-queue/index.js +183 -150
  5. package/business/Utilities/promise-queue/new.js +231 -0
  6. package/dist/InventoryLogic.0ac93278.js +35 -0
  7. package/dist/InventoryLogic.0ac93278.js.map +1 -0
  8. package/dist/InventoryLogic.31f6d549.js +152 -0
  9. package/dist/InventoryLogic.31f6d549.js.map +1 -0
  10. package/dist/InventoryLogic.35827495.js +285 -0
  11. package/dist/InventoryLogic.35827495.js.map +1 -0
  12. package/dist/InventoryLogic.37dfff3e.js +72 -0
  13. package/dist/InventoryLogic.37dfff3e.js.map +1 -0
  14. package/dist/InventoryLogic.4206cb15.js +213 -0
  15. package/dist/InventoryLogic.4206cb15.js.map +1 -0
  16. package/dist/InventoryLogic.44193a77.js +35 -0
  17. package/dist/InventoryLogic.44193a77.js.map +1 -0
  18. package/dist/InventoryLogic.46ca6768.js +131 -0
  19. package/dist/InventoryLogic.46ca6768.js.map +1 -0
  20. package/dist/InventoryLogic.4d012935.js +151 -0
  21. package/dist/InventoryLogic.4d012935.js.map +1 -0
  22. package/dist/InventoryLogic.57f24f5f.js +155 -0
  23. package/dist/InventoryLogic.57f24f5f.js.map +1 -0
  24. package/dist/InventoryLogic.59be76a4.js +184 -0
  25. package/dist/InventoryLogic.59be76a4.js.map +1 -0
  26. package/dist/InventoryLogic.70925a32.js +375 -0
  27. package/dist/InventoryLogic.70925a32.js.map +1 -0
  28. package/dist/InventoryLogic.72fcf301.js +6 -0
  29. package/dist/InventoryLogic.72fcf301.js.map +1 -0
  30. package/dist/InventoryLogic.7741caec.js +375 -0
  31. package/dist/InventoryLogic.7741caec.js.map +1 -0
  32. package/dist/InventoryLogic.78480e5e.js +152 -0
  33. package/dist/InventoryLogic.78480e5e.js.map +1 -0
  34. package/dist/InventoryLogic.80d0e568.js +135 -0
  35. package/dist/InventoryLogic.80d0e568.js.map +1 -0
  36. package/dist/InventoryLogic.8a273d2e.js +110 -0
  37. package/dist/InventoryLogic.8a273d2e.js.map +1 -0
  38. package/dist/InventoryLogic.8addb055.js +202 -0
  39. package/dist/InventoryLogic.8addb055.js.map +1 -0
  40. package/dist/InventoryLogic.9dee46ea.js +6 -0
  41. package/dist/InventoryLogic.9dee46ea.js.map +1 -0
  42. package/dist/InventoryLogic.b90f66ea.js +124 -0
  43. package/dist/InventoryLogic.b90f66ea.js.map +1 -0
  44. package/dist/InventoryLogic.bb447b4c.js +39 -0
  45. package/dist/InventoryLogic.bb447b4c.js.map +1 -0
  46. package/dist/InventoryLogic.d27e84a7.js +75 -0
  47. package/dist/InventoryLogic.d27e84a7.js.map +1 -0
  48. package/dist/InventoryLogic.d69ad127.js +217 -0
  49. package/dist/InventoryLogic.d69ad127.js.map +1 -0
  50. package/dist/InventoryLogic.e03e6b07.js +245 -0
  51. package/dist/InventoryLogic.e03e6b07.js.map +1 -0
  52. package/dist/InventoryLogic.f276f76c.js +213 -0
  53. package/dist/InventoryLogic.f276f76c.js.map +1 -0
  54. package/dist/InventoryLogic.f4627c8a.js +160 -0
  55. package/dist/InventoryLogic.f4627c8a.js.map +1 -0
  56. package/dist/index.js +22 -1
  57. package/dist/index.js.map +1 -0
  58. package/index.js +1 -2
  59. package/package.json +9 -20
  60. package/dist/InventoryLogic.0b64d0ad.js +0 -2
  61. package/dist/InventoryLogic.0fde24a4.js +0 -2
  62. package/dist/InventoryLogic.1e519cb0.js +0 -2
  63. package/dist/InventoryLogic.20d9efd7.js +0 -2
  64. package/dist/InventoryLogic.2468e70a.js +0 -2
  65. package/dist/InventoryLogic.30338491.js +0 -2
  66. package/dist/InventoryLogic.30e7c3e7.js +0 -2
  67. package/dist/InventoryLogic.4a3c62d7.js +0 -2
  68. package/dist/InventoryLogic.4e7ced22.js +0 -9
  69. package/dist/InventoryLogic.62b5247c.js +0 -2
  70. package/dist/InventoryLogic.6479c130.js +0 -2
  71. package/dist/InventoryLogic.74baf986.js +0 -2
  72. package/dist/InventoryLogic.7852e007.js +0 -2
  73. package/dist/InventoryLogic.87addb57.js +0 -2
  74. package/dist/InventoryLogic.9658c8e7.js +0 -2
  75. package/dist/InventoryLogic.9a89425d.js +0 -2
  76. package/dist/InventoryLogic.b49f09b1.js +0 -2
  77. package/dist/InventoryLogic.e0dc6c34.js +0 -2
  78. package/dist/InventoryLogic.e295e814.js +0 -2
  79. package/dist/InventoryLogic.f716bebc.js +0 -2
  80. package/dist/InventoryLogic.f8d080e8.js +0 -2
package/README.md CHANGED
@@ -97,21 +97,19 @@ services.
97
97
 
98
98
 
99
99
  * [InventoryLogic](#module_InventoryLogic)
100
- * _static_
101
- * [.databasePromise(firebase, config, thisLogger)](#module_InventoryLogic.databasePromise) ⇒ <code>Promise.Firebase</code>
102
- * _inner_
103
- * [~FirebaseConfigObject](#module_InventoryLogic..FirebaseConfigObject) : <code>object</code>
100
+ * [module.exports(firebase, config, thisLogger)](#exp_module_InventoryLogic--module.exports) ⇒ <code>Promise.Firebase</code> ⏏
101
+ * [~FirebaseConfigObject](#module_InventoryLogic--module.exports..FirebaseConfigObject) : <code>object</code>
104
102
 
105
- <a name="module_InventoryLogic.databasePromise"></a>
103
+ <a name="exp_module_InventoryLogic--module.exports"></a>
106
104
 
107
- ### InventoryLogic.databasePromise(firebase, config, thisLogger) ⇒ <code>Promise.Firebase</code>
105
+ ### module.exports(firebase, config, thisLogger) ⇒ <code>Promise.Firebase</code> ⏏
108
106
  all-in-one wrapper for a solid subset of CLIENT-SIDE Firebase
109
107
  functions, with a consistent interface. There is a parallel set for
110
108
  ADMIN-SIDE functions as well.
111
109
  Call/initialize with Firebase Configuration settings in an object as
112
110
  described below
113
111
 
114
- **Kind**: static method of [<code>InventoryLogic</code>](#module_InventoryLogic)
112
+ **Kind**: Exported function
115
113
 
116
114
  | Param | Type | Description |
117
115
  | --- | --- | --- |
@@ -128,13 +126,13 @@ import FirebaseWrapper from "@leaddreamer/firebase-wrapper";
128
126
  FirebaseWrapper(config); //see below
129
127
  export * from "@leaddreamer/firebase-wrapper";
130
128
  ```
131
- <a name="module_InventoryLogic..FirebaseConfigObject"></a>
129
+ <a name="module_InventoryLogic--module.exports..FirebaseConfigObject"></a>
132
130
 
133
- ### InventoryLogic~FirebaseConfigObject : <code>object</code>
131
+ #### module.exports~FirebaseConfigObject : <code>object</code>
134
132
  only authDomain, databaseURL and storageBucket are present when
135
133
  called from a cloud environment
136
134
 
137
- **Kind**: inner typedef of [<code>InventoryLogic</code>](#module_InventoryLogic)
135
+ **Kind**: inner typedef of [<code>module.exports</code>](#exp_module_InventoryLogic--module.exports)
138
136
  **Properties**
139
137
 
140
138
  | Name | Type | Description |
@@ -157,21 +155,19 @@ frontEnd and NodeJS BackEnd
157
155
 
158
156
 
159
157
  * [InventoryLogic](#module_InventoryLogic)
160
- * _static_
161
- * [.databasePromise(firebase, config, thisLogger)](#module_InventoryLogic.databasePromise) ⇒ <code>Promise.Firebase</code>
162
- * _inner_
163
- * [~FirebaseConfigObject](#module_InventoryLogic..FirebaseConfigObject) : <code>object</code>
158
+ * [module.exports(firebase, config, thisLogger)](#exp_module_InventoryLogic--module.exports) ⇒ <code>Promise.Firebase</code> ⏏
159
+ * [~FirebaseConfigObject](#module_InventoryLogic--module.exports..FirebaseConfigObject) : <code>object</code>
164
160
 
165
- <a name="module_InventoryLogic.databasePromise"></a>
161
+ <a name="exp_module_InventoryLogic--module.exports"></a>
166
162
 
167
- ### InventoryLogic.databasePromise(firebase, config, thisLogger) ⇒ <code>Promise.Firebase</code>
163
+ ### module.exports(firebase, config, thisLogger) ⇒ <code>Promise.Firebase</code> ⏏
168
164
  all-in-one wrapper for a solid subset of CLIENT-SIDE Firebase
169
165
  functions, with a consistent interface. There is a parallel set for
170
166
  ADMIN-SIDE functions as well.
171
167
  Call/initialize with Firebase Configuration settings in an object as
172
168
  described below
173
169
 
174
- **Kind**: static method of [<code>InventoryLogic</code>](#module_InventoryLogic)
170
+ **Kind**: Exported function
175
171
 
176
172
  | Param | Type | Description |
177
173
  | --- | --- | --- |
@@ -188,13 +184,13 @@ import FirebaseWrapper from "@leaddreamer/firebase-wrapper";
188
184
  FirebaseWrapper(config); //see below
189
185
  export * from "@leaddreamer/firebase-wrapper";
190
186
  ```
191
- <a name="module_InventoryLogic..FirebaseConfigObject"></a>
187
+ <a name="module_InventoryLogic--module.exports..FirebaseConfigObject"></a>
192
188
 
193
- ### InventoryLogic~FirebaseConfigObject : <code>object</code>
189
+ #### module.exports~FirebaseConfigObject : <code>object</code>
194
190
  only authDomain, databaseURL and storageBucket are present when
195
191
  called from a cloud environment
196
192
 
197
- **Kind**: inner typedef of [<code>InventoryLogic</code>](#module_InventoryLogic)
193
+ **Kind**: inner typedef of [<code>module.exports</code>](#exp_module_InventoryLogic--module.exports)
198
194
  **Properties**
199
195
 
200
196
  | Name | Type | Description |
@@ -336,3 +336,4 @@ export function choicesForm(fieldname) {
336
336
  }
337
337
 
338
338
  export * from "./other.js";
339
+ export * from "./promise-queue/index.js";
@@ -4,7 +4,7 @@
4
4
  * @module Utilities
5
5
  */
6
6
  import dayjs from "dayjs";
7
- import promisePool from "es6-promise-pool";
7
+ //import promisePool from "es6-promise-pool";
8
8
  import isSameOrAfter from "dayjs/plugin/isSameOrAfter.js";
9
9
  import isSameOrBefore from "dayjs/plugin/isSameOrBefore.js";
10
10
  import {
@@ -402,5 +402,3 @@ export function makeHexAsNeeded(color) {
402
402
  if (colours[color.toLowerCase()]) return colours[color.toLowerCase()];
403
403
  return color;
404
404
  }
405
-
406
- export * from "./promise-queue/index.js";
@@ -1,100 +1,132 @@
1
1
  /**
2
2
  * Typedefs, constants, support functions and database operations related to Promise getQueueSize
3
- * Thes era euseful for scheduling large serial asynchronous operations
3
+ * Thes are useful for scheduling large serial asynchronous operations
4
4
  * @module PromiseQueue
5
5
  */
6
- (function () {
7
- /**
8
- * Creates a new rate limited queue. The queue is created with stopped state, i.e. you have to call start() to run jobs.
9
- * @param {number} maxCallsPerSecond=1 - The rate limit of this queue in maximum calls per seconds which may be executed at any time. Pass values less than 1 to have less than one call per second, e.g. 1/3 for 3 one call in three seconds at maximum.
10
- * @param logger
11
- * @constructor
12
- */
13
- function PromiseQueue(maxCallsPerSecond, logger) {
14
- this.maxCallsPerSecond =
15
- typeof maxCallsPerSecond === "undefined" ? 1 : maxCallsPerSecond;
16
- this.logger = logger;
17
-
18
- this.tasks = [];
19
- this.isActive = false;
20
- this.jobIntervalMillis = 1000 / maxCallsPerSecond;
21
-
22
- this.lastTaskTimestamp = null;
23
- this.currentTaskTimeoutId = null;
24
- }
6
+ /**
7
+ * Creates a new rate limited queue. The queue is created with stopped state, i.e. you have to call start() to run jobs.
8
+ * @class
9
+ */
10
+ export class PromiseQueueClass {
11
+ /**
12
+ * @param {number} maxCallsPerSecond - The rate limit of this queue in maximum calls per seconds which may be executed at any time. Pass values less than 1 to have less than one call per second, e.g. 1/3 for 3 one call in three seconds at maximum.
13
+ * @param {callback} logger optional logger function for errors
14
+ * @constructor
15
+ */
16
+ constructor(maxCallsPerSecond=1, logger) {
17
+ /**
18
+ * The rate limit of this queue in maximum calls per seconds
19
+ * which may be executed at any time. Pass values less than 1
20
+ * to have less than one call per second, e.g. 1/3 for 3 one
21
+ * call in three seconds at maximum.
22
+ * @type {float}
23
+ */
24
+ this.maxCallsPerSecond =
25
+ typeof maxCallsPerSecond === "undefined" ? 1 : maxCallsPerSecond;
26
+ /**
27
+ * optional logger function for errors
28
+ * @type {callback}
29
+ */
30
+ this.logger = logger;
31
+
32
+ /**
33
+ * lists of tasks to be processed, in order, in the queue
34
+ * @type {Array.callback}
35
+ */
36
+ this.tasks = [];
37
+ /**
38
+ * flag to indicate queue processing is active
39
+ * @type {boolean}
40
+ */
41
+ this.isActive = false;
42
+ /**
43
+ * pacing for queue processing / rate limiting
44
+ * @type {float}
45
+ */
46
+ this.jobIntervalMillis = 1000 / maxCallsPerSecond;
47
+ /**
48
+ * timestamp of start of last task
49
+ * @type {time}
50
+ */
51
+ this.lastTaskTimestamp = null;
52
+ /**
53
+ * @type {string}
54
+ */
55
+ this.currentTaskTimeoutId = null;
56
+ }
25
57
 
26
58
  /**
27
59
  * Processes the next task and returns the id of the time used to wait for the next invocation of this method.
28
60
  * @private
29
61
  */
30
- PromiseQueue.prototype.updateTaskSchedule = function () {
31
- if (this.logger && this.logger.debug) {
32
- this.logger.debug("PromiseQueue.updateTaskSchedule");
33
- }
62
+ updateTaskSchedule() {
63
+ if (this.logger && this.logger.debug) {
64
+ this.logger.debug("PromiseQueue.updateTaskSchedule");
65
+ }
34
66
 
35
- if (this.isEmpty() || this.isStopped()) {
36
- return;
37
- }
67
+ if (this.isEmpty() || this.isStopped()) {
68
+ return;
69
+ }
38
70
 
39
- const queue = this;
40
-
41
- function processNextTask() {
42
- if (queue.logger && queue.logger.debug) {
43
- queue.logger.debug("PromiseQueue.processNextTask", queue.tasks.length);
44
- }
45
-
46
- var nextTaskItem = queue.tasks.shift();
47
- if (nextTaskItem) {
48
- try {
49
- const result = nextTaskItem.task.call();
50
-
51
- if (queue.logger && queue.logger.debug) {
52
- queue.logger.debug(
53
- "Resolving queued promise",
54
- result,
55
- result instanceof Promise
56
- );
57
- }
58
-
59
- nextTaskItem.resolve(result);
60
- } catch (e) {
61
- queue.logger.info("rejecting queued promise result", e);
62
- nextTaskItem.reject(e);
71
+ const queue = this;
72
+
73
+ function processNextTask() {
74
+ if (queue.logger && queue.logger.debug) {
75
+ queue.logger.debug("PromiseQueue.processNextTask", queue.tasks.length);
76
+ }
77
+
78
+ var nextTaskItem = queue.tasks.shift();
79
+ if (nextTaskItem) {
80
+ try {
81
+ const result = nextTaskItem.task.call();
82
+
83
+ if (queue.logger && queue.logger.debug) {
84
+ queue.logger.debug(
85
+ "Resolving queued promise",
86
+ result,
87
+ result instanceof Promise
88
+ );
89
+ }
90
+
91
+ nextTaskItem.resolve(result);
92
+ } catch (e) {
93
+ queue.logger.info("rejecting queued promise result", e);
94
+ nextTaskItem.reject(e);
95
+ }
96
+ }
63
97
  }
64
- }
65
- }
66
98
 
67
- function scheduleNext(timeoutMillisOverride) {
68
- if (queue.logger && queue.logger.debug) {
69
- queue.logger.debug("PromiseQueue.scheduleNext", timeoutMillisOverride);
70
- }
99
+ function scheduleNext(timeoutMillisOverride) {
100
+ if (queue.logger && queue.logger.debug) {
101
+ queue.logger.debug("PromiseQueue.scheduleNext", timeoutMillisOverride);
102
+ }
71
103
 
72
- if (queue.isEmpty()) {
73
- queue.currentTaskTimeoutId = null;
74
- return;
75
- }
104
+ if (queue.isEmpty()) {
105
+ queue.currentTaskTimeoutId = null;
106
+ return;
107
+ }
76
108
 
77
- queue.currentTaskTimeoutId = setTimeout(function () {
78
- queue.lastTaskTimestamp = Date.now();
79
- processNextTask();
109
+ queue.currentTaskTimeoutId = setTimeout(function () {
110
+ queue.lastTaskTimestamp = Date.now();
111
+ processNextTask();
80
112
 
81
- scheduleNext(queue.jobIntervalMillis);
82
- }, timeoutMillisOverride);
83
- }
113
+ scheduleNext(queue.jobIntervalMillis);
114
+ }, timeoutMillisOverride);
115
+ }
84
116
 
85
- if (this.currentTaskTimeoutId == null) {
86
- if (this.lastTaskTimestamp) {
87
- let passedTime = Date.now() - this.lastTaskTimestamp;
88
- if (passedTime > this.jobIntervalMillis) {
89
- scheduleNext(this.jobIntervalMillis);
90
- } else {
91
- scheduleNext(Math.max(0, this.jobIntervalMillis - passedTime));
117
+ if (this.currentTaskTimeoutId == null) {
118
+ if (this.lastTaskTimestamp) {
119
+ let passedTime = Date.now() - this.lastTaskTimestamp;
120
+ if (passedTime > this.jobIntervalMillis) {
121
+ scheduleNext(this.jobIntervalMillis);
122
+ } else {
123
+ scheduleNext(Math.max(0, this.jobIntervalMillis - passedTime));
124
+ }
125
+ } else {
126
+ scheduleNext(0);
127
+ }
92
128
  }
93
- } else {
94
- scheduleNext(0);
95
- }
96
- }
97
- };
129
+ };
98
130
 
99
131
  /**
100
132
  * Starts the task processing of this queue.
@@ -104,128 +136,129 @@
104
136
  *
105
137
  * @return {boolean} true if this queue wasn't started before and now started to process tasks.
106
138
  */
107
- PromiseQueue.prototype.start = function () {
108
- if (this.isActive) {
109
- return false;
110
- }
139
+ start() {
140
+ if (this.isActive) {
141
+ return false;
142
+ }
111
143
 
112
- this.isActive = true;
144
+ this.isActive = true;
113
145
 
114
- this.updateTaskSchedule();
146
+ this.updateTaskSchedule();
115
147
 
116
- return true;
117
- };
148
+ return true;
149
+ };
118
150
 
119
151
  /**
120
152
  * Stops the processing of this queue.
121
153
  * @return true if the queue was started and is now stopped. false if it was already stopped.
122
154
  */
123
- PromiseQueue.prototype.stop = function () {
124
- if (this.isActive) {
125
- this.isActive = false;
126
-
127
- if (this.currentTaskTimeoutId) {
128
- clearInterval(this.currentTaskTimeoutId);
129
- this.currentTaskTimeoutId = null;
130
- this.lastTaskTimestamp = null;
131
- }
132
- }
133
- };
155
+ stop() {
156
+ if (this.isActive) {
157
+ this.isActive = false;
158
+
159
+ if (this.currentTaskTimeoutId) {
160
+ clearInterval(this.currentTaskTimeoutId);
161
+ this.currentTaskTimeoutId = null;
162
+ this.lastTaskTimestamp = null;
163
+ }
164
+ }
165
+ };
134
166
 
135
- PromiseQueue.prototype.getMaxCallsPerSecond = function () {
136
- return this.maxCallsPerSecond;
137
- };
167
+ getMaxCallsPerSecond() {
168
+ return this.maxCallsPerSecond;
169
+ };
138
170
 
139
- PromiseQueue.prototype.isStarted = function () {
140
- return this.isActive;
141
- };
171
+ isStarted() {
172
+ return this.isActive;
173
+ };
142
174
 
143
- PromiseQueue.prototype.isStopped = function () {
144
- return !this.isStarted();
145
- };
175
+ isStopped() {
176
+ return !this.isStarted();
177
+ };
146
178
 
147
179
  /**
148
180
  * @returns {boolean} true if this queue is currently empty, i.e. if it has no tasks in the queue.
149
181
  */
150
- PromiseQueue.prototype.isEmpty = function () {
151
- return this.tasks.length === 0;
152
- };
182
+ isEmpty() {
183
+ return this.tasks.length === 0;
184
+ };
153
185
 
154
186
  /**
155
187
  * @returns {boolean} true if this queue has one or more entries.
156
188
  */
157
- PromiseQueue.prototype.isNotEmpty = function () {
158
- return !this.isEmpty();
159
- };
189
+ isNotEmpty() {
190
+ return !this.isEmpty();
191
+ };
160
192
 
161
193
  /**
162
194
  * @param {function} task - The task to add.
163
195
  * @param {boolean} append - if the task should be appended or prepended to the list of queued tasks
164
196
  * @return {Promise} A promise which is resolved/rejected when the task was executed by the queue.
165
197
  */
166
- PromiseQueue.prototype.add = function (task, append) {
167
- var self = this;
198
+ async add(task, append) {
199
+ var self = this;
168
200
 
169
- var promise = new Promise(function (resolve, reject) {
170
- var newTaskItem = { task: task, resolve: resolve, reject: reject };
201
+ var promise = new Promise(function (resolve, reject) {
202
+ var newTaskItem = { task: task, resolve: resolve, reject: reject };
171
203
 
172
- if (self.isEmpty() || append) {
173
- self.tasks.push(newTaskItem);
174
- } else {
175
- self.tasks.unshift(newTaskItem);
176
- }
177
- });
204
+ if (self.isEmpty() || append) {
205
+ self.tasks.push(newTaskItem);
206
+ } else {
207
+ self.tasks.unshift(newTaskItem);
208
+ }
209
+ });
178
210
 
179
- self.updateTaskSchedule();
211
+ self.updateTaskSchedule();
180
212
 
181
- return promise;
182
- };
213
+ return promise;
214
+ };
183
215
 
184
216
  /**
185
217
  * Appends a new task at the end of the queue.
186
218
  * @param {function} task - The task to perform. This function will be called with no arguments.
187
219
  * @return {Promise} A promise which is resolved/rejected When the task was executed by the queue
188
220
  */
189
- PromiseQueue.prototype.append = function (task) {
190
- return this.add(task, true);
191
- };
221
+ async append(task) {
222
+ return this.add(task, true);
223
+ };
192
224
 
193
225
  /**
194
226
  * Adds a new task as first item in the queue.
195
227
  * @param task
196
228
  * @return {Promise} A promise which is resolved/rejected When the task was executed by the queue
197
229
  */
198
- PromiseQueue.prototype.prepend = function (task) {
199
- return this.add(task, false);
200
- };
230
+ async prepend(task) {
231
+ return this.add(task, false);
232
+ };
201
233
 
202
234
  /**
203
235
  * Removes the task from the qeueue. If the task is contained more than one time then all occurrences will be removed.
204
236
  * @param {function} task - The task to remove.
205
237
  * @return {number} - The number of items which were removed.
206
238
  */
207
- PromiseQueue.prototype.remove = function (task) {
208
- if (this.isEmpty()) {
209
- return 0;
210
- }
239
+ remove(task) {
240
+ if (this.isEmpty()) {
241
+ return 0;
242
+ }
211
243
 
212
- var removedItems = 0;
213
- for (var i = this.tasks.length - 1; i >= 0; i--) {
214
- if (this.tasks[i].task === task) {
215
- this.tasks.splice(i, 1);
216
- removedItems++;
217
- }
218
- }
244
+ var removedItems = 0;
245
+ for (var i = this.tasks.length - 1; i >= 0; i--) {
246
+ if (this.tasks[i].task === task) {
247
+ this.tasks.splice(i, 1);
248
+ removedItems++;
249
+ }
250
+ }
219
251
 
220
- return removedItems;
221
- };
252
+ return removedItems;
253
+ };
222
254
 
223
255
  /**
224
256
  * @returns {Number} - The number of queued/waiting tasks in the queue.
225
257
  */
226
- PromiseQueue.prototype.getQueueSize = function () {
227
- return this.tasks.length;
228
- };
258
+ getQueueSize() {
259
+ return this.tasks.length;
260
+ };
261
+
262
+ };
229
263
 
230
- module.exports = PromiseQueue;
231
- })();
264
+ export default PromiseQueue = new PromiseQueueClass(1, null);