Comparing version 0.0.0 to 0.0.1
{ | ||
"name": "stac", | ||
"version": "0.0.0", | ||
"version": "0.0.1", | ||
"description": "Maintain a sorted stack of things.", | ||
@@ -5,0 +5,0 @@ "main": "stac.js", |
11
stac.js
@@ -7,2 +7,3 @@ | ||
this._options = options; | ||
this._sorted = false; | ||
@@ -17,2 +18,6 @@ this._stack = []; | ||
}; | ||
this.__defineGetter__('length', function () { | ||
return self._stack.length; | ||
}); | ||
} | ||
@@ -116,6 +121,8 @@ | ||
Stac.prototype.length = function () { | ||
return this._stack.length; | ||
Stac.prototype.clone = function () { | ||
var clone = new Stac(this._options); | ||
clone._stack = this._stack.slice(0); | ||
return clone; | ||
}; | ||
module.exports = Stac; |
@@ -37,6 +37,6 @@ var Stac = require('../'); | ||
stack.remove('two'); | ||
assert.equal(stack.length(), 2); | ||
assert.equal(stack.length, 2); | ||
stack.remove('foo'); | ||
assert.equal(stack.length(), 2); | ||
assert.equal(stack.length, 2); | ||
}); | ||
@@ -60,2 +60,18 @@ | ||
it('clone() - can clone the stack', function () { | ||
var clone; | ||
stack.add('one'); | ||
stack.add('two'); | ||
stack.add('three'); | ||
clone = stack.clone(); | ||
stack.remove('two'); | ||
clone.add('four'); | ||
assert.equal(stack.length, 2); | ||
assert.equal(clone.length, 4); | ||
}); | ||
it('can deal with objects in the stack', function () { | ||
@@ -76,3 +92,3 @@ var brian = { | ||
assert.equal(stack.length(), 1); | ||
assert.equal(stack.length, 1); | ||
assert.equal(stack.pop(), carlos); | ||
@@ -79,0 +95,0 @@ }); |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
7137
192