seamless-immutable
Advanced tools
Comparing version 1.1.2 to 1.2.0
{ | ||
"name": "seamless-immutable", | ||
"main": "seamless-immutable.js", | ||
"version": "1.1.2", | ||
"version": "1.2.0", | ||
"homepage": "https://github.com/rtfeldman/seamless-immutable", | ||
@@ -6,0 +6,0 @@ "authors": [ |
{ | ||
"name": "seamless-immutable", | ||
"version": "1.1.2", | ||
"version": "1.2.0", | ||
"description": "Immutable data structures for JavaScript which are backwards-compatible with normal JS Arrays and Objects.", | ||
@@ -5,0 +5,0 @@ "main": "seamless-immutable.js", |
@@ -192,11 +192,4 @@ (function(){ | ||
for (var index in this) { | ||
var pair = iterator(this[index], index, this); | ||
if (!(pair instanceof Array)) { | ||
throw new Error( | ||
"The iterator function passed to asObject must always return a pair, not " + | ||
JSON.stringify(pair)); | ||
} | ||
var key = pair[0], | ||
var pair = iterator(this[index], index, this), | ||
key = pair[0], | ||
value = pair[1]; | ||
@@ -263,7 +256,7 @@ | ||
result[key] = asDeepMutable(this[key]); | ||
}; | ||
} | ||
} else { | ||
for (var key in this) { | ||
result[key] = this[key]; | ||
}; | ||
} | ||
}; | ||
@@ -309,2 +302,3 @@ | ||
/* istanbul ignore if */ | ||
if (typeof module === "object") { | ||
@@ -311,0 +305,0 @@ module.exports = Immutable; |
@@ -11,6 +11,8 @@ var Immutable = require("../../seamless-immutable.js"); | ||
it("works on arrays of various lengths", function() { | ||
check(100, [JSC.array()], function(mutableArray) { | ||
var keys = mutableArray.map(function() { return JSC.string()(); }) | ||
var values = mutableArray.map(function() { return JSC.any()(); }) | ||
var array = Immutable(mutableArray); | ||
check(100, [TestUtils.ComplexObjectSpecifier()], function(obj) { | ||
var keys = _.keys(obj); | ||
var values = _.values(obj); | ||
var array = Immutable(_.map(obj, function(value, key) { | ||
return [key, value]; | ||
})); | ||
@@ -24,5 +26,3 @@ var result = array.asObject(function(value, index) { | ||
_.each(function(key, index) { | ||
assert.deepEqual(values[index], result[key]); | ||
}); | ||
assert.deepEqual(result, obj); | ||
}); | ||
@@ -32,7 +32,6 @@ }); | ||
it("works without an iterator on arrays that are already organized properly", function() { | ||
check(100, [JSC.array()], function(mutableArray) { | ||
var keys = mutableArray.map(function() { return JSC.string()(); }) | ||
var values = mutableArray.map(function() { return JSC.any()(); }) | ||
var array = Immutable(_.map(mutableArray, function(value, index) { | ||
return [keys[index], values[index]]; | ||
check(100, [TestUtils.ComplexObjectSpecifier()], function(obj) { | ||
var keys = _.keys(obj); | ||
var array = Immutable(_.map(obj, function(value, key) { | ||
return [key, value]; | ||
})); | ||
@@ -42,5 +41,3 @@ | ||
_.each(function(key, index) { | ||
assert.deepEqual(values[index], result[key]); | ||
}); | ||
assert.deepEqual(result, obj); | ||
}); | ||
@@ -47,0 +44,0 @@ }); |
67777
1052