diff --git a/map.js b/map.js new file mode 100644 index 0000000..8f330ed --- /dev/null +++ b/map.js @@ -0,0 +1,174 @@ +/* (c) 2016, Richard Feldman, github.com/rtfeldman/seamless-immutable/blob/master/LICENSE */!function () { + "use strict"; + function a(b) { + function c(a) { + return "object" == typeof a && !Array.isArray(a) && null !== a; + }function d(a) { + var b = Object.getPrototypeOf(a);return b ? b === Map.prototype ? new Map() : Object.create(b) : {}; + }function e(a, b, c) { + Object.defineProperty(a, b, { enumerable: !1, configurable: !1, writable: !1, value: c }); + }function f(a) { + e(a, R, !0); + }function g(a) { + return "object" != typeof a || null === a || Boolean(Object.getOwnPropertyDescriptor(a, R)); + }function h(a, b) { + return a === b || a !== a && b !== b; + }function i(a) { + return !(null === a || "object" != typeof a || Array.isArray(a) || a instanceof Date); + }function j(a) { + var b = new Error(a);return b.__proto__ = j, b; + }function k(a, b) { + f(a);return a; + }function l(a, b) { + var c = a[b];e(a, b, function () { + return K(c.apply(a, arguments)); + }); + }function m(a, b, c) { + var d = c && c.deep;if (a in this && (d && this[a] !== b && i(b) && i(this[a]) && (b = K.merge(this[a], b, { deep: !0, mode: "replace" })), h(this[a], b))) return this;var e = u.call(this);return e[a] = K(b), o(e); + }function n(a, b, c) { + var d = a[0];if (1 === a.length) return m.call(this, d, b, c);var e, + f = a.slice(1), + g = this[d];if ("object" == typeof g && null !== g) e = K.setIn(g, f, b);else { + var h = f[0];e = "" !== h && isFinite(h) ? n.call(Z, f, b) : A.call($, f, b); + }if (d in this && g === e) return this;var i = u.call(this);return i[d] = e, o(i); + }function o(a) { + for (var b in V) if (V.hasOwnProperty(b)) { + var c = V[b];l(a, c); + }Q.use_static || (e(a, "flatMap", s), e(a, "asObject", v), e(a, "asMutable", u), e(a, "set", m), e(a, "setIn", n), e(a, "update", C), e(a, "updateIn", E));for (var d = 0, f = a.length; d < f; d++) a[d] = K(a[d]);return k(a, U); + }function p(a) { + for (var b in Y) if (Y.hasOwnProperty(b)) { + var c = Y[b];l(a, c); + }return Q.use_static || (e(a, "asObject", v), e(a, "asMutable", u)), a.forEach(function (b, c) { + a.set(c, K(b)); + }), k(a, X); + }function q(a) { + return Q.use_static || e(a, "asMutable", r), k(a, W); + }function r() { + return new Date(this.getTime()); + }function s(a) { + if (0 === arguments.length) return this;var b, + c = [], + d = this.length;for (b = 0; b < d; b++) { + var e = a(this[b], b, this);Array.isArray(e) ? c.push.apply(c, e) : c.push(e); + }return o(c); + }function t(a) { + if ("undefined" == typeof a && 0 === arguments.length) return this;if ("function" != typeof a) { + var b = Array.isArray(a) ? a.slice() : Array.prototype.slice.call(arguments);b.forEach(function (a, b, c) { + "number" == typeof a && (c[b] = a.toString()); + }), a = function (a, c) { + return b.indexOf(c) !== -1; + }; + }var c = d(this);for (var e in this) this.hasOwnProperty(e) && a(this[e], e) === !1 && (c[e] = this[e]);return H(c); + }function u(a) { + var b, + c, + d = [];if (a && a.deep) for (b = 0, c = this.length; b < c; b++) d.push(w(this[b]));else for (b = 0, c = this.length; b < c; b++) d.push(this[b]);return d; + }function v(a) { + "function" != typeof a && (a = function (a) { + return a; + });var b, + c = {}, + d = this.length || this.size || 0;if (this instanceof Map) this.forEach(function (a, b) { + c[String(b)] = a; + });else for (b = 0; b < d; b++) { + var e = a(this[b], b, this), + f = e[0], + g = void 0 !== typeof e[1] ? e[1] : f;c[f] = g; + }return H(c); + }function w(a) { + return !a || "object" != typeof a || !Object.getOwnPropertyDescriptor(a, R) || a instanceof Date ? a : K.asMutable(a, { deep: !0 }); + }function x(a, b) { + if (a instanceof Map) a.forEach(function (a, c) { + b instanceof Map ? b.set(c, a) : b[c] = a; + });else for (var c in a) Object.getOwnPropertyDescriptor(a, c) && (b[c] = a[c]);return b; + }function y(a, b) { + function c(a, c, e) { + var g = c.get ? c.get(e) : c[e], + j = K(g), + l = m && m(a[e], j, b), + n = a[e];if (void 0 !== f || void 0 !== l || !a.hasOwnProperty(e) || !h(j, n)) { + var o;o = l ? l : k && i(n) && i(j) ? K.merge(n, j, b) : j, h(n, o) && a.hasOwnProperty(e) || (void 0 === f && (f = x(a, d(a))), o = "undefined" != typeof o ? o : e, f instanceof Map ? f.set(e, o) : f[e] = o); + } + }function e(a, b) { + for (var c in a) b.hasOwnProperty(c) || (void 0 === f && (f = x(a, d(a))), delete f[c]); + }if (0 === arguments.length) return this;if (null === a || "object" != typeof a) throw new TypeError("Immutable#merge can only be invoked with objects or arrays, not " + JSON.stringify(a));var f, + g, + j = Array.isArray(a), + k = b && b.deep, + l = b && b.mode || "merge", + m = b && b.merger;if (j || a instanceof Map != !1) { + if (j) for (var n = 0, o = a.length; n < o; n++) { + var p = a[n];if (Array.isArray(p) || p === Object(p)) for (g in p) p.hasOwnProperty(g) && c(void 0 !== f ? f : this, p, g);else c(void 0 !== f ? f : this, p, n); + } else { + var q = this;a.forEach(function (b, d) { + c(q, a, d); + }); + } + } else { + for (g in a) Object.getOwnPropertyDescriptor(a, g) && c(this, a, g);"replace" === l && this === Object(this) && e(this, a); + }return void 0 === f ? this : H(f); + }function z(a, b) { + var c = b && b.deep;if (0 === arguments.length) return this;if (null === a || "object" != typeof a) throw new TypeError("Immutable#replace can only be invoked with objects or arrays, not " + JSON.stringify(a));return K.merge(this, a, { deep: c, mode: "replace" }); + }function A(a, b, c) { + if (!(a instanceof Array) || 0 === a.length) throw new TypeError('The first argument to Immutable#setIn must be an array containing at least one "key" string.');var e = a[0];if (1 === a.length) return B.call(this, e, b, c);var f, + g = a.slice(1), + h = this[e];if (f = this.hasOwnProperty(e) && "object" == typeof h && null !== h ? K.setIn(h, g, b) : A.call($, g, b), this.hasOwnProperty(e) && h === f) return this;var i = x(this, d(this));return i[e] = f, H(i); + }function B(a, b, c) { + var e = c && c.deep;if (this.hasOwnProperty(a) && (e && this[a] !== b && i(b) && i(this[a]) && (b = K.merge(this[a], b, { deep: !0, mode: "replace" })), h(this[a], b))) return this;var f = x(this, d(this));return f[a] = K(b), H(f); + }function C(a, b) { + var c = Array.prototype.slice.call(arguments, 2), + d = this[a];return K.set(this, a, b.apply(d, [d].concat(c))); + }function D(a, b) { + for (var c = 0, d = b.length; null != a && c < d; c++) a = a[b[c]];return c && c == d ? a : void 0; + }function E(a, b) { + var c = Array.prototype.slice.call(arguments, 2), + d = D(this, a);return K.setIn(this, a, b.apply(d, [d].concat(c))); + }function F(a) { + var b, + c = d(this);if (a && a.deep) for (b in this) this.hasOwnProperty(b) && (c[b] = w(this[b]));else if (this.forEach) this.forEach(function (a, b) { + this && this.has && this.has(b) && (c[b] = a); + });else for (b in this) this.hasOwnProperty(b) && (c[b] = this[b]);return c; + }function G() { + return {}; + }function H(a) { + return Q.use_static || (e(a, "merge", y), e(a, "replace", z), e(a, "without", t), e(a, "asMutable", F), e(a, "set", B), e(a, "setIn", A), e(a, "update", C), e(a, "updateIn", E)), k(a, T); + }function I(a) { + return "object" == typeof a && null !== a && (a.$$typeof === P || a.$$typeof === O); + }function J(a) { + return "undefined" != typeof File && a instanceof File; + }function K(a, b, c) { + if (g(a) || I(a) || J(a)) return a;if (Array.isArray(a)) return o(a.slice());if (a instanceof Date) return q(new Date(a.getTime()));if (a.constructor === Map) return p(new Map(a));var d = b && b.prototype, + e = d && d !== Object.prototype ? function () { + return Object.create(d); + } : G, + f = e();for (var h in a) Object.getOwnPropertyDescriptor(a, h) && (f[h] = K(a[h], void 0, c));return H(f); + }function L(a) { + function b() { + var b = [].slice.call(arguments), + c = b.shift();return a.apply(c, b); + }return b; + }function M(a, b) { + function c() { + var c = [].slice.call(arguments), + d = c.shift();return Array.isArray(d) ? b.apply(d, c) : a.apply(d, c); + }return c; + }function N(a, b, c) { + function d() { + var d = [].slice.call(arguments), + e = d.shift();return Array.isArray(e) ? b.apply(e, d) : e instanceof Date ? c.apply(e, d) : a.apply(e, d); + }return d; + }var O = "function" == typeof Symbol && Symbol["for"] && Symbol["for"]("react.element"), + P = 60103, + Q = { use_static: !1 };c(b) && void 0 !== b.use_static && (Q.use_static = Boolean(b.use_static));var R = "__immutable_invariants_hold", + S = ["keys"], + T = ["setPrototypeOf"], + U = T.concat(["push", "pop", "sort", "splice", "shift", "unshift", "reverse"]), + V = S.concat(["map", "filter", "slice", "concat", "reduce", "reduceRight"]), + W = T.concat(["setDate", "setFullYear", "setHours", "setMilliseconds", "setMinutes", "setMonth", "setSeconds", "setTime", "setUTCDate", "setUTCFullYear", "setUTCHours", "setUTCMilliseconds", "setUTCMinutes", "setUTCMonth", "setUTCSeconds", "setYear"]), + X = (T.concat(["delete", "set"]), ["clear", "delete", "set"]), + Y = T.concat(["size", "entries", "forEach", "get", "has", "keys", "values"]);j.prototype = Error.prototype;var Z = K([]), + $ = K({});return K.from = K, K.isImmutable = g, K.ImmutableError = j, K.merge = L(y), K.replace = L(z), K.without = L(t), K.asMutable = N(F, u, r), K.set = M(B, m), K.setIn = M(A, n), K.update = L(C), K.updateIn = L(E), K.flatMap = L(s), K.asObject = L(v), Q.use_static || (K["static"] = a({ use_static: !0 })), Object.freeze(K), K; + }var b = a();"function" == typeof define && define.amd ? define(function () { + return b; + }) : "object" == typeof module ? module.exports = b : "object" == typeof exports ? exports.Immutable = b : "object" == typeof window ? window.Immutable = b : "object" == typeof global && (global.Immutable = b); +}(); diff --git a/package.json b/package.json index 952d7ac..cf2adf0 100644 --- a/package.json +++ b/package.json @@ -6,13 +6,18 @@ "browser": "seamless-immutable.development.js", "react-native": "src/seamless-immutable.js", "devDependencies": { + "babel-cli": "^6.22.2", + "babel-preset-es2015": "^6.22.0", "chai": "3.5.0", "coveralls": "2.11.8", "deep-equal": "1.0.1", "envify": "3.4.0", - "grunt": "0.4.5", + "grunt": "^0.4.5", + "grunt-babel": "^6.0.0", + "grunt-cli": "^1.2.0", "grunt-contrib-uglify": "0.11.1", "grunt-mocha-test": "0.12.7", + "grunt-rollup": "^1.0.1", "istanbul": "0.4.2", "jscheck": "0.2.0", "lodash": "3.10.1", @@ -20,6 +25,7 @@ "mocha-istanbul": "0.2.0", "mocha-lcov-reporter": "1.2.0", "react": "^15.0.1", + "rollup-plugin-babel": "^2.7.1", "zuul": "3.11.1" }, "scripts": { diff --git a/seamless-immutable.development.js b/seamless-immutable.development.js index d17773e..9ebd136 100644 --- a/seamless-immutable.development.js +++ b/seamless-immutable.development.js @@ -26,11 +26,11 @@ function immutableInit(config) { function instantiateEmptyObject(obj) { var prototype = Object.getPrototypeOf(obj); - if (!prototype) { + if (!prototype) return {}; - } else { - return Object.create(prototype); - } + else if (prototype === Map.prototype) return new Map() + return Object.create(prototype); + } function addPropertyTo(target, methodName, value) { @@ -74,16 +74,18 @@ function immutableInit(config) { function isMergableObject(target) { return target !== null && typeof target === "object" && !(Array.isArray(target)) && !(target instanceof Date); - } - var mutatingObjectMethods = [ - "setPrototypeOf" - ]; + } var nonMutatingObjectMethods = [ "keys" ]; + // Objects + var mutatingObjectMethods = [ + "setPrototypeOf" + ]; + var mutatingArrayMethods = mutatingObjectMethods.concat([ "push", "pop", "sort", "splice", "shift", "unshift", "reverse" ]); @@ -98,6 +100,35 @@ function immutableInit(config) { "setUTCMonth", "setUTCSeconds", "setYear" ]); + // WeakMap + var mutatingWeakMapMethods = mutatingObjectMethods.concat([ + 'delete', + 'set', + ]); + + + // Map + var mutatingMapMethods = [ + 'clear', + 'delete', + 'set', + ]; + + var nonMutatingWeakMapMethods = [ + 'get', + 'has', + ]; + + var nonMutatingMapMethods = mutatingObjectMethods.concat([ + 'size', + 'entries', + 'forEach', + 'get', + 'has', + 'keys', + 'values', + ]); + function ImmutableError(message) { var err = new Error(message); // TODO: Consider `Object.setPrototypeOf(err, ImmutableError);` @@ -105,6 +136,7 @@ function immutableInit(config) { return err; } + ImmutableError.prototype = Error.prototype; function makeImmutable(obj, bannedMethods) { @@ -213,6 +245,37 @@ function immutableInit(config) { return makeImmutable(array, mutatingArrayMethods); } + function makeImmutableMap(map) { + // process nonMutatingMapMethods + // ensure each key and value in map is Immutable + // return immutable map + // Don't change their implementations, but wrap these functions to make sure + // they always return an immutable value. + for (var index in nonMutatingMapMethods) { + if (nonMutatingMapMethods.hasOwnProperty(index)) { + var methodName = nonMutatingMapMethods[index]; + makeMethodReturnImmutable(map, methodName); + } + } + + if (!globalConfig.use_static) { + // addPropertyTo(array, "flatMap", flatMap); + addPropertyTo(map, "asObject", asObject); + addPropertyTo(map, "asMutable", asMutableArray); + //addPropertyTo(array, "set", arraySet); + //addPropertyTo(array, "setIn", arraySetIn); + //addPropertyTo(array, "update", update); + //addPropertyTo(array, "updateIn", updateIn); + } + + map.forEach(function(value, key) { + map.set(key, Immutable(value)); + }) + + return makeImmutable(map, mutatingMapMethods); + + } + function makeImmutableDate(date) { if (!globalConfig.use_static) { addPropertyTo(date, "asMutable", asMutableDate); @@ -263,6 +326,7 @@ function immutableInit(config) { * @param {array} keysToRemove - A list of strings representing the keys to exclude in the return value. Instead of providing a single array, this method can also be called by passing multiple strings as separate arguments. */ function without(remove) { + // Calling .without() with no arguments is a no-op. Don't bother cloning. if (typeof remove === "undefined" && arguments.length === 0) { return this; @@ -328,16 +392,21 @@ function immutableInit(config) { } var result = {}, - length = this.length, + length = this.length || this.size || 0, index; - for (index = 0; index < length; index++) { - var pair = iterator(this[index], index, this), - key = pair[0], - value = pair[1]; - - result[key] = value; - } + if (this instanceof Map) + this.forEach(function(value, key) { + result[String(key)] = value; + }) + else + for (index = 0; index < length; index++) { + var pair = iterator(this[index], index, this), + key = pair[0], + value = typeof pair[1] !== undefined ? pair[1] : key; + + result[key] = value; + } return makeImmutableObject(result); } @@ -353,8 +422,15 @@ function immutableInit(config) { } function quickCopy(src, dest) { - for (var key in src) { + + if (src instanceof Map) + src.forEach(function(value, key) { + if (dest instanceof Map) dest.set(key, value); + else dest[key] = value; + }) + else for (var key in src) { if (Object.getOwnPropertyDescriptor(src, key)) { + dest[key] = src[key]; } } @@ -372,6 +448,7 @@ function immutableInit(config) { * that takes a property from both objects. If anything is returned it overrides the normal merge behaviour. */ function merge(other, config) { + // Calling .merge() with no arguments is a no-op. Don't bother cloning. if (arguments.length === 0) { return this; @@ -391,7 +468,11 @@ function immutableInit(config) { // that value in the result object under the same key. If that resulted // in a change from this object's value at that key, set anyChanges = true. function addToResult(currentObj, otherObj, key) { - var immutableValue = Immutable(otherObj[key]); + var val = otherObj.get ? + otherObj.get(key): + otherObj[key]; + var immutableValue = Immutable(val); + var mergerResult = merger && merger(currentObj[key], immutableValue, config); var currentValue = currentObj[key]; @@ -399,7 +480,6 @@ function immutableInit(config) { (mergerResult !== undefined) || (!currentObj.hasOwnProperty(key)) || !isEqual(immutableValue, currentValue)) { - var newValue; if (mergerResult) { @@ -414,9 +494,11 @@ function immutableInit(config) { if (result === undefined) { // Make a shallow clone of the current object. result = quickCopy(currentObj, instantiateEmptyObject(currentObj)); - } - result[key] = newValue; + } + newValue = typeof newValue !== 'undefined' ? newValue : key; + if (result instanceof Map) result.set(key, newValue); + else result[key] = newValue; } } } @@ -436,27 +518,36 @@ function immutableInit(config) { var key; // Achieve prioritization by overriding previous values that get in the way. - if (!receivedArray) { + if (!receivedArray && other instanceof Map === false) { // The most common use case: just merge one object into the existing one. for (key in other) { if (Object.getOwnPropertyDescriptor(other, key)) { addToResult(this, other, key); } } - if (mode === 'replace') { + if (mode === 'replace' && this === Object(this)) { clearDroppedKeys(this, other); } - } else { + } else if (receivedArray) { // We also accept an Array for (var index = 0, length = other.length; index < length; index++) { + var otherFromArray = other[index]; - for (key in otherFromArray) { - if (otherFromArray.hasOwnProperty(key)) { - addToResult(result !== undefined ? result : this, otherFromArray, key); + if(!Array.isArray(otherFromArray) && otherFromArray !== Object(otherFromArray)) { + addToResult(result !== undefined ? result : this, otherFromArray, index); + } + else for (key in otherFromArray) { + if (otherFromArray.hasOwnProperty(key)) { + addToResult(result !== undefined ? result : this, otherFromArray, key); + } } } - } + } else { + var that = this + other.forEach(function(value, key) { + addToResult(that, other, key); + }) } if (result === undefined) { @@ -562,11 +653,17 @@ function immutableInit(config) { } } } else { - for (key in this) { - if (this.hasOwnProperty(key)) { - result[key] = this[key]; + if (this.forEach) + this.forEach(function(value, key){ + if (this && this.has && this.has(key)) + result[key] = value; + }); + else + for (key in this) { + if (this.hasOwnProperty(key)) { + result[key] = this[key]; + } } - } } return result; @@ -613,6 +710,8 @@ function immutableInit(config) { return makeImmutableArray(obj.slice()); } else if (obj instanceof Date) { return makeImmutableDate(new Date(obj.getTime())); + } else if (obj.constructor === Map) { + return makeImmutableMap(new Map(obj)); } else { // Don't freeze the object we were given; make a clone and use that. var prototype = options && options.prototype; diff --git a/seamless-immutable.development.min.js b/seamless-immutable.development.min.js index 627deb9..d5bb0b4 100644 --- a/seamless-immutable.development.min.js +++ b/seamless-immutable.development.min.js @@ -1 +1 @@ -/* (c) 2016, Richard Feldman, github.com/rtfeldman/seamless-immutable/blob/master/LICENSE */!function(){"use strict";function a(b){function c(a){return"object"==typeof a&&!Array.isArray(a)&&null!==a}function d(a){var b=Object.getPrototypeOf(a);return b?Object.create(b):{}}function e(a,b,c){Object.defineProperty(a,b,{enumerable:!1,configurable:!1,writable:!1,value:c})}function f(a,b){e(a,b,function(){throw new k("The "+b+" method cannot be invoked on an Immutable data structure.")})}function g(a){e(a,R,!0)}function h(a){return"object"==typeof a?null===a||Boolean(Object.getOwnPropertyDescriptor(a,R)):!0}function i(a,b){return a===b||a!==a&&b!==b}function j(a){return!(null===a||"object"!=typeof a||Array.isArray(a)||a instanceof Date)}function k(a){var b=new Error(a);return b.__proto__=k,b}function l(a,b){g(a);for(var c in b)b.hasOwnProperty(c)&&f(a,b[c]);return Object.freeze(a),a}function m(a,b){var c=a[b];e(a,b,function(){return K(c.apply(a,arguments))})}function n(a,b,c){var d=c&&c.deep;if(a in this&&(d&&this[a]!==b&&j(b)&&j(this[a])&&(b=K.merge(this[a],b,{deep:!0,mode:"replace"})),i(this[a],b)))return this;var e=u.call(this);return e[a]=K(b),p(e)}function o(a,b,c){var d=a[0];if(1===a.length)return n.call(this,d,b,c);var e,f=a.slice(1),g=this[d];if("object"==typeof g&&null!==g)e=K.setIn(g,f,b);else{var h=f[0];e=""!==h&&isFinite(h)?o.call(X,f,b):A.call(Y,f,b)}if(d in this&&g===e)return this;var i=u.call(this);return i[d]=e,p(i)}function p(a){for(var b in V)if(V.hasOwnProperty(b)){var c=V[b];m(a,c)}Q.use_static||(e(a,"flatMap",s),e(a,"asObject",v),e(a,"asMutable",u),e(a,"set",n),e(a,"setIn",o),e(a,"update",C),e(a,"updateIn",E));for(var d=0,f=a.length;f>d;d++)a[d]=K(a[d]);return l(a,U)}function q(a){return Q.use_static||e(a,"asMutable",r),l(a,W)}function r(){return new Date(this.getTime())}function s(a){if(0===arguments.length)return this;var b,c=[],d=this.length;for(b=0;d>b;b++){var e=a(this[b],b,this);Array.isArray(e)?c.push.apply(c,e):c.push(e)}return p(c)}function t(a){if("undefined"==typeof a&&0===arguments.length)return this;if("function"!=typeof a){var b=Array.isArray(a)?a.slice():Array.prototype.slice.call(arguments);b.forEach(function(a,b,c){"number"==typeof a&&(c[b]=a.toString())}),a=function(a,c){return-1!==b.indexOf(c)}}var c=d(this);for(var e in this)this.hasOwnProperty(e)&&a(this[e],e)===!1&&(c[e]=this[e]);return H(c)}function u(a){var b,c,d=[];if(a&&a.deep)for(b=0,c=this.length;c>b;b++)d.push(w(this[b]));else for(b=0,c=this.length;c>b;b++)d.push(this[b]);return d}function v(a){"function"!=typeof a&&(a=function(a){return a});var b,c={},d=this.length;for(b=0;d>b;b++){var e=a(this[b],b,this),f=e[0],g=e[1];c[f]=g}return H(c)}function w(a){return!a||"object"!=typeof a||!Object.getOwnPropertyDescriptor(a,R)||a instanceof Date?a:K.asMutable(a,{deep:!0})}function x(a,b){for(var c in a)Object.getOwnPropertyDescriptor(a,c)&&(b[c]=a[c]);return b}function y(a,b){function c(a,c,e){var g=K(c[e]),h=m&&m(a[e],g,b),l=a[e];if(void 0!==f||void 0!==h||!a.hasOwnProperty(e)||!i(g,l)){var n;n=h?h:k&&j(l)&&j(g)?K.merge(l,g,b):g,i(l,n)&&a.hasOwnProperty(e)||(void 0===f&&(f=x(a,d(a))),f[e]=n)}}function e(a,b){for(var c in a)b.hasOwnProperty(c)||(void 0===f&&(f=x(a,d(a))),delete f[c])}if(0===arguments.length)return this;if(null===a||"object"!=typeof a)throw new TypeError("Immutable#merge can only be invoked with objects or arrays, not "+JSON.stringify(a));var f,g,h=Array.isArray(a),k=b&&b.deep,l=b&&b.mode||"merge",m=b&&b.merger;if(h)for(var n=0,o=a.length;o>n;n++){var p=a[n];for(g in p)p.hasOwnProperty(g)&&c(void 0!==f?f:this,p,g)}else{for(g in a)Object.getOwnPropertyDescriptor(a,g)&&c(this,a,g);"replace"===l&&e(this,a)}return void 0===f?this:H(f)}function z(a,b){var c=b&&b.deep;if(0===arguments.length)return this;if(null===a||"object"!=typeof a)throw new TypeError("Immutable#replace can only be invoked with objects or arrays, not "+JSON.stringify(a));return K.merge(this,a,{deep:c,mode:"replace"})}function A(a,b,c){if(!(a instanceof Array)||0===a.length)throw new TypeError('The first argument to Immutable#setIn must be an array containing at least one "key" string.');var e=a[0];if(1===a.length)return B.call(this,e,b,c);var f,g=a.slice(1),h=this[e];if(f=this.hasOwnProperty(e)&&"object"==typeof h&&null!==h?K.setIn(h,g,b):A.call(Y,g,b),this.hasOwnProperty(e)&&h===f)return this;var i=x(this,d(this));return i[e]=f,H(i)}function B(a,b,c){var e=c&&c.deep;if(this.hasOwnProperty(a)&&(e&&this[a]!==b&&j(b)&&j(this[a])&&(b=K.merge(this[a],b,{deep:!0,mode:"replace"})),i(this[a],b)))return this;var f=x(this,d(this));return f[a]=K(b),H(f)}function C(a,b){var c=Array.prototype.slice.call(arguments,2),d=this[a];return K.set(this,a,b.apply(d,[d].concat(c)))}function D(a,b){for(var c=0,d=b.length;null!=a&&d>c;c++)a=a[b[c]];return c&&c==d?a:void 0}function E(a,b){var c=Array.prototype.slice.call(arguments,2),d=D(this,a);return K.setIn(this,a,b.apply(d,[d].concat(c)))}function F(a){var b,c=d(this);if(a&&a.deep)for(b in this)this.hasOwnProperty(b)&&(c[b]=w(this[b]));else for(b in this)this.hasOwnProperty(b)&&(c[b]=this[b]);return c}function G(){return{}}function H(a){return Q.use_static||(e(a,"merge",y),e(a,"replace",z),e(a,"without",t),e(a,"asMutable",F),e(a,"set",B),e(a,"setIn",A),e(a,"update",C),e(a,"updateIn",E)),l(a,S)}function I(a){return"object"==typeof a&&null!==a&&(a.$$typeof===P||a.$$typeof===O)}function J(a){return"undefined"!=typeof File&&a instanceof File}function K(a,b,c){if(h(a)||I(a)||J(a))return a;if(Array.isArray(a))return p(a.slice());if(a instanceof Date)return q(new Date(a.getTime()));var d=b&&b.prototype,e=d&&d!==Object.prototype?function(){return Object.create(d)}:G,f=e();if(null==c&&(c=64),0>=c)throw new k("Attempt to construct Immutable from a deeply nested object was detected. Have you tried to wrap an object with circular references (e.g. React element)? See https://github.com/rtfeldman/seamless-immutable/wiki/Deeply-nested-object-was-detected for details.");c-=1;for(var g in a)Object.getOwnPropertyDescriptor(a,g)&&(f[g]=K(a[g],void 0,c));return H(f)}function L(a){function b(){var b=[].slice.call(arguments),c=b.shift();return a.apply(c,b)}return b}function M(a,b){function c(){var c=[].slice.call(arguments),d=c.shift();return Array.isArray(d)?b.apply(d,c):a.apply(d,c)}return c}function N(a,b,c){function d(){var d=[].slice.call(arguments),e=d.shift();return Array.isArray(e)?b.apply(e,d):e instanceof Date?c.apply(e,d):a.apply(e,d)}return d}var O="function"==typeof Symbol&&Symbol["for"]&&Symbol["for"]("react.element"),P=60103,Q={use_static:!1};c(b)&&void 0!==b.use_static&&(Q.use_static=Boolean(b.use_static));var R="__immutable_invariants_hold",S=["setPrototypeOf"],T=["keys"],U=S.concat(["push","pop","sort","splice","shift","unshift","reverse"]),V=T.concat(["map","filter","slice","concat","reduce","reduceRight"]),W=S.concat(["setDate","setFullYear","setHours","setMilliseconds","setMinutes","setMonth","setSeconds","setTime","setUTCDate","setUTCFullYear","setUTCHours","setUTCMilliseconds","setUTCMinutes","setUTCMonth","setUTCSeconds","setYear"]);k.prototype=Error.prototype;var X=K([]),Y=K({});return K.from=K,K.isImmutable=h,K.ImmutableError=k,K.merge=L(y),K.replace=L(z),K.without=L(t),K.asMutable=N(F,u,r),K.set=M(B,n),K.setIn=M(A,o),K.update=L(C),K.updateIn=L(E),K.flatMap=L(s),K.asObject=L(v),Q.use_static||(K["static"]=a({use_static:!0})),Object.freeze(K),K}var b=a();"function"==typeof define&&define.amd?define(function(){return b}):"object"==typeof module?module.exports=b:"object"==typeof exports?exports.Immutable=b:"object"==typeof window?window.Immutable=b:"object"==typeof global&&(global.Immutable=b)}(); \ No newline at end of file +/* (c) 2016, Richard Feldman, github.com/rtfeldman/seamless-immutable/blob/master/LICENSE */!function(){"use strict";function a(b){function c(a){return"object"==typeof a&&!Array.isArray(a)&&null!==a}function d(a){var b=Object.getPrototypeOf(a);return b?b===Map.prototype?new Map:Object.create(b):{}}function e(a,b,c){Object.defineProperty(a,b,{enumerable:!1,configurable:!1,writable:!1,value:c})}function f(a,b){e(a,b,function(){throw new k("The "+b+" method cannot be invoked on an Immutable data structure.")})}function g(a){e(a,S,!0)}function h(a){return"object"!=typeof a||(null===a||Boolean(Object.getOwnPropertyDescriptor(a,S)))}function i(a,b){return a===b||a!==a&&b!==b}function j(a){return!(null===a||"object"!=typeof a||Array.isArray(a)||a instanceof Date)}function k(a){var b=new Error(a);return b.__proto__=k,b}function l(a,b){g(a);for(var c in b)b.hasOwnProperty(c)&&f(a,b[c]);return Object.freeze(a),a}function m(a,b){var c=a[b];e(a,b,function(){return L(c.apply(a,arguments))})}function n(a,b,c){var d=c&&c.deep;if(a in this&&(d&&this[a]!==b&&j(b)&&j(this[a])&&(b=L.merge(this[a],b,{deep:!0,mode:"replace"})),i(this[a],b)))return this;var e=v.call(this);return e[a]=L(b),p(e)}function o(a,b,c){var d=a[0];if(1===a.length)return n.call(this,d,b,c);var e,f=a.slice(1),g=this[d];if("object"==typeof g&&null!==g)e=L.setIn(g,f,b);else{var h=f[0];e=""!==h&&isFinite(h)?o.call($,f,b):B.call(_,f,b)}if(d in this&&g===e)return this;var i=v.call(this);return i[d]=e,p(i)}function p(a){for(var b in W)if(W.hasOwnProperty(b)){var c=W[b];m(a,c)}R.use_static||(e(a,"flatMap",t),e(a,"asObject",w),e(a,"asMutable",v),e(a,"set",n),e(a,"setIn",o),e(a,"update",D),e(a,"updateIn",F));for(var d=0,f=a.length;dd;d++)a[d]=J(a[d]);return k(a,T)}function p(a){return P.use_static||e(a,"asMutable",q),k(a,V)}function q(){return new Date(this.getTime())}function r(a){if(0===arguments.length)return this;var b,c=[],d=this.length;for(b=0;d>b;b++){var e=a(this[b],b,this);Array.isArray(e)?c.push.apply(c,e):c.push(e)}return o(c)}function s(a){if("undefined"==typeof a&&0===arguments.length)return this;if("function"!=typeof a){var b=Array.isArray(a)?a.slice():Array.prototype.slice.call(arguments);b.forEach(function(a,b,c){"number"==typeof a&&(c[b]=a.toString())}),a=function(a,c){return-1!==b.indexOf(c)}}var c=d(this);for(var e in this)this.hasOwnProperty(e)&&a(this[e],e)===!1&&(c[e]=this[e]);return G(c)}function t(a){var b,c,d=[];if(a&&a.deep)for(b=0,c=this.length;c>b;b++)d.push(v(this[b]));else for(b=0,c=this.length;c>b;b++)d.push(this[b]);return d}function u(a){"function"!=typeof a&&(a=function(a){return a});var b,c={},d=this.length;for(b=0;d>b;b++){var e=a(this[b],b,this),f=e[0],g=e[1];c[f]=g}return G(c)}function v(a){return!a||"object"!=typeof a||!Object.getOwnPropertyDescriptor(a,Q)||a instanceof Date?a:J.asMutable(a,{deep:!0})}function w(a,b){for(var c in a)Object.getOwnPropertyDescriptor(a,c)&&(b[c]=a[c]);return b}function x(a,b){function c(a,c,e){var g=J(c[e]),j=m&&m(a[e],g,b),l=a[e];if(void 0!==f||void 0!==j||!a.hasOwnProperty(e)||!h(g,l)){var n;n=j?j:k&&i(l)&&i(g)?J.merge(l,g,b):g,h(l,n)&&a.hasOwnProperty(e)||(void 0===f&&(f=w(a,d(a))),f[e]=n)}}function e(a,b){for(var c in a)b.hasOwnProperty(c)||(void 0===f&&(f=w(a,d(a))),delete f[c])}if(0===arguments.length)return this;if(null===a||"object"!=typeof a)throw new TypeError("Immutable#merge can only be invoked with objects or arrays, not "+JSON.stringify(a));var f,g,j=Array.isArray(a),k=b&&b.deep,l=b&&b.mode||"merge",m=b&&b.merger;if(j)for(var n=0,o=a.length;o>n;n++){var p=a[n];for(g in p)p.hasOwnProperty(g)&&c(void 0!==f?f:this,p,g)}else{for(g in a)Object.getOwnPropertyDescriptor(a,g)&&c(this,a,g);"replace"===l&&e(this,a)}return void 0===f?this:G(f)}function y(a,b){var c=b&&b.deep;if(0===arguments.length)return this;if(null===a||"object"!=typeof a)throw new TypeError("Immutable#replace can only be invoked with objects or arrays, not "+JSON.stringify(a));return J.merge(this,a,{deep:c,mode:"replace"})}function z(a,b,c){if(!(a instanceof Array)||0===a.length)throw new TypeError('The first argument to Immutable#setIn must be an array containing at least one "key" string.');var e=a[0];if(1===a.length)return A.call(this,e,b,c);var f,g=a.slice(1),h=this[e];if(f=this.hasOwnProperty(e)&&"object"==typeof h&&null!==h?J.setIn(h,g,b):z.call(X,g,b),this.hasOwnProperty(e)&&h===f)return this;var i=w(this,d(this));return i[e]=f,G(i)}function A(a,b,c){var e=c&&c.deep;if(this.hasOwnProperty(a)&&(e&&this[a]!==b&&i(b)&&i(this[a])&&(b=J.merge(this[a],b,{deep:!0,mode:"replace"})),h(this[a],b)))return this;var f=w(this,d(this));return f[a]=J(b),G(f)}function B(a,b){var c=Array.prototype.slice.call(arguments,2),d=this[a];return J.set(this,a,b.apply(d,[d].concat(c)))}function C(a,b){for(var c=0,d=b.length;null!=a&&d>c;c++)a=a[b[c]];return c&&c==d?a:void 0}function D(a,b){var c=Array.prototype.slice.call(arguments,2),d=C(this,a);return J.setIn(this,a,b.apply(d,[d].concat(c)))}function E(a){var b,c=d(this);if(a&&a.deep)for(b in this)this.hasOwnProperty(b)&&(c[b]=v(this[b]));else for(b in this)this.hasOwnProperty(b)&&(c[b]=this[b]);return c}function F(){return{}}function G(a){return P.use_static||(e(a,"merge",x),e(a,"replace",y),e(a,"without",s),e(a,"asMutable",E),e(a,"set",A),e(a,"setIn",z),e(a,"update",B),e(a,"updateIn",D)),k(a,R)}function H(a){return"object"==typeof a&&null!==a&&(a.$$typeof===O||a.$$typeof===N)}function I(a){return"undefined"!=typeof File&&a instanceof File}function J(a,b,c){if(g(a)||H(a)||I(a))return a;if(Array.isArray(a))return o(a.slice());if(a instanceof Date)return p(new Date(a.getTime()));var d=b&&b.prototype,e=d&&d!==Object.prototype?function(){return Object.create(d)}:F,f=e();for(var h in a)Object.getOwnPropertyDescriptor(a,h)&&(f[h]=J(a[h],void 0,c));return G(f)}function K(a){function b(){var b=[].slice.call(arguments),c=b.shift();return a.apply(c,b)}return b}function L(a,b){function c(){var c=[].slice.call(arguments),d=c.shift();return Array.isArray(d)?b.apply(d,c):a.apply(d,c)}return c}function M(a,b,c){function d(){var d=[].slice.call(arguments),e=d.shift();return Array.isArray(e)?b.apply(e,d):e instanceof Date?c.apply(e,d):a.apply(e,d)}return d}var N="function"==typeof Symbol&&Symbol["for"]&&Symbol["for"]("react.element"),O=60103,P={use_static:!1};c(b)&&void 0!==b.use_static&&(P.use_static=Boolean(b.use_static));var Q="__immutable_invariants_hold",R=["setPrototypeOf"],S=["keys"],T=R.concat(["push","pop","sort","splice","shift","unshift","reverse"]),U=S.concat(["map","filter","slice","concat","reduce","reduceRight"]),V=R.concat(["setDate","setFullYear","setHours","setMilliseconds","setMinutes","setMonth","setSeconds","setTime","setUTCDate","setUTCFullYear","setUTCHours","setUTCMilliseconds","setUTCMinutes","setUTCMonth","setUTCSeconds","setYear"]);j.prototype=Error.prototype;var W=J([]),X=J({});return J.from=J,J.isImmutable=g,J.ImmutableError=j,J.merge=K(x),J.replace=K(y),J.without=K(s),J.asMutable=M(E,t,q),J.set=L(A,m),J.setIn=L(z,n),J.update=K(B),J.updateIn=K(D),J.flatMap=K(r),J.asObject=K(u),P.use_static||(J["static"]=a({use_static:!0})),Object.freeze(J),J}var b=a();"function"==typeof define&&define.amd?define(function(){return b}):"object"==typeof module?module.exports=b:"object"==typeof exports?exports.Immutable=b:"object"==typeof window?window.Immutable=b:"object"==typeof global&&(global.Immutable=b)}(); \ No newline at end of file +/* (c) 2016, Richard Feldman, github.com/rtfeldman/seamless-immutable/blob/master/LICENSE */!function(){"use strict";function a(b){function c(a){return"object"==typeof a&&!Array.isArray(a)&&null!==a}function d(a){var b=Object.getPrototypeOf(a);return b?b===Map.prototype?new Map:Object.create(b):{}}function e(a,b,c){Object.defineProperty(a,b,{enumerable:!1,configurable:!1,writable:!1,value:c})}function f(a){e(a,R,!0)}function g(a){return"object"!=typeof a||(null===a||Boolean(Object.getOwnPropertyDescriptor(a,R)))}function h(a,b){return a===b||a!==a&&b!==b}function i(a){return!(null===a||"object"!=typeof a||Array.isArray(a)||a instanceof Date)}function j(a){var b=new Error(a);return b.__proto__=j,b}function k(a,b){f(a);return a}function l(a,b){var c=a[b];e(a,b,function(){return K(c.apply(a,arguments))})}function m(a,b,c){var d=c&&c.deep;if(a in this&&(d&&this[a]!==b&&i(b)&&i(this[a])&&(b=K.merge(this[a],b,{deep:!0,mode:"replace"})),h(this[a],b)))return this;var e=u.call(this);return e[a]=K(b),o(e)}function n(a,b,c){var d=a[0];if(1===a.length)return m.call(this,d,b,c);var e,f=a.slice(1),g=this[d];if("object"==typeof g&&null!==g)e=K.setIn(g,f,b);else{var h=f[0];e=""!==h&&isFinite(h)?n.call(Z,f,b):A.call($,f,b)}if(d in this&&g===e)return this;var i=u.call(this);return i[d]=e,o(i)}function o(a){for(var b in V)if(V.hasOwnProperty(b)){var c=V[b];l(a,c)}Q.use_static||(e(a,"flatMap",s),e(a,"asObject",v),e(a,"asMutable",u),e(a,"set",m),e(a,"setIn",n),e(a,"update",C),e(a,"updateIn",E));for(var d=0,f=a.length;d