@leaddreamer/inventorylogic 0.0.3-beta.82 → 0.0.3-beta.83

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.
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "engines": {
4
4
  "node": ">=22"
5
5
  },
6
- "version": "0.0.3-beta.82",
6
+ "version": "0.0.3-beta.83",
7
7
  "description": "Business & Database Logic for Inventory Services",
8
8
  "repository": {
9
9
  "type": "git",
@@ -33,9 +33,7 @@
33
33
  "type": "module",
34
34
  "scripts": {
35
35
  "reinstall": "rm -rf node_modules && rm -rf dist && npm install",
36
- "mybuild": "parcel build --dist-dir './dist'",
37
36
  "release:rebuild": "$npm_execpath version minor --git-tag-version && $npm_execpath run docs",
38
- "myprepublishOnly": "$npm_execpath run build",
39
37
  "make_docs": "jsdoc2md -c jsdoc.conf.json --template README.hbs --files *.js ./business/*.js ./business/*/*.js > README.md",
40
38
  "docs": "$npm_execpath run make_docs",
41
39
  "beta:rebuild": "$npm_execpath version prerelease --git-tag-version --preid=beta && $npm_execpath run docs",
@@ -49,12 +47,9 @@
49
47
  },
50
48
  "dependencies": {
51
49
  "@leaddreamer/firebase-wrapper": "^2.1.2-beta.0",
52
- "@leaddreamer/genericutilities": "^0.2.7",
50
+ "@leaddreamer/genericutilities": "^0.2.8",
53
51
  "@leaddreamer/staticforms": "^1.1.0",
54
- "lodash.clonedeep": "4.5.0",
55
- "dayjs": "1.11.23",
56
- "mathjs": "15.2.0",
57
- "uuid": "14.0.1"
52
+ "lodash.clonedeep": "4.5.0"
58
53
  },
59
54
  "peerDependencies": {
60
55
  "firebase": "12.16.0",
@@ -69,10 +64,7 @@
69
64
  }
70
65
  },
71
66
  "devDependencies": {
72
- "accounting-js": "2.0.3",
73
- "jsdoc-to-markdown": "9.1.3",
74
- "@parcel/bundler-library": "^2.16.4",
75
- "parcel": "latest"
67
+ "jsdoc-to-markdown": "9.1.3"
76
68
  },
77
69
  "keywords": []
78
70
  }
@@ -1,404 +0,0 @@
1
- /**
2
- * Typedefs, constants, support functions and database operations for
3
- * general Utilities
4
- * @module Utilities
5
- */
6
- import dayjs from "dayjs";
7
- //import promisePool from "es6-promise-pool";
8
- import isSameOrAfter from "dayjs/plugin/isSameOrAfter.js";
9
- import isSameOrBefore from "dayjs/plugin/isSameOrBefore.js";
10
- import {
11
- fetchRecordByRefPath,
12
- runTransaction,
13
- writeBack,
14
- deleteRecordByRefPath,
15
- } from "@leaddreamer/firebase-wrapper";
16
- //the following inits the dayjs plugins
17
-
18
- dayjs.extend(isSameOrAfter);
19
- dayjs.extend(isSameOrBefore);
20
-
21
- /**
22
- * A convenience function for some shared artist/host front-end pages
23
- * @param {OrganizationType} host
24
- * @returns {Promise.OrganizationType}
25
- */
26
- export async function saveHost(host, batch = null) {
27
- return writeBack(host, batch);
28
- }
29
-
30
- /**
31
- * Simple top-level object compare - assumes objects have similar structure - or
32
- * AT LEAST all the fields of object1 are present in object2
33
- * @param {object} object1
34
- * @param {object} object2
35
- * @returns {boolean}
36
- */
37
- export function simpleObjectCompare(object1, object2) {
38
- let result = Object.keys(object1).reduce((accumulate, key) => {
39
- // eslint-disable-next-line
40
- return object1[key] == object2[key] ? accumulate : false;
41
- }, true); // note simple (not object) compare
42
- return result;
43
- }
44
-
45
- /**
46
- * Allows string substitution from an object
47
- * field names support Dot notation
48
- * field names allow ":" extension for alternate formatting
49
- * @param {object} thisItem - object to create formated string from
50
- * @param {string} thisFormat - string describing formatted output - fieldname wrapped in {} will be substituted. DOT notation allowed for fields.
51
- * @returns {string}
52
- */
53
- export function formatItem(thisObject, thisFormat) {
54
- let final = thisFormat.replace(
55
- /{.+?}/g, //global, non-greedy - i.e. multiple {} bracketed elements
56
- function (field) {
57
- let fieldRaw = field.slice(1, -1);
58
- //below allows for DOT notation access within the item object
59
- let fieldparts = fieldRaw.split(":");
60
- let [fieldname, fieldStyle] = fieldparts;
61
- let fieldArray = fieldname.split(".");
62
- //below walks into an object - note: ASSUMES an object
63
- const bob = fieldArray.reduce((lastObject, nextName) => {
64
- return lastObject[nextName];
65
- }, thisObject);
66
- return bob ? specialFormat(bob, fieldStyle) : "----";
67
- }
68
- );
69
- return final;
70
- }
71
-
72
- /**
73
- * @private
74
- * @param {any} value
75
- * @param {!string} style
76
- * @returns {any|string}
77
- */
78
- function specialFormat(value, style) {
79
- switch (style) {
80
- case "timestamp":
81
- return dayjs(value.toDate()).format("MMM DD, YYYY");
82
- default:
83
- return value;
84
- }
85
- }
86
-
87
- /**
88
- * @param {object} thisItem - one of two objects being compared
89
- * @param {object} anotherItem - the other of two objects being compared
90
- * @param {!string} sort - string describing sort - format "fieldName:sortType" - sort Type is "string, "date" or "number" (default)
91
- * @return {string}
92
- */
93
- export function compare(thisItem, anotherItem, sort = "Id:number") {
94
- let [field, type] = sort.split(":");
95
- type = type ? type : "number";
96
- switch (type) {
97
- case "string":
98
- let nameArray = thisItem[field].split("The ");
99
- let anotherArray = anotherItem[field].split("The ");
100
- return (nameArray[0] ? nameArray[0] : nameArray[1]).localeCompare(
101
- anotherArray[0] ? anotherArray[0] : anotherArray[1]
102
- );
103
-
104
- case "date":
105
- //if (!thisItem[field] || !anotherItem[field]) return 0;
106
- return !thisItem[field] ||
107
- dayjs(thisItem[field]).isBefore(anotherItem[field], "day")
108
- ? -1
109
- : anotherItem[field] &&
110
- dayjs(thisItem[field]).isSame(anotherItem[field], "day")
111
- ? 0
112
- : 1;
113
-
114
- default:
115
- return Number(thisItem[field]) - Number(anotherItem[field]);
116
- }
117
- }
118
-
119
- /**
120
- * An array based compare function - is any entry of findFrom present in findIn
121
- * @param {Array.any} findFrom
122
- * @param {Array.any} findIn
123
- * @returns {boolean}
124
- */
125
- export function anyInAny(findFrom, findIn) {
126
- let mapFindIn = new Map();
127
-
128
- findIn.forEach((entry, index) => {
129
- mapFindIn.set(entry, true);
130
- }); //speed up by avoiding second loop
131
-
132
- const findFromLength = findFrom.length;
133
- let found = false;
134
- for (
135
- let findFromIndex = 0;
136
- findFromIndex < findFromLength && !found;
137
- findFromIndex++
138
- )
139
- if (
140
- mapFindIn.get(findFrom[findFromIndex].valueOf())
141
- //findFrom[findFromIndex].valueOf() === findIn[arrayTwoIndex].valueOf()
142
- )
143
- found = true; //note this breaks both loops
144
-
145
- return found;
146
- }
147
-
148
- /**
149
- * A convenience function for legibility
150
- * @param {any} args unbounded list of arguments
151
- * @returns {number} the least of any of the arguments
152
- b */
153
- export function lesserOf(...args) {
154
- return Math.min(...args);
155
- }
156
-
157
- /**
158
- * @param {any} args unbounded list of arguments
159
- * @returns {number} the largest of any of the arguments
160
- */
161
- export function largerOf(...args) {
162
- return Math.max(...args);
163
- }
164
-
165
- /**
166
- * "Moves" a record from our standard tree structureto a parallel archival
167
- * structure, by prepending a "_" to the collection names in the path
168
- * This prevents the archived record from appearing in collectionGroup queries
169
- * @param {RecordDocument} record
170
- * @param {!string} record.refPath
171
- * @returns {Promise}
172
- */
173
- export async function archiveRecord(record) {
174
- //split the reference path into it's constituent parts
175
- const parts = record.refPath.split("/");
176
- const partsCount = parts.length;
177
- if (Math.floor(partsCount / 2) * 2 !== partsCount) {
178
- //throw "safe" error
179
- return; //returns a null promise resolved
180
- }
181
-
182
- let archivePath = "";
183
- let index = 0;
184
- //adde a "_" to the start of every collection named in the path
185
- //this avoids collectionGroup issues, but follows a parallel path
186
- do {
187
- archivePath = `${archivePath}/_${parts[index]}/${parts[index + 1]}`;
188
- index += 2;
189
- } while (index < partsCount);
190
- await runTransaction(async (batch) => {
191
- //////////////////////////////
192
- //Read a current full copy of the record
193
- const realRecord = await fetchRecordByRefPath(record.refPath, batch);
194
- //Write it to the "archivePath"
195
- await writeBack({ ...realRecord, refPath: archivePath }, batch);
196
- //delete the original copy
197
- await deleteRecordByRefPath(realRecord.refPath, batch);
198
- });
199
- }
200
-
201
- /**
202
- * uses a passed refPath to create the most basic document record form
203
- * @param {!string} refPath - "/" separated document path reference
204
- * @returns {RecordDocument}
205
- */
206
- export function refPathToBaseRecord(refPath) {
207
- return {
208
- Id: refPath.split("/").pop(),
209
- refPath: refPath,
210
- };
211
- }
212
-
213
- /**
214
- * clips value to given bounds
215
- * @param {number} value
216
- * @param {number} lowerBound
217
- * @param {number} upperBound
218
- * @returns {number}
219
- */
220
- export function bound(value, lowerBound, upperBound) {
221
- return largerOf(lesserOf(value, upperBound), lowerBound);
222
- }
223
-
224
- /**
225
- * function to push an element to an array which may not be initialized
226
- * @param {Array.object} targetArray
227
- * @param {object} newObject
228
- *
229
- */
230
- export function blindPush(targetArray, newObject) {
231
- targetArray
232
- ? targetArray.push(newObject)
233
- : (targetArray = [newObject]);
234
- return targetArray;
235
- }
236
-
237
- /**
238
- * @param {Array.Array.object} arrayObject
239
- * @param {string} key key or index to choose which Array.object to add *this* object to
240
- * @param {object} object
241
- */
242
- export function addToArrayObject(arrayObject, key, object) {
243
- if (arrayObject[key] && arrayObject[key].length) {
244
- //if the key is already present, *and* there are already objects in the keyed array
245
- arrayObject[key].push(object); //push the object onto the indexed array
246
- } else {
247
- arrayObject[key] = [object];
248
- }
249
- }
250
-
251
-
252
-
253
- /**
254
- * @param {string} color name of color
255
- * @returns {string} hex value of named color
256
- */
257
- export function makeHexAsNeeded(color) {
258
- var colours = {
259
- aliceblue: "#f0f8ff",
260
- antiquewhite: "#faebd7",
261
- aqua: "#00ffff",
262
- aquamarine: "#7fffd4",
263
- azure: "#f0ffff",
264
- beige: "#f5f5dc",
265
- bisque: "#ffe4c4",
266
- black: "#000000",
267
- blanchedalmond: "#ffebcd",
268
- blue: "#0000ff",
269
- blueviolet: "#8a2be2",
270
- brown: "#a52a2a",
271
- burlywood: "#deb887",
272
- cadetblue: "#5f9ea0",
273
- chartreuse: "#7fff00",
274
- chocolate: "#d2691e",
275
- coral: "#ff7f50",
276
- cornflowerblue: "#6495ed",
277
- cornsilk: "#fff8dc",
278
- crimson: "#dc143c",
279
- cyan: "#00ffff",
280
- darkblue: "#00008b",
281
- darkcyan: "#008b8b",
282
- darkgoldenrod: "#b8860b",
283
- darkgray: "#a9a9a9",
284
- darkgreen: "#006400",
285
- darkkhaki: "#bdb76b",
286
- darkmagenta: "#8b008b",
287
- darkolivegreen: "#556b2f",
288
- darkorange: "#ff8c00",
289
- darkorchid: "#9932cc",
290
- darkred: "#8b0000",
291
- darksalmon: "#e9967a",
292
- darkseagreen: "#8fbc8f",
293
- darkslateblue: "#483d8b",
294
- darkslategray: "#2f4f4f",
295
- darkturquoise: "#00ced1",
296
- darkviolet: "#9400d3",
297
- deeppink: "#ff1493",
298
- deepskyblue: "#00bfff",
299
- dimgray: "#696969",
300
- dodgerblue: "#1e90ff",
301
- firebrick: "#b22222",
302
- floralwhite: "#fffaf0",
303
- forestgreen: "#228b22",
304
- fuchsia: "#ff00ff",
305
- gainsboro: "#dcdcdc",
306
- ghostwhite: "#f8f8ff",
307
- gold: "#ffd700",
308
- goldenrod: "#daa520",
309
- gray: "#808080",
310
- green: "#008000",
311
- greenyellow: "#adff2f",
312
- honeydew: "#f0fff0",
313
- hotpink: "#ff69b4",
314
- "indianred ": "#cd5c5c",
315
- indigo: "#4b0082",
316
- ivory: "#fffff0",
317
- khaki: "#f0e68c",
318
- lavender: "#e6e6fa",
319
- lavenderblush: "#fff0f5",
320
- lawngreen: "#7cfc00",
321
- lemonchiffon: "#fffacd",
322
- lightblue: "#add8e6",
323
- lightcoral: "#f08080",
324
- lightcyan: "#e0ffff",
325
- lightgoldenrodyellow: "#fafad2",
326
- lightgrey: "#d3d3d3",
327
- lightgreen: "#90ee90",
328
- lightpink: "#ffb6c1",
329
- lightsalmon: "#ffa07a",
330
- lightseagreen: "#20b2aa",
331
- lightskyblue: "#87cefa",
332
- lightslategray: "#778899",
333
- lightsteelblue: "#b0c4de",
334
- lightyellow: "#ffffe0",
335
- lime: "#00ff00",
336
- limegreen: "#32cd32",
337
- linen: "#faf0e6",
338
- magenta: "#ff00ff",
339
- maroon: "#800000",
340
- mediumaquamarine: "#66cdaa",
341
- mediumblue: "#0000cd",
342
- mediumorchid: "#ba55d3",
343
- mediumpurple: "#9370d8",
344
- mediumseagreen: "#3cb371",
345
- mediumslateblue: "#7b68ee",
346
- mediumspringgreen: "#00fa9a",
347
- mediumturquoise: "#48d1cc",
348
- mediumvioletred: "#c71585",
349
- midnightblue: "#191970",
350
- mintcream: "#f5fffa",
351
- mistyrose: "#ffe4e1",
352
- moccasin: "#ffe4b5",
353
- navajowhite: "#ffdead",
354
- navy: "#000080",
355
- oldlace: "#fdf5e6",
356
- olive: "#808000",
357
- olivedrab: "#6b8e23",
358
- orange: "#ffa500",
359
- orangered: "#ff4500",
360
- orchid: "#da70d6",
361
- palegoldenrod: "#eee8aa",
362
- palegreen: "#98fb98",
363
- paleturquoise: "#afeeee",
364
- palevioletred: "#d87093",
365
- papayawhip: "#ffefd5",
366
- peachpuff: "#ffdab9",
367
- peru: "#cd853f",
368
- pink: "#ffc0cb",
369
- plum: "#dda0dd",
370
- powderblue: "#b0e0e6",
371
- purple: "#800080",
372
- rebeccapurple: "#663399",
373
- red: "#ff0000",
374
- rosybrown: "#bc8f8f",
375
- royalblue: "#4169e1",
376
- saddlebrown: "#8b4513",
377
- salmon: "#fa8072",
378
- sandybrown: "#f4a460",
379
- seagreen: "#2e8b57",
380
- seashell: "#fff5ee",
381
- sienna: "#a0522d",
382
- silver: "#c0c0c0",
383
- skyblue: "#87ceeb",
384
- slateblue: "#6a5acd",
385
- slategray: "#708090",
386
- snow: "#fffafa",
387
- springgreen: "#00ff7f",
388
- steelblue: "#4682b4",
389
- tan: "#d2b48c",
390
- teal: "#008080",
391
- thistle: "#d8bfd8",
392
- tomato: "#ff6347",
393
- turquoise: "#40e0d0",
394
- violet: "#ee82ee",
395
- wheat: "#f5deb3",
396
- white: "#ffffff",
397
- whitesmoke: "#f5f5f5",
398
- yellow: "#ffff00",
399
- yellowgreen: "#9acd32",
400
- };
401
-
402
- if (colours[color.toLowerCase()]) return colours[color.toLowerCase()];
403
- return color;
404
- }
@@ -1,266 +0,0 @@
1
- /**
2
- * Typedefs, constants, support functions and database operations related to Promise getQueueSize
3
- * Thes are useful for scheduling large serial asynchronous operations
4
- * @module PromiseQueue
5
- */
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
- }
57
-
58
- /**
59
- * Processes the next task and returns the id of the time used to wait for the next invocation of this method.
60
- * @private
61
- */
62
- updateTaskSchedule() {
63
- if (this.logger && this.logger.debug) {
64
- this.logger.debug("PromiseQueue.updateTaskSchedule");
65
- }
66
-
67
- if (this.isEmpty() || this.isStopped()) {
68
- return;
69
- }
70
-
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
- }
97
- }
98
-
99
- function scheduleNext(timeoutMillisOverride) {
100
- if (queue.logger && queue.logger.debug) {
101
- queue.logger.debug("PromiseQueue.scheduleNext", timeoutMillisOverride);
102
- }
103
-
104
- if (queue.isEmpty()) {
105
- queue.currentTaskTimeoutId = null;
106
- return;
107
- }
108
-
109
- queue.currentTaskTimeoutId = setTimeout(function () {
110
- queue.lastTaskTimestamp = Date.now();
111
- processNextTask();
112
-
113
- scheduleNext(queue.jobIntervalMillis);
114
- }, timeoutMillisOverride);
115
- }
116
-
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
- }
128
- }
129
- };
130
-
131
- /**
132
- * Starts the task processing of this queue.
133
- *
134
- * If it is already started, then false will be returned.
135
- * If it is not yet started then the first task will be processed in the background and true will be returned.
136
- *
137
- * @return {boolean} true if this queue wasn't started before and now started to process tasks.
138
- */
139
- start() {
140
- if (this.isActive) {
141
- return false;
142
- }
143
-
144
- this.isActive = true;
145
-
146
- this.updateTaskSchedule();
147
-
148
- return true;
149
- };
150
-
151
- /**
152
- * Stops the processing of this queue.
153
- * @return true if the queue was started and is now stopped. false if it was already stopped.
154
- */
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
- };
166
-
167
- getMaxCallsPerSecond() {
168
- return this.maxCallsPerSecond;
169
- };
170
-
171
- isStarted() {
172
- return this.isActive;
173
- };
174
-
175
- isStopped() {
176
- return !this.isStarted();
177
- };
178
-
179
- /**
180
- * @returns {boolean} true if this queue is currently empty, i.e. if it has no tasks in the queue.
181
- */
182
- isEmpty() {
183
- return this.tasks.length === 0;
184
- };
185
-
186
- /**
187
- * @returns {boolean} true if this queue has one or more entries.
188
- */
189
- isNotEmpty() {
190
- return !this.isEmpty();
191
- };
192
-
193
- /**
194
- * @param {function} task - The task to add.
195
- * @param {boolean} append - if the task should be appended or prepended to the list of queued tasks
196
- * @return {Promise} A promise which is resolved/rejected when the task was executed by the queue.
197
- */
198
- async add(task, append) {
199
- var self = this;
200
-
201
- var promise = new Promise(function (resolve, reject) {
202
- var newTaskItem = { task: task, resolve: resolve, reject: reject };
203
-
204
- if (self.isEmpty() || append) {
205
- self.tasks.push(newTaskItem);
206
- } else {
207
- self.tasks.unshift(newTaskItem);
208
- }
209
- });
210
-
211
- self.updateTaskSchedule();
212
-
213
- return promise;
214
- };
215
-
216
- /**
217
- * Appends a new task at the end of the queue.
218
- * @param {function} task - The task to perform. This function will be called with no arguments.
219
- * @return {Promise} A promise which is resolved/rejected When the task was executed by the queue
220
- */
221
- async append(task) {
222
- return this.add(task, true);
223
- };
224
-
225
- /**
226
- * Adds a new task as first item in the queue.
227
- * @param task
228
- * @return {Promise} A promise which is resolved/rejected When the task was executed by the queue
229
- */
230
- async prepend(task) {
231
- return this.add(task, false);
232
- };
233
-
234
- /**
235
- * Removes the task from the qeueue. If the task is contained more than one time then all occurrences will be removed.
236
- * @param {function} task - The task to remove.
237
- * @return {number} - The number of items which were removed.
238
- */
239
- remove(task) {
240
- if (this.isEmpty()) {
241
- return 0;
242
- }
243
-
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
- }
251
-
252
- return removedItems;
253
- };
254
-
255
- /**
256
- * @returns {Number} - The number of queued/waiting tasks in the queue.
257
- */
258
- getQueueSize() {
259
- return this.tasks.length;
260
- };
261
-
262
- };
263
-
264
- var PromiseQueue = new PromiseQueueClass(1, null);
265
-
266
- export default PromiseQueue;