Skip to content

Commit

Permalink
Adding Stack.of
Browse files Browse the repository at this point in the history
  • Loading branch information
Yomguithereal committed Feb 23, 2018
1 parent b4b4f59 commit 0a11e3e
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

* Adding `StaticIntervalTree`.
* Adding `PointerVector`.
* Adding `Stack.of`.
* Improving `Vector` & `BitVector` reallocation performance.
* Improving `InvertedIndex` performance.

Expand Down
11 changes: 11 additions & 0 deletions stack.js
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,17 @@ Stack.from = function(iterable) {
return stack;
};

/**
* Static @.of function taking an abitrary number of arguments & converting it
* into a stack.
*
* @param {...any} args
* @return {Stack}
*/
Stack.of = function() {
return Stack.from(arguments);
};

/**
* Exporting.
*/
Expand Down
6 changes: 6 additions & 0 deletions test/stack.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,12 @@ describe('Stack', function() {
assert.deepEqual(stack.toArray(), [3, 2, 1]);
});

it('should be possible to create a stack from arbitrary arguments.', function() {
var stack = Stack.of(1, 2, 3);

assert.deepEqual(stack.toArray(), [3, 2, 1]);
});

it('should be possible to create a values iterator.', function() {
var stack = Stack.from([1, 2, 3]);

Expand Down

0 comments on commit 0a11e3e

Please sign in to comment.