observ-array
Advanced tools
Comparing version 1.2.0 to 1.3.0
@@ -7,2 +7,3 @@ var Observ = require("observ") | ||
var splice = require("./splice.js") | ||
var put = require('./put.js') | ||
var ArrayMethods = require("./array-methods.js") | ||
@@ -72,8 +73,4 @@ var addListener = require("./add-listener.js") | ||
function put(index, value) { | ||
this.splice(index, 1, value) | ||
} | ||
function getLength() { | ||
return this._list.length | ||
} |
{ | ||
"name": "observ-array", | ||
"version": "1.2.0", | ||
"version": "1.3.0", | ||
"description": "An array containing observable values", | ||
@@ -5,0 +5,0 @@ "keywords": [], |
@@ -245,1 +245,43 @@ var test = require("tape") | ||
}) | ||
test("can use put to override existing value", function (assert) { | ||
var arr = ObservArray([ Observ("foo"), Observ("bar") ]) | ||
var changes = [] | ||
arr(function (state) { | ||
changes.push(state) | ||
}) | ||
arr.put(0, Observ('baz')) | ||
arr.put(1, Observ('foobar')) | ||
assert.equal(changes.length, 2) | ||
assert.deepEqual(changes[0].slice(), ["baz", "bar"]) | ||
assert.deepEqual(changes[0]._diff, [0, 1, 'baz']) | ||
assert.deepEqual(changes[1].slice(), ["baz", "foobar"]) | ||
assert.deepEqual(changes[1]._diff, [1, 1, 'foobar']) | ||
assert.end() | ||
}) | ||
test("can put values into array beyond length", function (assert) { | ||
var arr = ObservArray([ Observ("foo"), Observ("bar") ]) | ||
var changes = [] | ||
arr(function (state) { | ||
changes.push(state) | ||
}) | ||
var baz = Observ("baz") | ||
arr.put(4, baz) | ||
baz.set("foobaz") | ||
assert.equal(changes.length, 2) | ||
assert.deepEqual(changes[0].slice(), ["foo", "bar", , , "baz"]) | ||
assert.deepEqual(changes[0]._diff, [4, 0, 'baz']) | ||
assert.deepEqual(changes[1].slice(), ["foo", "bar", , , "foobaz"]) | ||
assert.deepEqual(changes[1]._diff, [4, 1, 'foobaz']) | ||
assert.end() | ||
}) |
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
19822
13
427