@common.js/yocto-queue 1.1.1 → 1.2.3
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/README.md +1 -1
- package/index.d.ts +14 -0
- package/index.js +32 -0
- package/package.json +10 -1
package/README.md
CHANGED
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
|
|
3
3
|
The [yocto-queue](https://www.npmjs.com/package/yocto-queue) package exported as CommonJS modules.
|
|
4
4
|
|
|
5
|
-
Exported from [yocto-queue@1.
|
|
5
|
+
Exported from [yocto-queue@1.2.2](https://www.npmjs.com/package/yocto-queue/v/1.2.2) using https://github.com/etienne-martin/common.js.
|
package/index.d.ts
CHANGED
|
@@ -33,8 +33,22 @@ export default class Queue<ValueType> implements Iterable<ValueType> {
|
|
|
33
33
|
*/
|
|
34
34
|
constructor();
|
|
35
35
|
|
|
36
|
+
/**
|
|
37
|
+
The instance is an [`Iterable`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols), which means you can iterate over the queue front to back with a “for…of” loop. Using the iterator will not remove the items from the queue. If you want that, use `drain()` instead.
|
|
38
|
+
|
|
39
|
+
You can also use spreading to convert the queue to an array. Don't do this unless you really need to though, since it's slow.
|
|
40
|
+
*/
|
|
36
41
|
[Symbol.iterator](): IterableIterator<ValueType>;
|
|
37
42
|
|
|
43
|
+
/**
|
|
44
|
+
Returns an iterator that dequeues items as you consume it.
|
|
45
|
+
|
|
46
|
+
This allows you to empty the queue while processing its items.
|
|
47
|
+
|
|
48
|
+
If you want to not remove items as you consume it, use the `Queue` object as an iterator.
|
|
49
|
+
*/
|
|
50
|
+
drain(): IterableIterator<ValueType>;
|
|
51
|
+
|
|
38
52
|
/**
|
|
39
53
|
Add a value to the queue.
|
|
40
54
|
*/
|
package/index.js
CHANGED
|
@@ -253,6 +253,10 @@ var Queue = /*#__PURE__*/ function() {
|
|
|
253
253
|
}
|
|
254
254
|
_classPrivateFieldSet(this, _head, _classPrivateFieldGet(this, _head).next);
|
|
255
255
|
_classPrivateFieldUpdate(this, _size).value--;
|
|
256
|
+
// Clean up tail reference when queue becomes empty
|
|
257
|
+
if (!_classPrivateFieldGet(this, _head)) {
|
|
258
|
+
_classPrivateFieldSet(this, _tail, undefined);
|
|
259
|
+
}
|
|
256
260
|
return current.value;
|
|
257
261
|
}
|
|
258
262
|
},
|
|
@@ -313,6 +317,34 @@ var Queue = /*#__PURE__*/ function() {
|
|
|
313
317
|
}
|
|
314
318
|
});
|
|
315
319
|
}
|
|
320
|
+
},
|
|
321
|
+
{
|
|
322
|
+
key: "drain",
|
|
323
|
+
value: function drain() {
|
|
324
|
+
return __generator(this, function(_state) {
|
|
325
|
+
switch(_state.label){
|
|
326
|
+
case 0:
|
|
327
|
+
if (!_classPrivateFieldGet(this, _head)) return [
|
|
328
|
+
3,
|
|
329
|
+
2
|
|
330
|
+
];
|
|
331
|
+
return [
|
|
332
|
+
4,
|
|
333
|
+
this.dequeue()
|
|
334
|
+
];
|
|
335
|
+
case 1:
|
|
336
|
+
_state.sent();
|
|
337
|
+
return [
|
|
338
|
+
3,
|
|
339
|
+
0
|
|
340
|
+
];
|
|
341
|
+
case 2:
|
|
342
|
+
return [
|
|
343
|
+
2
|
|
344
|
+
];
|
|
345
|
+
}
|
|
346
|
+
});
|
|
347
|
+
}
|
|
316
348
|
}
|
|
317
349
|
]);
|
|
318
350
|
return Queue;
|
package/package.json
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@common.js/yocto-queue",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.3",
|
|
4
4
|
"description": "yocto-queue package exported as CommonJS modules",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": "etienne-martin/common.js",
|
|
7
7
|
"funding": "https://github.com/sponsors/sindresorhus",
|
|
8
8
|
"type": "commonjs",
|
|
9
|
+
"exports": "./index.js",
|
|
9
10
|
"types": "./index.d.ts",
|
|
10
11
|
"sideEffects": false,
|
|
11
12
|
"engines": {
|
|
@@ -26,5 +27,13 @@
|
|
|
26
27
|
},
|
|
27
28
|
"homepage": "https://github.com/etienne-martin/common.js#readme",
|
|
28
29
|
"dependencies": {},
|
|
30
|
+
"commonjs": {
|
|
31
|
+
"source": {
|
|
32
|
+
"name": "yocto-queue",
|
|
33
|
+
"version": "1.2.2"
|
|
34
|
+
},
|
|
35
|
+
"transformRevision": 1,
|
|
36
|
+
"buildKey": "6a25f69cbff1ba97ef4237e3035370898edda88004722c34f37fc4ad2417f0f8"
|
|
37
|
+
},
|
|
29
38
|
"main": "./index.js"
|
|
30
39
|
}
|