@tsdotnet/queue 1.3.1 → 1.4.0
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/LICENSE +21 -21
- package/README.md +11 -12
- package/dist/{LinkQueue.d.ts → cjs/LinkQueue.d.ts} +1 -16
- package/dist/cjs/LinkQueue.js +2 -17
- package/dist/cjs/LinkQueue.js.map +1 -1
- package/dist/{Queue.d.ts → cjs/Queue.d.ts} +1 -13
- package/dist/cjs/Queue.js +6 -26
- package/dist/cjs/Queue.js.map +1 -1
- package/dist/cjs/QueueBase.d.ts +27 -0
- package/dist/cjs/QueueBase.js +0 -53
- package/dist/cjs/QueueBase.js.map +1 -1
- package/dist/cjs/index.d.ts +5 -0
- package/dist/cjs/index.js +12 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/package.json +1 -0
- package/dist/esm/LinkQueue.js +6 -18
- package/dist/esm/LinkQueue.js.map +1 -1
- package/dist/esm/Queue.js +10 -27
- package/dist/esm/Queue.js.map +1 -1
- package/dist/esm/QueueBase.js +7 -57
- package/dist/esm/QueueBase.js.map +1 -1
- package/dist/esm/index.js +8 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/types/LinkQueue.d.ts +19 -0
- package/dist/types/Queue.d.ts +19 -0
- package/dist/types/QueueBase.d.ts +27 -0
- package/dist/types/index.d.ts +5 -0
- package/dist/umd/package.json +1 -0
- package/dist/umd/queue.js +313 -0
- package/dist/umd/queue.js.map +1 -0
- package/dist/umd/queue.min.js +10 -0
- package/dist/umd/queue.min.js.map +1 -0
- package/package.json +69 -65
- package/dist/QueueBase.d.ts +0 -106
- package/dist/umd/LinkQueue.js +0 -117
- package/dist/umd/LinkQueue.js.map +0 -1
- package/dist/umd/Queue.js +0 -175
- package/dist/umd/Queue.js.map +0 -1
- package/dist/umd/QueueBase.js +0 -139
- package/dist/umd/QueueBase.js.map +0 -1
- package/eslint.config.mjs +0 -23
package/dist/umd/QueueBase.js
DELETED
|
@@ -1,139 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* @author electricessence / https://github.com/electricessence/
|
|
3
|
-
* @license MIT
|
|
4
|
-
*/
|
|
5
|
-
(function (factory) {
|
|
6
|
-
if (typeof module === "object" && typeof module.exports === "object") {
|
|
7
|
-
var v = factory(require, exports);
|
|
8
|
-
if (v !== undefined) module.exports = v;
|
|
9
|
-
}
|
|
10
|
-
else if (typeof define === "function" && define.amd) {
|
|
11
|
-
define(["require", "exports", "@tsdotnet/collection-base", "@tsdotnet/exceptions"], factory);
|
|
12
|
-
}
|
|
13
|
-
})(function (require, exports) {
|
|
14
|
-
"use strict";
|
|
15
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
-
const collection_base_1 = require("@tsdotnet/collection-base");
|
|
17
|
-
const exceptions_1 = require("@tsdotnet/exceptions");
|
|
18
|
-
class QueueBase extends collection_base_1.IterableCollectionBase {
|
|
19
|
-
/**
|
|
20
|
-
* The number of items currently in the queue.
|
|
21
|
-
* @returns {number}
|
|
22
|
-
*/
|
|
23
|
-
get count() {
|
|
24
|
-
return this.getCount();
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* Returns true if the queue is empty.
|
|
28
|
-
* @return {boolean}
|
|
29
|
-
*/
|
|
30
|
-
get isEmpty() {
|
|
31
|
-
return this.getCount() === 0;
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* Adds an item to the end of the queue.
|
|
35
|
-
* @param value
|
|
36
|
-
* @returns {this}
|
|
37
|
-
*/
|
|
38
|
-
enqueue(value) {
|
|
39
|
-
this._enqueueInternal(value);
|
|
40
|
-
this.incrementVersion();
|
|
41
|
-
return this;
|
|
42
|
-
}
|
|
43
|
-
/**
|
|
44
|
-
* Adds items to the end of the queue.
|
|
45
|
-
* @param {Iterable} values
|
|
46
|
-
* @returns {this}
|
|
47
|
-
*/
|
|
48
|
-
enqueueMultiple(values) {
|
|
49
|
-
if (!values)
|
|
50
|
-
return this;
|
|
51
|
-
let hasValues = false;
|
|
52
|
-
for (const v of values) {
|
|
53
|
-
hasValues = true;
|
|
54
|
-
this._enqueueInternal(v);
|
|
55
|
-
}
|
|
56
|
-
if (hasValues)
|
|
57
|
-
this.incrementVersion();
|
|
58
|
-
return this;
|
|
59
|
-
}
|
|
60
|
-
/**
|
|
61
|
-
* Adds items to the end of the queue.
|
|
62
|
-
* @param values
|
|
63
|
-
* @returns {this}
|
|
64
|
-
*/
|
|
65
|
-
enqueueThese(...values) {
|
|
66
|
-
return this.enqueueMultiple(values);
|
|
67
|
-
}
|
|
68
|
-
/**
|
|
69
|
-
* Produces an iterable that dequeues items when iterated. Stops when empty.
|
|
70
|
-
* @return {Iterable}
|
|
71
|
-
*/
|
|
72
|
-
consumer() {
|
|
73
|
-
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
74
|
-
const _ = this;
|
|
75
|
-
return {
|
|
76
|
-
*[Symbol.iterator]() {
|
|
77
|
-
while (_.getCount()) {
|
|
78
|
-
yield _.dequeue(true);
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
};
|
|
82
|
-
}
|
|
83
|
-
/**
|
|
84
|
-
* Pulls an entry from the head of the queue and returns it.
|
|
85
|
-
* Returns undefined if the queue is already empty and throwIfEmpty is false.
|
|
86
|
-
* @throws {InvalidOperationException} If the queue is already empty and throwIfEmpty is true.
|
|
87
|
-
* @param throwIfEmpty
|
|
88
|
-
*/
|
|
89
|
-
dequeue(throwIfEmpty = false) {
|
|
90
|
-
if (throwIfEmpty && this.isEmpty)
|
|
91
|
-
throw new exceptions_1.InvalidOperationException('Cannot dequeue an empty queue.');
|
|
92
|
-
const item = this._dequeueInternal();
|
|
93
|
-
this.incrementVersion();
|
|
94
|
-
return item;
|
|
95
|
-
}
|
|
96
|
-
/**
|
|
97
|
-
* Checks to see if the queue has entries an pulls an entry from the head of the queue and passes it to the out handler.
|
|
98
|
-
* @throws {ArgumentNullException} If no out delegate was specified.
|
|
99
|
-
* @param out The 'out' handler that receives the value if it exists.
|
|
100
|
-
* @returns {boolean} True if a value was retrieved. False if not.
|
|
101
|
-
*/
|
|
102
|
-
tryDequeue(out) {
|
|
103
|
-
if (!out)
|
|
104
|
-
throw new exceptions_1.ArgumentNullException('out');
|
|
105
|
-
if (this.isEmpty)
|
|
106
|
-
return false;
|
|
107
|
-
const item = this._dequeueInternal();
|
|
108
|
-
this.incrementVersion();
|
|
109
|
-
out(item);
|
|
110
|
-
return true;
|
|
111
|
-
}
|
|
112
|
-
/**
|
|
113
|
-
* Returns the entry at the head of the queue.
|
|
114
|
-
* Returns undefined if the queue is already empty and throwIfEmpty is false.
|
|
115
|
-
* @throws {InvalidOperationException} If the queue is already empty and throwIfEmpty is true.
|
|
116
|
-
* @param {boolean} throwIfEmpty
|
|
117
|
-
* @return {T | undefined}
|
|
118
|
-
*/
|
|
119
|
-
peek(throwIfEmpty = false) {
|
|
120
|
-
if (throwIfEmpty && this.isEmpty)
|
|
121
|
-
throw new exceptions_1.InvalidOperationException('Cannot call peek on an empty queue.');
|
|
122
|
-
return this._peekInternal();
|
|
123
|
-
}
|
|
124
|
-
/**
|
|
125
|
-
* Clears the list.
|
|
126
|
-
*/
|
|
127
|
-
dispose() {
|
|
128
|
-
this.clear();
|
|
129
|
-
}
|
|
130
|
-
/**
|
|
131
|
-
* Clears the list.
|
|
132
|
-
*/
|
|
133
|
-
recycle() {
|
|
134
|
-
this.clear();
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
exports.default = QueueBase;
|
|
138
|
-
});
|
|
139
|
-
//# sourceMappingURL=QueueBase.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"QueueBase.js","sourceRoot":"","sources":["../../src/QueueBase.ts"],"names":[],"mappings":"AAAA;;;GAGG;;;;;;;;;;;;IAEH,+DAAiE;IACjE,qDAAsF;IAEtF,MAA8B,SAC7B,SAAQ,wCAAyB;QAEjC;;;WAGG;QACH,IAAI,KAAK;YAER,OAAO,IAAI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AC,gBAAgB,EAAG,CAAC;YACtC,IAAI,CAAC,gBAAgB,EAAE,CAAC;YACxB,OAAO,IAAI,CAAC;QACb,CAAC;QAED;;;;;WAKG;QACH,UAAU,CAAE,GAA0B;YAErC,IAAG,CAAC,GAAG;gBAAE,MAAM,IAAI,kCAAqB,CAAC,KAAK,CAAC,CAAC;YAChD,IAAG,IAAI,CAAC,OAAO;gBAAE,OAAO,KAAK,CAAC;YAC9B,MAAM,IAAI,GAAG,IAAI,CAAC,gBAAgB,EAAG,CAAC;YACtC,IAAI,CAAC,gBAAgB,EAAE,CAAC;YACxB,GAAG,CAAC,IAAI,CAAC,CAAC;YACV,OAAO,IAAI,CAAC;QACb,CAAC;QAwBD;;;;;;WAMG;QACH,IAAI,CAAE,eAAwB,KAAK;YAElC,IAAG,YAAY,IAAI,IAAI,CAAC,OAAO;gBAAE,MAAM,IAAI,sCAAyB,CAAC,qCAAqC,CAAC,CAAC;YAC5G,OAAO,IAAI,CAAC,aAAa,EAAE,CAAC;QAC7B,CAAC;QAcD;;WAEG;QACH,OAAO;YAEN,IAAI,CAAC,KAAK,EAAE,CAAC;QACd,CAAC;QAED;;WAEG;QACH,OAAO;YAEN,IAAI,CAAC,KAAK,EAAE,CAAC;QACd,CAAC;KAOD;IAxMD,4BAwMC"}
|
package/eslint.config.mjs
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import eslint from '@eslint/js';
|
|
2
|
-
import tseslint from 'typescript-eslint';
|
|
3
|
-
|
|
4
|
-
export default tseslint.config(
|
|
5
|
-
eslint.configs.recommended,
|
|
6
|
-
...tseslint.configs.recommended,
|
|
7
|
-
{
|
|
8
|
-
rules: {
|
|
9
|
-
"semi": ["warn", "always"],
|
|
10
|
-
"indent": ["warn", "tab", { "SwitchCase": 1 }],
|
|
11
|
-
"@typescript-eslint/no-explicit-any": "off"
|
|
12
|
-
},
|
|
13
|
-
files: ['src/**/*.ts'],
|
|
14
|
-
languageOptions: {
|
|
15
|
-
ecmaVersion: 2022,
|
|
16
|
-
sourceType: 'module',
|
|
17
|
-
globals: {
|
|
18
|
-
console: 'readonly',
|
|
19
|
-
process: 'readonly'
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
);
|