@common.js/yocto-queue
Advanced tools
Comparing version
@@ -51,2 +51,9 @@ export default class Queue<ValueType> implements Iterable<ValueType> { | ||
/** | ||
Get the next value in the queue without removing it. | ||
@returns The value or `undefined` if the queue is empty. | ||
*/ | ||
peek(): ValueType | undefined; | ||
/** | ||
Clear the queue. | ||
@@ -53,0 +60,0 @@ */ |
11
index.js
@@ -260,2 +260,13 @@ /* | ||
{ | ||
key: "peek", | ||
value: function peek() { | ||
if (!_classPrivateFieldGet(this, _head)) { | ||
return; | ||
} | ||
return _classPrivateFieldGet(this, _head).value; | ||
// TODO: Node.js 18. | ||
// return this.#head?.value; | ||
} | ||
}, | ||
{ | ||
key: "clear", | ||
@@ -262,0 +273,0 @@ value: function clear() { |
{ | ||
"name": "@common.js/yocto-queue", | ||
"version": "1.0.0", | ||
"description": "Tiny queue data structure", | ||
"version": "1.1.1", | ||
"description": "yocto-queue package exported as CommonJS modules", | ||
"license": "MIT", | ||
@@ -9,2 +9,4 @@ "repository": "etienne-martin/common.js", | ||
"type": "commonjs", | ||
"types": "./index.d.ts", | ||
"sideEffects": false, | ||
"engines": { | ||
@@ -11,0 +13,0 @@ "node": ">=12.20" |
@@ -5,2 +5,2 @@ # @common.js/yocto-queue | ||
Exported from [yocto-queue@1.0.0](https://www.npmjs.com/package/yocto-queue/v/1.0.0) using https://github.com/etienne-martin/common.js. | ||
Exported from [yocto-queue@1.1.1](https://www.npmjs.com/package/yocto-queue/v/1.1.1) using https://github.com/etienne-martin/common.js. |
366
4.57%14107
-9.73%5
-16.67%