+1
-1
| { | ||
| "name": "stac", | ||
| "version": "0.0.11", | ||
| "version": "0.0.12", | ||
| "description": "Maintain a sorted stack of things.", | ||
@@ -5,0 +5,0 @@ "main": "stac.js", |
+7
-8
| function Stac(options) { | ||
| var self = this | ||
| , toAdd = null; | ||
| function Stac(options, items) { | ||
| var self = this; | ||
| if (Array.isArray(options)) { | ||
| toAdd = options; | ||
| items = options; | ||
| options = {}; | ||
@@ -26,4 +25,4 @@ } | ||
| if (toAdd) { | ||
| this.multi('add', toAdd); | ||
| if (items) { | ||
| this.multi('add', items); | ||
| } | ||
@@ -168,5 +167,5 @@ } | ||
| module.exports = function createStac (options) { | ||
| return new Stac(options); | ||
| module.exports = function createStac (options, items) { | ||
| return new Stac(options, items); | ||
| }; | ||
| module.exports.Stac = Stac; |
+11
-0
@@ -208,3 +208,14 @@ var createStac = require('../'); | ||
| it('can be created with options and an existing array', function () { | ||
| stack = createStac({sortBy: 'age'}, [ | ||
| {name: 'Joe', age: 23}, | ||
| {name: 'Gramps', age: 67}, | ||
| {name: 'May', age: 34}, | ||
| {name: 'Bobby', age: 12} | ||
| ]); | ||
| assert.equal(stack.pop().name, 'Gramps'); | ||
| assert.equal(stack.shift().name, 'Bobby'); | ||
| }); | ||
| }); | ||
14473
2.46%317
2.92%