Skip to content

Commit

Permalink
Merge pull request #58 from bjornstar/develop
Browse files Browse the repository at this point in the history
v0.0.16: Keys are now being updated properly when splicing arrays.
  • Loading branch information
bjornstar committed Oct 22, 2013
2 parents bb824dc + 44805ba commit cf02405
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 3 deletions.
2 changes: 1 addition & 1 deletion component.json
Expand Up @@ -2,7 +2,7 @@
"name": "tomes",
"repo": "bjornstar/tomes",
"description": "Evented Storage Agnostic Data API",
"version": "0.0.15",
"version": "0.0.16",
"keywords": [ "data", "events" ],
"dependencies": {
"component/emitter": "*"
Expand Down
2 changes: 1 addition & 1 deletion package.json
@@ -1,7 +1,7 @@
{
"name": "tomes",
"description": "Evented Storage Agnostic Data API",
"version": "0.0.15",
"version": "0.0.16",
"author": "Wizcorp, Inc. <info@wizcorp.jp>",
"maintainers": [
{ "name": "Bjorn Stromberg", "email": "bstromberg@wizcorp.jp" }
Expand Down
1 change: 0 additions & 1 deletion scripts/jshint.cfg
Expand Up @@ -26,7 +26,6 @@


// ECMAScript 5.
"es5" : true, // Allow ECMAScript 5 syntax.
"strict" : false, // Require `use strict` pragma in every file.
"globalstrict" : true, // Allow global "use strict" (also enables 'strict').

Expand Down
16 changes: 16 additions & 0 deletions test/modules/array.js
Expand Up @@ -1095,5 +1095,21 @@ exports.testSplice = function (test) {

test.strictEqual(JSON.stringify(a), JSON.stringify(b));

test.done();
};

exports.testSpliceKeys = function (test) {
test.expect(5);

var a = [ 0, 1, 2, 3, 4, 5 ];
var b = Tome.conjure(a);

a.splice(0, 1);
b.splice(0, 1);

for (var i = 0; i < b.length; i += 1) {
test.strictEqual(i, b[i].getKey());
}

test.done();
};
1 change: 1 addition & 0 deletions tomes.js
Expand Up @@ -1259,6 +1259,7 @@ ArrayTome.prototype.splice = function (spliceIndex, toRemove) {

for (i = 0, len = this._arr.length; i < len; i += 1) {
this[i] = this._arr[i];
this[i].__key__ = i;
}

if (out.length > toAdd.length) {
Expand Down

0 comments on commit cf02405

Please sign in to comment.