From e07f8eea1023667b628981aa8b07d0328687dadf Mon Sep 17 00:00:00 2001 From: Yomguithereal Date: Fri, 9 Mar 2018 16:11:59 +0100 Subject: [PATCH] Adding Queue.of and bump 0.19.0 --- CHANGELOG.md | 3 ++- package.json | 2 +- queue.js | 11 +++++++++++ test/queue.js | 6 ++++++ 4 files changed, 20 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a3d30b8d..f54458a4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,9 +1,10 @@ # Changelog -## 0.19.0 (provisional) +## 0.19.0 * Adding `StaticIntervalTree`. * Adding `PointerVector`. +* Adding `Queue.of`. * Adding `Stack.of`. * Improving `Vector` & `BitVector` reallocation performance. * Improving `InvertedIndex` performance. diff --git a/package.json b/package.json index 52aa8352..047156a6 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "mnemonist", - "version": "0.19.0-beta1", + "version": "0.19.0", "description": "Curated collection of data structures for the JavaScript language.", "scripts": { "lint": "eslint ./*.js ./utils ./test", diff --git a/queue.js b/queue.js index f9b899a9..20adfb1a 100644 --- a/queue.js +++ b/queue.js @@ -195,6 +195,17 @@ Queue.from = function(iterable) { return queue; }; +/** + * Static @.of function taking an abitrary number of arguments & converting it + * into a queue. + * + * @param {...any} args + * @return {Queue} + */ +Queue.of = function() { + return Queue.from(arguments); +}; + /** * Exporting. */ diff --git a/test/queue.js b/test/queue.js index 136dcdcc..15983482 100644 --- a/test/queue.js +++ b/test/queue.js @@ -88,6 +88,12 @@ describe('Queue', function() { assert.deepEqual(queue.toArray(), [1, 2, 3]); }); + it('should be possible to create a queue from arbitrary arguments.', function() { + var queue = Queue.of(1, 2, 3); + + assert.deepEqual(queue.toArray(), [1, 2, 3]); + }); + it('should be possible to create a values iterator.', function() { var queue = Queue.from([1, 2, 3]);