diff --git a/__tests__/Record.ts b/__tests__/Record.ts index 6b8a751008..5c29913ba6 100644 --- a/__tests__/Record.ts +++ b/__tests__/Record.ts @@ -48,6 +48,23 @@ describe('Record', () => { expect(t2).toBe(t1); }); + it('falls back to default values when deleted or cleared', () => { + const MyType = Record({ a: 1, b: 2, c: 3 }); + const t1 = new MyType({ a: 10, b: 20 }); + const t2 = new MyType({ b: 20 }); + const t3 = t1.delete('a'); + const t4 = t3.clear(); + + expect(t1.get('a')).toBe(10); + expect(t2.get('a')).toBe(1); + expect(t3.get('a')).toBe(1); + expect(t4.get('b')).toBe(2); + + expect(t2.equals(t3)).toBe(true); + expect(t2.equals(t4)).toBe(false); + expect(t4.equals(new MyType())).toBe(true); + }); + it('is a value type and equals other similar Records', () => { let MyType = Record({a: 1, b: 2, c: 3}); let t1 = MyType({ a: 10 }); diff --git a/__tests__/RecordJS.js b/__tests__/RecordJS.js index 6ccd39f0ea..b49ba7ab56 100644 --- a/__tests__/RecordJS.js +++ b/__tests__/RecordJS.js @@ -45,4 +45,20 @@ describe('Record', () => { expect(t.soup()).toBe(6); expect(t2.soup()).toBe(204); }); + + it('can be cleared', () => { + const MyType = Record({ a: 1, b: 2, c: 3 }); + let t = new MyType({ c: 'cats' }); + + expect(t.c).toBe('cats'); + t = t.clear(); + expect(t.c).toBe(3); + + const MyType2 = Record({ d: 4, e: 5, f: 6 }); + let t2 = new MyType2({ d: 'dogs' }); + + expect(t2.d).toBe('dogs'); + t2 = t2.clear(); + expect(t2.d).toBe(4); + }); }); diff --git a/dist/immutable-nonambient.d.ts b/dist/immutable-nonambient.d.ts index 5b97038479..8e10b19070 100644 --- a/dist/immutable-nonambient.d.ts +++ b/dist/immutable-nonambient.d.ts @@ -2162,6 +2162,21 @@ ...collections: Array | Iterable<[string, any]>> ): this; + /** + * Returns a new instance of this Record type with the value for the + * specific key set to its default value. + * + * @alias remove + */ + delete(key: K): this; + remove(key: K): this; + + /** + * Returns a new instance of this Record type with all values set + * to their default values. + */ + clear(): this; + // Deep persistent changes setIn(keyPath: Iterable, value: any): this; diff --git a/dist/immutable.d.ts b/dist/immutable.d.ts index 471536348e..367201a4fc 100644 --- a/dist/immutable.d.ts +++ b/dist/immutable.d.ts @@ -2162,6 +2162,21 @@ declare module Immutable { ...collections: Array | Iterable<[string, any]>> ): this; + /** + * Returns a new instance of this Record type with the value for the + * specific key set to its default value. + * + * @alias remove + */ + delete(key: K): this; + remove(key: K): this; + + /** + * Returns a new instance of this Record type with all values set + * to their default values. + */ + clear(): this; + // Deep persistent changes setIn(keyPath: Iterable, value: any): this; diff --git a/dist/immutable.js b/dist/immutable.js index c506aa98c1..5dee3a6785 100644 --- a/dist/immutable.js +++ b/dist/immutable.js @@ -5234,11 +5234,11 @@ Record.prototype.toString = function toString () { Record.prototype.equals = function equals (other) { return this === other || - (this._keys === other._keys && this._values.equals(other._values)); + (this._keys === other._keys && recordSeq(this).equals(recordSeq(other))); }; Record.prototype.hashCode = function hashCode () { - return this._values.hashCode(); + return recordSeq(this).hashCode(); }; // @pragma Access @@ -5271,6 +5271,15 @@ Record.prototype.set = function set (k, v) { return this; }; +Record.prototype.remove = function remove (k) { + return this.set(k); +}; + +Record.prototype.clear = function clear () { + var newValues = this._values.clear().setSize(this._keys.length); + return this.__ownerID ? this : makeRecord(this, newValues); +}; + Record.prototype.wasAltered = function wasAltered () { return this._values.wasAltered(); }; @@ -5308,6 +5317,7 @@ Record.isRecord = isRecord; Record.getDescriptiveName = recordName; var RecordPrototype = Record.prototype; RecordPrototype[IS_RECORD_SENTINEL] = true; +RecordPrototype[DELETE] = RecordPrototype.remove; RecordPrototype.getIn = CollectionPrototype.getIn; RecordPrototype.hasIn = CollectionPrototype.hasIn; RecordPrototype.merge = MapPrototype.merge; diff --git a/dist/immutable.js.flow b/dist/immutable.js.flow index b70f35b914..e1513dcd26 100644 --- a/dist/immutable.js.flow +++ b/dist/immutable.js.flow @@ -1091,6 +1091,10 @@ declare class RecordInstance { ...collections: Array<$Shape | Iterable<[string, any]>> ): this; + delete>(key: K): this; + remove>(key: K): this; + clear(): this; + setIn(keyPath: Iterable, value: any): this; updateIn(keyPath: Iterable, updater: (value: any) => any): this; mergeIn(keyPath: Iterable, ...collections: Array): this; diff --git a/dist/immutable.min.js b/dist/immutable.min.js index baaf0f0cac..ca89b0c77f 100644 --- a/dist/immutable.min.js +++ b/dist/immutable.min.js @@ -6,34 +6,34 @@ * LICENSE file in the root directory of this source tree. An additional grant * of patent rights can be found in the PATENTS file in the same directory. */ -!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e(t.Immutable=t.Immutable||{})}(this,function(t){"use strict";function e(t){return t.value=!1,t}function r(t){t&&(t.value=!0)}function n(){}function i(t,e){e=e||0;for(var r=Math.max(0,t.length-e),n=Array(r),i=0;i>>0;if(""+r!==e||4294967295===r)return NaN;e=r}return e<0?o(t)+e:e}function s(){return!0}function a(t,e,r){return(0===t||void 0!==r&&t<=-r)&&(void 0===e||void 0!==r&&e>=r)}function c(t,e){return f(t,e,0)}function h(t,e){return f(t,e,e)}function f(t,e,r){return void 0===t?r:t<0?e===1/0?e:0|Math.max(0,e+t):void 0===e||e===t?t:0|Math.min(e,t)}function p(t){return(_(t)||g(t))&&!t.__ownerID}function _(t){return!(!t||!t[ke])}function l(t){return!(!t||!t[Ae])}function v(t){return!(!t||!t[Re])}function y(t){return l(t)||v(t)}function d(t){return!(!t||!t[Ue])}function g(t){return!(!t||!t[Ke])}function m(t){return!(!t||"function"!=typeof t.equals||"function"!=typeof t.hashCode)}function w(t,e,r,n){var i=0===t?e:1===t?r:[e,r];return n?n.value=i:n={value:i,done:!1},n}function z(){return{value:void 0,done:!0}}function S(t){return!!O(t)}function I(t){return t&&"function"==typeof t.next}function b(t){var e=O(t);return e&&e.call(t)}function O(t){var e=t&&(Ne&&t[Ne]||t[Ve]);if("function"==typeof e)return e}function M(t){return t&&"number"==typeof t.length}function q(t){return!(!t||!t[Ze])}function D(){return er||(er=new $e([]))}function E(t){var e=Array.isArray(t)?new $e(t):I(t)?new ir(t):S(t)?new nr(t):void 0;if(e)return e.fromEntrySeq();if("object"==typeof t)return new tr(t);throw new TypeError("Expected Array or collection object of [k, v] entries, or keyed object: "+t)}function x(t){var e=k(t);if(e)return e;throw new TypeError("Expected Array or collection object of values: "+t)}function j(t){var e=k(t);if(e)return e -;if("object"==typeof t)return new tr(t);throw new TypeError("Expected Array or collection object of values, or keyed object: "+t)}function k(t){return M(t)?new $e(t):I(t)?new ir(t):S(t)?new nr(t):void 0}function A(t,e){if(t===e||t!==t&&e!==e)return!0;if(!t||!e)return!1;if("function"==typeof t.valueOf&&"function"==typeof e.valueOf){if(t=t.valueOf(),e=e.valueOf(),t===e||t!==t&&e!==e)return!0;if(!t||!e)return!1}return!!(m(t)&&m(e)&&t.equals(e))}function R(t,e){return U([],e||K,t,"",e&&e.length>2?[]:void 0,{"":t})}function U(t,e,r,n,i,o){var u=Array.isArray(r)?Fe:L(r)?Xe:null;if(u){if(~t.indexOf(r))throw new TypeError("Cannot convert circular structure to Immutable");t.push(r),i&&""!==n&&i.push(n);var s=e.call(o,n,u(r).map(function(n,o){return U(t,e,n,o,i,r)}),i&&i.slice());return t.pop(),i&&i.pop(),s}return r}function K(t,e){return l(e)?e.toMap():e.toList()}function L(t){return t&&(t.constructor===Object||void 0===t.constructor)}function T(t){return t>>>1&1073741824|3221225471&t}function C(t){if(t===!1||null===t||void 0===t)return 0;if("function"==typeof t.valueOf&&((t=t.valueOf())===!1||null===t||void 0===t))return 0;if(t===!0)return 1;var e=typeof t;if("number"===e){if(t!==t||t===1/0)return 0;var r=0|t;for(r!==t&&(r^=4294967295*t);t>4294967295;)t/=4294967295,r^=t;return T(r)}if("string"===e)return t.length>fr?W(t):B(t);if("function"==typeof t.hashCode)return t.hashCode();if("object"===e)return J(t);if("function"==typeof t.toString)return B(""+t);throw Error("Value type "+e+" cannot be hashed.")}function W(t){var e=lr[t];return void 0===e&&(e=B(t),_r===pr&&(_r=0,lr={}),_r++,lr[t]=e),e}function B(t){for(var e=0,r=0;r>>0;if(""+r!==e||4294967295===r)return NaN;e=r}return e<0?o(t)+e:e}function s(){return!0}function a(t,e,r){return(0===t||void 0!==r&&t<=-r)&&(void 0===e||void 0!==r&&e>=r)}function c(t,e){return f(t,e,0)}function h(t,e){return f(t,e,e)}function f(t,e,r){return void 0===t?r:t<0?e===1/0?e:0|Math.max(0,e+t):void 0===e||e===t?t:0|Math.min(e,t)}function p(t){return(_(t)||g(t))&&!t.__ownerID}function _(t){return!(!t||!t[je])}function l(t){return!(!t||!t[Ae])}function v(t){return!(!t||!t[Re])}function y(t){return l(t)||v(t)}function d(t){return!(!t||!t[Ue])}function g(t){return!(!t||!t[Ke])}function m(t){return!(!t||"function"!=typeof t.equals||"function"!=typeof t.hashCode)}function w(t,e,r,n){var i=0===t?e:1===t?r:[e,r];return n?n.value=i:n={value:i,done:!1},n}function z(){return{value:void 0,done:!0}}function S(t){return!!O(t)}function I(t){return t&&"function"==typeof t.next}function b(t){var e=O(t);return e&&e.call(t)}function O(t){var e=t&&(Ne&&t[Ne]||t[Ve]);if("function"==typeof e)return e}function M(t){return t&&"number"==typeof t.length}function D(t){return!(!t||!t[Ze])}function q(){return er||(er=new $e([]))}function E(t){var e=Array.isArray(t)?new $e(t):I(t)?new ir(t):S(t)?new nr(t):void 0;if(e)return e.fromEntrySeq();if("object"==typeof t)return new tr(t);throw new TypeError("Expected Array or collection object of [k, v] entries, or keyed object: "+t)}function x(t){var e=j(t);if(e)return e;throw new TypeError("Expected Array or collection object of values: "+t)}function k(t){var e=j(t);if(e)return e +;if("object"==typeof t)return new tr(t);throw new TypeError("Expected Array or collection object of values, or keyed object: "+t)}function j(t){return M(t)?new $e(t):I(t)?new ir(t):S(t)?new nr(t):void 0}function A(t,e){if(t===e||t!==t&&e!==e)return!0;if(!t||!e)return!1;if("function"==typeof t.valueOf&&"function"==typeof e.valueOf){if(t=t.valueOf(),e=e.valueOf(),t===e||t!==t&&e!==e)return!0;if(!t||!e)return!1}return!!(m(t)&&m(e)&&t.equals(e))}function R(t,e){return U([],e||K,t,"",e&&e.length>2?[]:void 0,{"":t})}function U(t,e,r,n,i,o){var u=Array.isArray(r)?Fe:L(r)?Xe:null;if(u){if(~t.indexOf(r))throw new TypeError("Cannot convert circular structure to Immutable");t.push(r),i&&""!==n&&i.push(n);var s=e.call(o,n,u(r).map(function(n,o){return U(t,e,n,o,i,r)}),i&&i.slice());return t.pop(),i&&i.pop(),s}return r}function K(t,e){return l(e)?e.toMap():e.toList()}function L(t){return t&&(t.constructor===Object||void 0===t.constructor)}function T(t){return t>>>1&1073741824|3221225471&t}function C(t){if(t===!1||null===t||void 0===t)return 0;if("function"==typeof t.valueOf&&((t=t.valueOf())===!1||null===t||void 0===t))return 0;if(t===!0)return 1;var e=typeof t;if("number"===e){if(t!==t||t===1/0)return 0;var r=0|t;for(r!==t&&(r^=4294967295*t);t>4294967295;)t/=4294967295,r^=t;return T(r)}if("string"===e)return t.length>fr?W(t):B(t);if("function"==typeof t.hashCode)return t.hashCode();if("object"===e)return J(t);if("function"==typeof t.toString)return B(""+t);throw Error("Value type "+e+" cannot be hashed.")}function W(t){var e=lr[t];return void 0===e&&(e=B(t),_r===pr&&(_r=0,lr={}),_r++,lr[t]=e),e}function B(t){for(var e=0,r=0;r0)switch(t.nodeType){case 1:return t.uniqueID;case 9:return t.documentElement&&t.documentElement.uniqueID}}function N(t){var e=ht(t);return e._iter=t,e.size=t.size,e.flip=function(){return t},e.reverse=function(){var e=t.reverse.apply(this);return e.flip=function(){return t.reverse()},e},e.has=function(e){return t.includes(e)},e.includes=function(e){return t.has(e)},e.cacheResult=ft,e.__iterateUncached=function(e,r){var n=this;return t.__iterate(function(t,r){return e(r,t,n)!==!1},r)},e.__iteratorUncached=function(e,r){if(e===Pe){var n=t.__iterator(e,r);return new Ye(function(){var t=n.next();if(!t.done){var e=t.value[0];t.value[0]=t.value[1],t.value[1]=e}return t})}return t.__iterator(e===Je?Be:Je,r)},e}function V(t,e,r){var n=ht(t);return n.size=t.size,n.has=function(e){return t.has(e)},n.get=function(n,i){var o=t.get(n,Ee);return o===Ee?i:e.call(r,o,n,t)},n.__iterateUncached=function(n,i){var o=this;return t.__iterate(function(t,i,u){return n(e.call(r,t,i,u),i,o)!==!1},i)},n.__iteratorUncached=function(n,i){var o=t.__iterator(Pe,i);return new Ye(function(){var i=o.next();if(i.done)return i;var u=i.value,s=u[0];return w(n,s,e.call(r,u[1],s,t),i)})},n}function H(t,e){var r=this,n=ht(t);return n._iter=t,n.size=t.size,n.reverse=function(){return t},t.flip&&(n.flip=function(){var e=N(t);return e.reverse=function(){return t.flip()},e}),n.get=function(r,n){return t.get(e?r:-1-r,n)},n.has=function(r){return t.has(e?r:-1-r)},n.includes=function(e){return t.includes(e)},n.cacheResult=ft,n.__iterate=function(r,n){var i=this,u=0;return n&&o(t), -t.__iterate(function(t,o){return r(t,e?o:n?i.size-++u:u++,i)},!n)},n.__iterator=function(n,i){var u=0;i&&o(t);var s=t.__iterator(Pe,!i);return new Ye(function(){var t=s.next();if(t.done)return t;var o=t.value;return w(n,e?o[0]:i?r.size-++u:u++,o[1],t)})},n}function Y(t,e,r,n){var i=ht(t);return n&&(i.has=function(n){var i=t.get(n,Ee);return i!==Ee&&!!e.call(r,i,n,t)},i.get=function(n,i){var o=t.get(n,Ee);return o!==Ee&&e.call(r,o,n,t)?o:i}),i.__iterateUncached=function(i,o){var u=this,s=0;return t.__iterate(function(t,o,a){if(e.call(r,t,o,a))return i(t,n?o:s++,u)},o),s},i.__iteratorUncached=function(i,o){var u=t.__iterator(Pe,o),s=0;return new Ye(function(){for(;;){var o=u.next();if(o.done)return o;var a=o.value,c=a[0],h=a[1];if(e.call(r,h,c,t))return w(i,n?c:s++,h,o)}})},i}function Q(t,e,r){var n=mr().asMutable();return t.__iterate(function(i,o){n.update(e.call(r,i,o,t),0,function(t){return t+1})}),n.asImmutable()}function X(t,e,r){var n=l(t),i=(d(t)?Tr():mr()).asMutable();t.__iterate(function(o,u){i.update(e.call(r,o,u,t),function(t){return t=t||[],t.push(n?[u,o]:o),t})});var o=ct(t);return i.map(function(e){return st(t,o(e))})}function F(t,e,r,n){var i=t.size;if(a(e,r,i))return t;var o=c(e,i),s=h(r,i);if(o!==o||s!==s)return F(t.toSeq().cacheResult(),e,r,n);var f,p=s-o;p===p&&(f=p<0?0:p);var _=ht(t);return _.size=0===f?f:t.size&&f||void 0,!n&&q(t)&&f>=0&&(_.get=function(e,r){return e=u(this,e),e>=0&&ef)return z();var t=i.next();return n||e===Je?t:e===Be?w(e,s-1,void 0,t):w(e,s-1,t.value[1],t)})},_}function G(t,e,r){var n=ht(t);return n.__iterateUncached=function(n,i){var o=this +t.__iterate(function(t,o){return r(t,e?o:n?i.size-++u:u++,i)},!n)},n.__iterator=function(n,i){var u=0;i&&o(t);var s=t.__iterator(Pe,!i);return new Ye(function(){var t=s.next();if(t.done)return t;var o=t.value;return w(n,e?o[0]:i?r.size-++u:u++,o[1],t)})},n}function Y(t,e,r,n){var i=ht(t);return n&&(i.has=function(n){var i=t.get(n,Ee);return i!==Ee&&!!e.call(r,i,n,t)},i.get=function(n,i){var o=t.get(n,Ee);return o!==Ee&&e.call(r,o,n,t)?o:i}),i.__iterateUncached=function(i,o){var u=this,s=0;return t.__iterate(function(t,o,a){if(e.call(r,t,o,a))return i(t,n?o:s++,u)},o),s},i.__iteratorUncached=function(i,o){var u=t.__iterator(Pe,o),s=0;return new Ye(function(){for(;;){var o=u.next();if(o.done)return o;var a=o.value,c=a[0],h=a[1];if(e.call(r,h,c,t))return w(i,n?c:s++,h,o)}})},i}function Q(t,e,r){var n=mr().asMutable();return t.__iterate(function(i,o){n.update(e.call(r,i,o,t),0,function(t){return t+1})}),n.asImmutable()}function X(t,e,r){var n=l(t),i=(d(t)?Tr():mr()).asMutable();t.__iterate(function(o,u){i.update(e.call(r,o,u,t),function(t){return t=t||[],t.push(n?[u,o]:o),t})});var o=ct(t);return i.map(function(e){return st(t,o(e))})}function F(t,e,r,n){var i=t.size;if(a(e,r,i))return t;var o=c(e,i),s=h(r,i);if(o!==o||s!==s)return F(t.toSeq().cacheResult(),e,r,n);var f,p=s-o;p===p&&(f=p<0?0:p);var _=ht(t);return _.size=0===f?f:t.size&&f||void 0,!n&&D(t)&&f>=0&&(_.get=function(e,r){return e=u(this,e),e>=0&&ef)return z();var t=i.next();return n||e===Je?t:e===Be?w(e,s-1,void 0,t):w(e,s-1,t.value[1],t)})},_}function G(t,e,r){var n=ht(t);return n.__iterateUncached=function(n,i){var o=this ;if(i)return this.cacheResult().__iterate(n,i);var u=0;return t.__iterate(function(t,i,s){return e.call(r,t,i,s)&&++u&&n(t,i,o)}),u},n.__iteratorUncached=function(n,i){var o=this;if(i)return this.cacheResult().__iterator(n,i);var u=t.__iterator(Pe,i),s=!0;return new Ye(function(){if(!s)return z();var t=u.next();if(t.done)return t;var i=t.value,a=i[0],c=i[1];return e.call(r,c,a,o)?n===Pe?t:w(n,a,c,t):(s=!1,z())})},n}function Z(t,e,r,n){var i=ht(t);return i.__iterateUncached=function(i,o){var u=this;if(o)return this.cacheResult().__iterate(i,o);var s=!0,a=0;return t.__iterate(function(t,o,c){if(!s||!(s=e.call(r,t,o,c)))return a++,i(t,n?o:a-1,u)}),a},i.__iteratorUncached=function(i,o){var u=this;if(o)return this.cacheResult().__iterator(i,o);var s=t.__iterator(Pe,o),a=!0,c=0;return new Ye(function(){var t,o,h;do{if(t=s.next(),t.done)return n||i===Je?t:i===Be?w(i,c++,void 0,t):w(i,c++,t.value[1],t);var f=t.value;o=f[0],h=f[1],a&&(a=e.call(r,h,o,u))}while(a);return i===Pe?t:w(i,o,h,t)})},i}function $(t,e){var r=l(t),n=[t].concat(e).map(function(t){return _(t)?r&&(t=Te(t)):t=r?E(t):x(Array.isArray(t)?t:[t]),t}).filter(function(t){return 0!==t.size});if(0===n.length)return t;if(1===n.length){var i=n[0];if(i===t||r&&l(i)||v(t)&&v(i))return i}var o=new $e(n);return r?o=o.toKeyedSeq():v(t)||(o=o.toSetSeq()),o=o.flatten(!0),o.size=n.reduce(function(t,e){if(void 0!==t){var r=e.size;if(void 0!==r)return t+r}},0),o}function tt(t,e,r){var n=ht(t);return n.__iterateUncached=function(i,o){function u(t,c){t.__iterate(function(t,o){return(!e||c0}function ut(t,e,r){var n=ht(t);return n.size=new $e(r).map(function(t){return t.size}).min(),n.__iterate=function(t,e){for(var r,n=this,i=this.__iterator(Je,e),o=0;!(r=i.next()).done&&t(r.value,o++,n)!==!1;);return o},n.__iteratorUncached=function(t,n){var i=r.map(function(t){return t=Le(t),b(n?t.reverse():t)}),o=0,u=!1;return new Ye(function(){var r;return u||(r=i.map(function(t){return t.next()}),u=r.some(function(t){return t.done})),u?z():w(t,o++,e.apply(null,r.map(function(t){return t.value})))})},n}function st(t,e){return t===e?t:q(t)?e:t.constructor(e)}function at(t){if(t!==Object(t))throw new TypeError("Expected [K, V] tuple: "+t)}function ct(t){return l(t)?Te:v(t)?Ce:We}function ht(t){return Object.create((l(t)?Xe:v(t)?Fe:Ge).prototype)}function ft(){return this._iter.cacheResult?(this._iter.cacheResult(),this.size=this._iter.size,this):Qe.prototype.cacheResult.call(this)}function pt(t,e){return void 0===t&&void 0===e?0:void 0===t?1:void 0===e?-1:t>e?1:t>>r)&De,s=(0===r?n:n>>>r)&De;return new Ir(e,1<>>=1)u[s]=1&r?e[o++]:void 0;return u[n]=i,new br(t,o+1,u)}function Et(t,e,r){for(var n=[],i=0;i>1&1431655765,t=(858993459&t)+(t>>2&858993459),t=t+(t>>4)&252645135,t+=t>>8,127&(t+=t>>16)}function Ut(t,e,r,n){var o=n?t:i(t);return o[e]=r,o}function Kt(t,e,r,n){var i=t.length+1;if(n&&e+1===i)return t[e]=r,t;for(var o=Array(i),u=0,s=0;so?0:o-r,c=u-r;return c>qe&&(c=qe),function(){if(i===c)return Lr;var t=e?--c:i++;return n&&n[t]}}function i(t,n,i){var s,a=t&&t.array,c=i>o?0:o-i>>n,h=1+(u-i>>n);return h>qe&&(h=qe),function(){for(;;){if(s){var t=s();if(t!==Lr)return t;s=null}if(c===h)return Lr;var o=e?--h:c++;s=r(a&&a[o],n-Me,i+(o<=t.size||r<0)return t.withMutations(function(t){r<0?Ht(t,r).set(0,n):Ht(t,0,r+1).set(r,n)});r+=t._origin;var i=t._tail,o=t._root,s=e(je) -;return r>=Qt(t._capacity)?i=Pt(i,t.__ownerID,0,r,n,s):o=Pt(o,t.__ownerID,t._level,r,n,s),s.value?t.__ownerID?(t._root=o,t._tail=i,t.__hash=void 0,t.__altered=!0,t):Wt(t._origin,t._capacity,t._level,o,i):t}function Pt(t,e,n,i,o,u){var s=i>>>n&De,a=t&&s0){var h=t&&t.array[s],f=Pt(h,e,n-Me,i,o,u);return f===h?t:(c=Nt(t,e),c.array[s]=f,c)}return a&&t.array[s]===o?t:(r(u),c=Nt(t,e),void 0===o&&s===c.array.length-1?c.array.pop():c.array[s]=o,c)}function Nt(t,e){return e&&t&&e===t.ownerID?t:new Ur(t?t.array.slice():[],e)}function Vt(t,e){if(e>=Qt(t._capacity))return t._tail;if(e<1<0;)r=r.array[e>>>n&De],n-=Me;return r}}function Ht(t,e,r){void 0!==e&&(e|=0),void 0!==r&&(r|=0);var i=t.__ownerID||new n,o=t._origin,u=t._capacity,s=o+e,a=void 0===r?u:r<0?u+r:o+r;if(s===o&&a===u)return t;if(s>=a)return t.clear();for(var c=t._level,h=t._root,f=0;s+f<0;)h=new Ur(h&&h.array.length?[void 0,h]:[],i),c+=Me,f+=1<=1<p?new Ur([],i):l;if(l&&_>p&&sMe;d-=Me){var g=p>>>d&De;y=y.array[g]=Nt(y.array[g],i)}y.array[p>>>Me&De]=l}if(a=_)s-=_,a-=_,c=Me,h=null,v=v&&v.removeBefore(i,0,s);else if(s>o||_>>c&De;if(m!==_>>>c&De)break;m&&(f+=(1<o&&(h=h.removeBefore(i,c,s-f)),h&&_i&&(i=s.size),_(u)||(s=s.map(function(t){return R(t)})),n.push(s)}return i>t.size&&(t=t.setSize(i)),kt(t,e,n)}function Qt(t){return t>>Me<=qe&&u.size>=2*o.size?(i=u.filter(function(t,e){return void 0!==t&&s!==e}),n=i.toKeyedSeq().map(function(t){return t[0]}).flip().toMap(),t.__ownerID&&(n.__ownerID=i.__ownerID=t.__ownerID)):(n=o.remove(e),i=s===u.size-1?u.pop():u.set(s,void 0))}else if(a){if(r===u.get(s)[1])return t;n=o,i=u.set(s,[e,r])}else n=o.set(e,u.size),i=u.set(u.size,[e,r]);return t.__ownerID?(t.size=n.size,t._map=n,t._list=i,t.__hash=void 0,t):Ft(n,i)}function $t(t){return!(!t||!t[Br])}function te(t,e,r,n){var i=Object.create(Jr);return i.size=t,i._head=e,i.__ownerID=r,i.__hash=n,i.__altered=!1,i}function ee(){return Pr||(Pr=te(0))}function re(t,e){if(t===e)return!0;if(!_(e)||void 0!==t.size&&void 0!==e.size&&t.size!==e.size||void 0!==t.__hash&&void 0!==e.__hash&&t.__hash!==e.__hash||l(t)!==l(e)||v(t)!==v(e)||d(t)!==d(e))return!1;if(0===t.size&&0===e.size)return!0;var r=!y(t);if(d(t)){var n=t.entries();return e.every(function(t,e){var i=n.next().value;return i&&A(i[1],t)&&(r||A(i[0],e))})&&n.next().done}var i=!1;if(void 0===t.size)if(void 0===e.size)"function"==typeof t.cacheResult&&t.cacheResult();else{i=!0;var o=t;t=e,e=o}var u=!0,s=e.__iterate(function(e,n){if(r?!t.has(e):i?!A(e,t.get(n,Ee)):!A(t.get(n,Ee),e))return u=!1,!1});return u&&t.size===s}function ne(t,e){var r=function(r){t.prototype[r]=e[r]};return Object.keys(e).forEach(r),Object.getOwnPropertySymbols&&Object.getOwnPropertySymbols(e).forEach(r),t}function ie(t){return!(!t||!t[Vr])}function oe(t,e){return t.__ownerID?(t.size=e.size,t._map=e,t):e===t._map?t:0===e.size?t.__empty():t.__make(e)}function ue(t,e){var r=Object.create(Hr);return r.size=t?t.size:0,r._map=t,r.__ownerID=e,r}function se(){return Yr||(Yr=ue(zt()))}function ae(t,e,r,n,i,o){return vt(t.size),t.__iterate(function(t,o,u){i?(i=!1,r=t):r=e.call(n,r,t,o,u)},o),r}function ce(t,e){return e} -function he(t,e){return[e,t]}function fe(t){return t&&"function"==typeof t.toJS?t.toJS():t}function pe(t){return function(){return!t.apply(this,arguments)}}function _e(t){return function(){return-t.apply(this,arguments)}}function le(){return i(arguments)}function ve(t,e){return te?-1:0}function ye(t){if(t.size===1/0)return 0;var e=d(t),r=l(t),n=e?1:0;return de(t.__iterate(r?e?function(t,e){n=31*n+ge(C(t),C(e))|0}:function(t,e){n=n+ge(C(t),C(e))|0}:e?function(t){n=31*n+C(t)|0}:function(t){n=n+C(t)|0}),n)}function de(t,e){return e=or(e,3432918353),e=or(e<<15|e>>>-15,461845907),e=or(e<<13|e>>>-13,5),e=(e+3864292196|0)^t,e=or(e^e>>>16,2246822507),e=or(e^e>>>13,3266489909),e=T(e^e>>>16)}function ge(t,e){return t^e+2654435769+(t<<6)+(t>>2)|0}function me(t){return ie(t)&&d(t)}function we(t,e){var r=Object.create(tn);return r.size=t?t.size:0,r._map=t,r.__ownerID=e,r}function ze(){return en||(en=we(Gt()))}function Se(t,e,r){var n=Object.create(Object.getPrototypeOf(t));return n._values=e,n.__ownerID=r,n}function Ie(t){return t._name||t.constructor.name||"Record"}function be(t){return E(t._keys.map(function(e){return[e,t.get(e)]}))}function Oe(t,e){try{Object.defineProperty(t,e,{get:function(){return this.get(e)},set:function(t){lt(this.__ownerID,"Cannot set on an immutable record."),this.set(e,t)}})}catch(t){}}var Me=5,qe=1<0}function ut(t,e,r){var n=ht(t);return n.size=new $e(r).map(function(t){return t.size}).min(),n.__iterate=function(t,e){for(var r,n=this,i=this.__iterator(Je,e),o=0;!(r=i.next()).done&&t(r.value,o++,n)!==!1;);return o},n.__iteratorUncached=function(t,n){var i=r.map(function(t){return t=Le(t),b(n?t.reverse():t)}),o=0,u=!1;return new Ye(function(){var r;return u||(r=i.map(function(t){return t.next()}),u=r.some(function(t){return t.done})),u?z():w(t,o++,e.apply(null,r.map(function(t){return t.value})))})},n}function st(t,e){return t===e?t:D(t)?e:t.constructor(e)}function at(t){if(t!==Object(t))throw new TypeError("Expected [K, V] tuple: "+t)}function ct(t){return l(t)?Te:v(t)?Ce:We}function ht(t){return Object.create((l(t)?Xe:v(t)?Fe:Ge).prototype)}function ft(){return this._iter.cacheResult?(this._iter.cacheResult(),this.size=this._iter.size,this):Qe.prototype.cacheResult.call(this)}function pt(t,e){return void 0===t&&void 0===e?0:void 0===t?1:void 0===e?-1:t>e?1:t>>r)&qe,s=(0===r?n:n>>>r)&qe;return new Ir(e,1<>>=1)u[s]=1&r?e[o++]:void 0;return u[n]=i,new br(t,o+1,u)}function Et(t,e,r){for(var n=[],i=0;i>1&1431655765,t=(858993459&t)+(t>>2&858993459),t=t+(t>>4)&252645135,t+=t>>8,127&(t+=t>>16)}function Ut(t,e,r,n){var o=n?t:i(t);return o[e]=r,o}function Kt(t,e,r,n){var i=t.length+1;if(n&&e+1===i)return t[e]=r,t;for(var o=Array(i),u=0,s=0;so?0:o-r,c=u-r;return c>De&&(c=De),function(){if(i===c)return Lr;var t=e?--c:i++;return n&&n[t]}}function i(t,n,i){var s,a=t&&t.array,c=i>o?0:o-i>>n,h=1+(u-i>>n);return h>De&&(h=De),function(){for(;;){if(s){var t=s();if(t!==Lr)return t;s=null}if(c===h)return Lr;var o=e?--h:c++;s=r(a&&a[o],n-Me,i+(o<=t.size||r<0)return t.withMutations(function(t){r<0?Ht(t,r).set(0,n):Ht(t,0,r+1).set(r,n)});r+=t._origin;var i=t._tail,o=t._root,s=e(ke) +;return r>=Qt(t._capacity)?i=Pt(i,t.__ownerID,0,r,n,s):o=Pt(o,t.__ownerID,t._level,r,n,s),s.value?t.__ownerID?(t._root=o,t._tail=i,t.__hash=void 0,t.__altered=!0,t):Wt(t._origin,t._capacity,t._level,o,i):t}function Pt(t,e,n,i,o,u){var s=i>>>n&qe,a=t&&s0){var h=t&&t.array[s],f=Pt(h,e,n-Me,i,o,u);return f===h?t:(c=Nt(t,e),c.array[s]=f,c)}return a&&t.array[s]===o?t:(r(u),c=Nt(t,e),void 0===o&&s===c.array.length-1?c.array.pop():c.array[s]=o,c)}function Nt(t,e){return e&&t&&e===t.ownerID?t:new Ur(t?t.array.slice():[],e)}function Vt(t,e){if(e>=Qt(t._capacity))return t._tail;if(e<1<0;)r=r.array[e>>>n&qe],n-=Me;return r}}function Ht(t,e,r){void 0!==e&&(e|=0),void 0!==r&&(r|=0);var i=t.__ownerID||new n,o=t._origin,u=t._capacity,s=o+e,a=void 0===r?u:r<0?u+r:o+r;if(s===o&&a===u)return t;if(s>=a)return t.clear();for(var c=t._level,h=t._root,f=0;s+f<0;)h=new Ur(h&&h.array.length?[void 0,h]:[],i),c+=Me,f+=1<=1<p?new Ur([],i):l;if(l&&_>p&&sMe;d-=Me){var g=p>>>d&qe;y=y.array[g]=Nt(y.array[g],i)}y.array[p>>>Me&qe]=l}if(a=_)s-=_,a-=_,c=Me,h=null,v=v&&v.removeBefore(i,0,s);else if(s>o||_>>c&qe;if(m!==_>>>c&qe)break;m&&(f+=(1<o&&(h=h.removeBefore(i,c,s-f)),h&&_i&&(i=s.size),_(u)||(s=s.map(function(t){return R(t)})),n.push(s)}return i>t.size&&(t=t.setSize(i)),jt(t,e,n)}function Qt(t){return t>>Me<=De&&u.size>=2*o.size?(i=u.filter(function(t,e){return void 0!==t&&s!==e}),n=i.toKeyedSeq().map(function(t){return t[0]}).flip().toMap(),t.__ownerID&&(n.__ownerID=i.__ownerID=t.__ownerID)):(n=o.remove(e),i=s===u.size-1?u.pop():u.set(s,void 0))}else if(a){if(r===u.get(s)[1])return t;n=o,i=u.set(s,[e,r])}else n=o.set(e,u.size),i=u.set(u.size,[e,r]);return t.__ownerID?(t.size=n.size,t._map=n,t._list=i,t.__hash=void 0,t):Ft(n,i)}function $t(t){return!(!t||!t[Br])}function te(t,e,r,n){var i=Object.create(Jr);return i.size=t,i._head=e,i.__ownerID=r,i.__hash=n,i.__altered=!1,i}function ee(){return Pr||(Pr=te(0))}function re(t,e){if(t===e)return!0;if(!_(e)||void 0!==t.size&&void 0!==e.size&&t.size!==e.size||void 0!==t.__hash&&void 0!==e.__hash&&t.__hash!==e.__hash||l(t)!==l(e)||v(t)!==v(e)||d(t)!==d(e))return!1;if(0===t.size&&0===e.size)return!0;var r=!y(t);if(d(t)){var n=t.entries();return e.every(function(t,e){var i=n.next().value;return i&&A(i[1],t)&&(r||A(i[0],e))})&&n.next().done}var i=!1;if(void 0===t.size)if(void 0===e.size)"function"==typeof t.cacheResult&&t.cacheResult();else{i=!0;var o=t;t=e,e=o}var u=!0,s=e.__iterate(function(e,n){if(r?!t.has(e):i?!A(e,t.get(n,Ee)):!A(t.get(n,Ee),e))return u=!1,!1});return u&&t.size===s}function ne(t,e){var r=function(r){t.prototype[r]=e[r]};return Object.keys(e).forEach(r),Object.getOwnPropertySymbols&&Object.getOwnPropertySymbols(e).forEach(r),t}function ie(t){return!(!t||!t[Vr])}function oe(t,e){return t.__ownerID?(t.size=e.size,t._map=e,t):e===t._map?t:0===e.size?t.__empty():t.__make(e)}function ue(t,e){var r=Object.create(Hr);return r.size=t?t.size:0,r._map=t,r.__ownerID=e,r}function se(){return Yr||(Yr=ue(zt()))}function ae(t,e,r,n,i,o){return vt(t.size),t.__iterate(function(t,o,u){i?(i=!1,r=t):r=e.call(n,r,t,o,u)},o),r}function ce(t,e){return e} +function he(t,e){return[e,t]}function fe(t){return t&&"function"==typeof t.toJS?t.toJS():t}function pe(t){return function(){return!t.apply(this,arguments)}}function _e(t){return function(){return-t.apply(this,arguments)}}function le(){return i(arguments)}function ve(t,e){return te?-1:0}function ye(t){if(t.size===1/0)return 0;var e=d(t),r=l(t),n=e?1:0;return de(t.__iterate(r?e?function(t,e){n=31*n+ge(C(t),C(e))|0}:function(t,e){n=n+ge(C(t),C(e))|0}:e?function(t){n=31*n+C(t)|0}:function(t){n=n+C(t)|0}),n)}function de(t,e){return e=or(e,3432918353),e=or(e<<15|e>>>-15,461845907),e=or(e<<13|e>>>-13,5),e=(e+3864292196|0)^t,e=or(e^e>>>16,2246822507),e=or(e^e>>>13,3266489909),e=T(e^e>>>16)}function ge(t,e){return t^e+2654435769+(t<<6)+(t>>2)|0}function me(t){return ie(t)&&d(t)}function we(t,e){var r=Object.create(tn);return r.size=t?t.size:0,r._map=t,r.__ownerID=e,r}function ze(){return en||(en=we(Gt()))}function Se(t,e,r){var n=Object.create(Object.getPrototypeOf(t));return n._values=e,n.__ownerID=r,n}function Ie(t){return t._name||t.constructor.name||"Record"}function be(t){return E(t._keys.map(function(e){return[e,t.get(e)]}))}function Oe(t,e){try{Object.defineProperty(t,e,{get:function(){return this.get(e)},set:function(t){lt(this.__ownerID,"Cannot set on an immutable record."),this.set(e,t)}})}catch(t){}}var Me=5,De=1<=n.length){var e=r.next();if(e.done)return e;n[i]=e.value}return w(t,i,n[i++])})},e}(Fe),or="function"==typeof Math.imul&&Math.imul(4294967295,2)===-2?Math.imul:function(t,e){t|=0,e|=0;var r=65535&t,n=65535&e;return r*n+((t>>>16)*n+r*(e>>>16)<<16>>>0)|0},ur=Object.isExtensible,sr=function(){try{return Object.defineProperty({},"@",{}),!0}catch(t){return!1}}(),ar="function"==typeof WeakMap;ar&&(rr=new WeakMap);var cr=0,hr="__immutablehash__";"function"==typeof Symbol&&(hr=Symbol(hr));var fr=16,pr=255,_r=0,lr={},vr=function(t){function e(t,e){this._iter=t,this._useKeys=e,this.size=t.size}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.get=function(t,e){return this._iter.get(t,e)},e.prototype.has=function(t){return this._iter.has(t)},e.prototype.valueSeq=function(){return this._iter.valueSeq()},e.prototype.reverse=function(){var t=this,e=H(this,!0);return this._useKeys||(e.valueSeq=function(){return t._iter.toSeq().reverse()}),e},e.prototype.map=function(t,e){var r=this,n=V(this,t,e);return this._useKeys||(n.valueSeq=function(){return r._iter.toSeq().map(t,e)}),n},e.prototype.__iterate=function(t,e){var r=this;return this._iter.__iterate(function(e,n){return t(e,n,r)},e)},e.prototype.__iterator=function(t,e){return this._iter.__iterator(t,e)},e}(Xe);vr.prototype[Ue]=!0;var yr=function(t){function e(t){this._iter=t, this.size=t.size}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.includes=function(t){return this._iter.includes(t)},e.prototype.__iterate=function(t,e){var r=this,n=0;return e&&o(this),this._iter.__iterate(function(i){return t(i,e?r.size-++n:n++,r)},e)},e.prototype.__iterator=function(t,e){var r=this,n=this._iter.__iterator(Je,e),i=0;return e&&o(this),new Ye(function(){var o=n.next();return o.done?o:w(t,e?r.size-++i:i++,o.value,o)})},e}(Fe),dr=function(t){function e(t){this._iter=t,this.size=t.size}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.has=function(t){return this._iter.includes(t)},e.prototype.__iterate=function(t,e){var r=this;return this._iter.__iterate(function(e){return t(e,e,r)},e)},e.prototype.__iterator=function(t,e){var r=this._iter.__iterator(Je,e);return new Ye(function(){var e=r.next();return e.done?e:w(t,e.value,e.value,e)})},e}(Ge),gr=function(t){function e(t){this._iter=t,this.size=t.size}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.entrySeq=function(){return this._iter.toSeq()},e.prototype.__iterate=function(t,e){var r=this;return this._iter.__iterate(function(e){if(e){at(e);var n=_(e);return t(n?e.get(1):e[1],n?e.get(0):e[0],r)}},e)},e.prototype.__iterator=function(t,e){var r=this._iter.__iterator(Je,e);return new Ye(function(){for(;;){var e=r.next();if(e.done)return e;var n=e.value;if(n){at(n);var i=_(n);return w(t,i?n.get(0):n[0],i?n.get(1):n[1],e)}}})},e}(Xe);yr.prototype.cacheResult=vr.prototype.cacheResult=dr.prototype.cacheResult=gr.prototype.cacheResult=ft;var mr=function(t){function e(e){return null===e||void 0===e?zt():dt(e)&&!d(e)?e:zt().withMutations(function(r){var n=t(e);vt(n.size),n.forEach(function(t,e){return r.set(e,t)})})}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e] -;return zt().withMutations(function(e){for(var r=0;r=t.length)throw Error("Missing value for key: "+t[r]);e.set(t[r],t[r+1])}})},e.prototype.toString=function(){return this.__toString("Map {","}")},e.prototype.get=function(t,e){return this._root?this._root.get(0,void 0,t,e):e},e.prototype.set=function(t,e){return St(this,t,e)},e.prototype.setIn=function(t,e){return this.updateIn(t,Ee,function(){return e})},e.prototype.remove=function(t){return St(this,t,Ee)},e.prototype.deleteIn=function(t){if(t=[].concat(_t(t)),t.length){var e=t.pop();return this.updateIn(t,function(t){return t&&t.remove(e)})}},e.prototype.deleteAll=function(t){var e=Le(t);return 0===e.size?this:this.withMutations(function(t){e.forEach(function(e){return t.remove(e)})})},e.prototype.update=function(t,e,r){return 1===arguments.length?t(this):this.updateIn([t],e,r)},e.prototype.updateIn=function(t,e,r){r||(r=e,e=void 0);var n=At(this,_t(t),0,e,r);return n===Ee?e:n},e.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._root=null,this.__hash=void 0,this.__altered=!0,this):zt()},e.prototype.merge=function(){return Et(this,void 0,arguments)},e.prototype.mergeWith=function(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return Et(this,t,e)},e.prototype.mergeIn=function(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return this.updateIn(t,zt(),function(t){return"function"==typeof t.merge?t.merge.apply(t,e):e[e.length-1]})},e.prototype.mergeDeep=function(){return Et(this,xt,arguments)},e.prototype.mergeDeepWith=function(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return Et(this,jt(t),e)},e.prototype.mergeDeepIn=function(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return this.updateIn(t,zt(),function(t){return"function"==typeof t.mergeDeep?t.mergeDeep.apply(t,e):e[e.length-1]})},e.prototype.sort=function(t){return Tr(nt(this,t))},e.prototype.sortBy=function(t,e){return Tr(nt(this,e,t))}, -e.prototype.withMutations=function(t){var e=this.asMutable();return t(e),e.wasAltered()?e.__ensureOwner(this.__ownerID):this},e.prototype.asMutable=function(){return this.__ownerID?this:this.__ensureOwner(new n)},e.prototype.asImmutable=function(){return this.__ensureOwner()},e.prototype.wasAltered=function(){return this.__altered},e.prototype.__iterator=function(t,e){return new Dr(this,t,e)},e.prototype.__iterate=function(t,e){var r=this,n=0;return this._root&&this._root.iterate(function(e){return n++,t(e[1],e[0],r)},e),n},e.prototype.__ensureOwner=function(t){return t===this.__ownerID?this:t?wt(this.size,this._root,t,this.__hash):0===this.size?zt():(this.__ownerID=t,this.__altered=!1,this)},e}(Te);mr.isMap=dt;var wr="@@__IMMUTABLE_MAP__@@",zr=mr.prototype;zr[wr]=!0,zr.delete=zr.remove,zr.removeIn=zr.deleteIn,zr.removeAll=zr.deleteAll;var Sr=function(t,e){this.ownerID=t,this.entries=e};Sr.prototype.get=function(t,e,r,n){for(var i=this.entries,o=0,u=i.length;o=Er)return Mt(t,h,o,u);var l=t&&t===this.ownerID,v=l?h:i(h);return _?c?f===p-1?v.pop():v[f]=v.pop():v[f]=[o,u]:v.push([o,u]),l?(this.entries=v,this):new Sr(t,v)}};var Ir=function(t,e,r){this.ownerID=t,this.bitmap=e,this.nodes=r};Ir.prototype.get=function(t,e,r,n){void 0===e&&(e=C(r));var i=1<<((0===t?e:e>>>t)&De),o=this.bitmap;return 0==(o&i)?n:this.nodes[Rt(o&i-1)].get(t+Me,e,r,n)},Ir.prototype.update=function(t,e,r,n,i,o,u){void 0===r&&(r=C(n));var s=(0===e?r:r>>>e)&De,a=1<=xr)return Dt(t,p,c,s,l);if(h&&!l&&2===p.length&&bt(p[1^f]))return p[1^f];if(h&&l&&1===p.length&&bt(l))return l -;var v=t&&t===this.ownerID,y=h?l?c:c^a:c|a,d=h?l?Ut(p,f,l,v):Lt(p,f,v):Kt(p,f,l,v);return v?(this.bitmap=y,this.nodes=d,this):new Ir(t,y,d)};var br=function(t,e,r){this.ownerID=t,this.count=e,this.nodes=r};br.prototype.get=function(t,e,r,n){void 0===e&&(e=C(r));var i=(0===t?e:e>>>t)&De,o=this.nodes[i];return o?o.get(t+Me,e,r,n):n},br.prototype.update=function(t,e,r,n,i,o,u){void 0===r&&(r=C(n));var s=(0===e?r:r>>>e)&De,a=i===Ee,c=this.nodes,h=c[s];if(a&&!h)return this;var f=It(h,t,e+Me,r,n,i,o,u);if(f===h)return this;var p=this.count;if(h){if(!f&&--p0&&i=0&&t0;)e[r]=arguments[r+1];return Yt(this,t,e)},e.prototype.mergeDeep=function(){return Yt(this,xt,arguments)},e.prototype.mergeDeepWith=function(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return Yt(this,jt(t),e)},e.prototype.setSize=function(t){return Ht(this,0,t)},e.prototype.slice=function(t,e){var r=this.size;return a(t,e,r)?this:Ht(this,c(t,r),h(e,r))},e.prototype.__iterator=function(t,e){var r=e?this.size:0,n=Ct(this,e);return new Ye(function(){var i=n();return i===Lr?z():w(t,e?--r:r++,i)})},e.prototype.__iterate=function(t,e){for(var r,n=this,i=e?this.size:0,o=Ct(this,e);(r=o())!==Lr&&t(r,e?--i:i++,n)!==!1;);return i},e.prototype.__ensureOwner=function(t){return t===this.__ownerID?this:t?Wt(this._origin,this._capacity,this._level,this._root,this._tail,t,this.__hash):0===this.size?Bt():(this.__ownerID=t,this)},e}(Ce);kr.isList=Tt;var Ar="@@__IMMUTABLE_LIST__@@",Rr=kr.prototype;Rr[Ar]=!0,Rr.delete=Rr.remove,Rr.setIn=zr.setIn,Rr.deleteIn=Rr.removeIn=zr.removeIn,Rr.update=zr.update,Rr.updateIn=zr.updateIn,Rr.mergeIn=zr.mergeIn,Rr.mergeDeepIn=zr.mergeDeepIn,Rr.withMutations=zr.withMutations,Rr.asMutable=zr.asMutable,Rr.asImmutable=zr.asImmutable,Rr.wasAltered=zr.wasAltered;var Ur=function(t,e){this.array=t,this.ownerID=e};Ur.prototype.removeBefore=function(t,e,r){if(r===e?1<>>e&De;if(n>=this.array.length)return new Ur([],t);var i,o=0===n;if(e>0){var u=this.array[n];if((i=u&&u.removeBefore(t,e-Me,r))===u&&o)return this}if(o&&!i)return this;var s=Nt(this,t);if(!o)for(var a=0;a>>e&De;if(n>=this.array.length)return this;var i;if(e>0){var o=this.array[n] +;return zt().withMutations(function(e){for(var r=0;r=t.length)throw Error("Missing value for key: "+t[r]);e.set(t[r],t[r+1])}})},e.prototype.toString=function(){return this.__toString("Map {","}")},e.prototype.get=function(t,e){return this._root?this._root.get(0,void 0,t,e):e},e.prototype.set=function(t,e){return St(this,t,e)},e.prototype.setIn=function(t,e){return this.updateIn(t,Ee,function(){return e})},e.prototype.remove=function(t){return St(this,t,Ee)},e.prototype.deleteIn=function(t){if(t=[].concat(_t(t)),t.length){var e=t.pop();return this.updateIn(t,function(t){return t&&t.remove(e)})}},e.prototype.deleteAll=function(t){var e=Le(t);return 0===e.size?this:this.withMutations(function(t){e.forEach(function(e){return t.remove(e)})})},e.prototype.update=function(t,e,r){return 1===arguments.length?t(this):this.updateIn([t],e,r)},e.prototype.updateIn=function(t,e,r){r||(r=e,e=void 0);var n=At(this,_t(t),0,e,r);return n===Ee?e:n},e.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._root=null,this.__hash=void 0,this.__altered=!0,this):zt()},e.prototype.merge=function(){return Et(this,void 0,arguments)},e.prototype.mergeWith=function(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return Et(this,t,e)},e.prototype.mergeIn=function(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return this.updateIn(t,zt(),function(t){return"function"==typeof t.merge?t.merge.apply(t,e):e[e.length-1]})},e.prototype.mergeDeep=function(){return Et(this,xt,arguments)},e.prototype.mergeDeepWith=function(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return Et(this,kt(t),e)},e.prototype.mergeDeepIn=function(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return this.updateIn(t,zt(),function(t){return"function"==typeof t.mergeDeep?t.mergeDeep.apply(t,e):e[e.length-1]})},e.prototype.sort=function(t){return Tr(nt(this,t))},e.prototype.sortBy=function(t,e){return Tr(nt(this,e,t))}, +e.prototype.withMutations=function(t){var e=this.asMutable();return t(e),e.wasAltered()?e.__ensureOwner(this.__ownerID):this},e.prototype.asMutable=function(){return this.__ownerID?this:this.__ensureOwner(new n)},e.prototype.asImmutable=function(){return this.__ensureOwner()},e.prototype.wasAltered=function(){return this.__altered},e.prototype.__iterator=function(t,e){return new qr(this,t,e)},e.prototype.__iterate=function(t,e){var r=this,n=0;return this._root&&this._root.iterate(function(e){return n++,t(e[1],e[0],r)},e),n},e.prototype.__ensureOwner=function(t){return t===this.__ownerID?this:t?wt(this.size,this._root,t,this.__hash):0===this.size?zt():(this.__ownerID=t,this.__altered=!1,this)},e}(Te);mr.isMap=dt;var wr="@@__IMMUTABLE_MAP__@@",zr=mr.prototype;zr[wr]=!0,zr.delete=zr.remove,zr.removeIn=zr.deleteIn,zr.removeAll=zr.deleteAll;var Sr=function(t,e){this.ownerID=t,this.entries=e};Sr.prototype.get=function(t,e,r,n){for(var i=this.entries,o=0,u=i.length;o=Er)return Mt(t,h,o,u);var l=t&&t===this.ownerID,v=l?h:i(h);return _?c?f===p-1?v.pop():v[f]=v.pop():v[f]=[o,u]:v.push([o,u]),l?(this.entries=v,this):new Sr(t,v)}};var Ir=function(t,e,r){this.ownerID=t,this.bitmap=e,this.nodes=r};Ir.prototype.get=function(t,e,r,n){void 0===e&&(e=C(r));var i=1<<((0===t?e:e>>>t)&qe),o=this.bitmap;return 0==(o&i)?n:this.nodes[Rt(o&i-1)].get(t+Me,e,r,n)},Ir.prototype.update=function(t,e,r,n,i,o,u){void 0===r&&(r=C(n));var s=(0===e?r:r>>>e)&qe,a=1<=xr)return qt(t,p,c,s,l);if(h&&!l&&2===p.length&&bt(p[1^f]))return p[1^f];if(h&&l&&1===p.length&&bt(l))return l +;var v=t&&t===this.ownerID,y=h?l?c:c^a:c|a,d=h?l?Ut(p,f,l,v):Lt(p,f,v):Kt(p,f,l,v);return v?(this.bitmap=y,this.nodes=d,this):new Ir(t,y,d)};var br=function(t,e,r){this.ownerID=t,this.count=e,this.nodes=r};br.prototype.get=function(t,e,r,n){void 0===e&&(e=C(r));var i=(0===t?e:e>>>t)&qe,o=this.nodes[i];return o?o.get(t+Me,e,r,n):n},br.prototype.update=function(t,e,r,n,i,o,u){void 0===r&&(r=C(n));var s=(0===e?r:r>>>e)&qe,a=i===Ee,c=this.nodes,h=c[s];if(a&&!h)return this;var f=It(h,t,e+Me,r,n,i,o,u);if(f===h)return this;var p=this.count;if(h){if(!f&&--p0&&i=0&&t0;)e[r]=arguments[r+1];return Yt(this,t,e)},e.prototype.mergeDeep=function(){return Yt(this,xt,arguments)},e.prototype.mergeDeepWith=function(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return Yt(this,kt(t),e)},e.prototype.setSize=function(t){return Ht(this,0,t)},e.prototype.slice=function(t,e){var r=this.size;return a(t,e,r)?this:Ht(this,c(t,r),h(e,r))},e.prototype.__iterator=function(t,e){var r=e?this.size:0,n=Ct(this,e);return new Ye(function(){var i=n();return i===Lr?z():w(t,e?--r:r++,i)})},e.prototype.__iterate=function(t,e){for(var r,n=this,i=e?this.size:0,o=Ct(this,e);(r=o())!==Lr&&t(r,e?--i:i++,n)!==!1;);return i},e.prototype.__ensureOwner=function(t){return t===this.__ownerID?this:t?Wt(this._origin,this._capacity,this._level,this._root,this._tail,t,this.__hash):0===this.size?Bt():(this.__ownerID=t,this)},e}(Ce);jr.isList=Tt;var Ar="@@__IMMUTABLE_LIST__@@",Rr=jr.prototype;Rr[Ar]=!0,Rr.delete=Rr.remove,Rr.setIn=zr.setIn,Rr.deleteIn=Rr.removeIn=zr.removeIn,Rr.update=zr.update,Rr.updateIn=zr.updateIn,Rr.mergeIn=zr.mergeIn,Rr.mergeDeepIn=zr.mergeDeepIn,Rr.withMutations=zr.withMutations,Rr.asMutable=zr.asMutable,Rr.asImmutable=zr.asImmutable,Rr.wasAltered=zr.wasAltered;var Ur=function(t,e){this.array=t,this.ownerID=e};Ur.prototype.removeBefore=function(t,e,r){if(r===e?1<>>e&qe;if(n>=this.array.length)return new Ur([],t);var i,o=0===n;if(e>0){var u=this.array[n];if((i=u&&u.removeBefore(t,e-Me,r))===u&&o)return this}if(o&&!i)return this;var s=Nt(this,t);if(!o)for(var a=0;a>>e&qe;if(n>=this.array.length)return this;var i;if(e>0){var o=this.array[n] ;if((i=o&&o.removeAfter(t,e-Me,r))===o&&n===this.array.length-1)return this}var u=Nt(this,t);return u.array.splice(n+1),i&&(u.array[n]=i),u};var Kr,Lr={},Tr=function(t){function e(t){return null===t||void 0===t?Gt():Xt(t)?t:Gt().withMutations(function(e){var r=Te(t);vt(r.size),r.forEach(function(t,r){return e.set(r,t)})})}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return this(arguments)},e.prototype.toString=function(){return this.__toString("OrderedMap {","}")},e.prototype.get=function(t,e){var r=this._map.get(t);return void 0!==r?this._list.get(r)[1]:e},e.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._map.clear(),this._list.clear(),this):Gt()},e.prototype.set=function(t,e){return Zt(this,t,e)},e.prototype.remove=function(t){return Zt(this,t,Ee)},e.prototype.wasAltered=function(){return this._map.wasAltered()||this._list.wasAltered()},e.prototype.__iterate=function(t,e){var r=this;return this._list.__iterate(function(e){return e&&t(e[1],e[0],r)},e)},e.prototype.__iterator=function(t,e){return this._list.fromEntrySeq().__iterator(t,e)},e.prototype.__ensureOwner=function(t){if(t===this.__ownerID)return this;var e=this._map.__ensureOwner(t),r=this._list.__ensureOwner(t);return t?Ft(e,r,t,this.__hash):0===this.size?Gt():(this.__ownerID=t,this._map=e,this._list=r,this)},e}(mr);Tr.isOrderedMap=Xt,Tr.prototype[Ue]=!0,Tr.prototype.delete=Tr.prototype.remove;var Cr,Wr=function(t){function e(t){return null===t||void 0===t?ee():$t(t)?t:ee().pushAll(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return this(arguments)},e.prototype.toString=function(){return this.__toString("Stack [","]")},e.prototype.get=function(t,e){var r=this._head;for(t=u(this,t);r&&t--;)r=r.next;return r?r.value:e},e.prototype.peek=function(){return this._head&&this._head.value},e.prototype.push=function(){var t=arguments;if(0===arguments.length)return this ;for(var e=this.size+arguments.length,r=this._head,n=arguments.length-1;n>=0;n--)r={value:t[n],next:r};return this.__ownerID?(this.size=e,this._head=r,this.__hash=void 0,this.__altered=!0,this):te(e,r)},e.prototype.pushAll=function(e){if(e=t(e),0===e.size)return this;if(0===this.size&&$t(e))return e;vt(e.size);var r=this.size,n=this._head;return e.__iterate(function(t){r++,n={value:t,next:n}},!0),this.__ownerID?(this.size=r,this._head=n,this.__hash=void 0,this.__altered=!0,this):te(r,n)},e.prototype.pop=function(){return this.slice(1)},e.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._head=void 0,this.__hash=void 0,this.__altered=!0,this):ee()},e.prototype.slice=function(e,r){if(a(e,r,this.size))return this;var n=c(e,this.size);if(h(r,this.size)!==this.size)return t.prototype.slice.call(this,e,r);for(var i=this.size-n,o=this._head;n--;)o=o.next;return this.__ownerID?(this.size=i,this._head=o,this.__hash=void 0,this.__altered=!0,this):te(i,o)},e.prototype.__ensureOwner=function(t){return t===this.__ownerID?this:t?te(this.size,this._head,t,this.__hash):0===this.size?ee():(this.__ownerID=t,this.__altered=!1,this)},e.prototype.__iterate=function(t,e){var r=this;if(e)return new $e(this.toArray()).__iterate(function(e,n){return t(e,n,r)},e);for(var n=0,i=this._head;i&&t(i.value,n++,r)!==!1;)i=i.next;return n},e.prototype.__iterator=function(t,e){if(e)return new $e(this.toArray()).__iterator(t,e);var r=0,n=this._head;return new Ye(function(){if(n){var e=n.value;return n=n.next,w(t,r++,e)}return z()})},e}(Ce);Wr.isStack=$t;var Br="@@__IMMUTABLE_STACK__@@",Jr=Wr.prototype;Jr[Br]=!0,Jr.withMutations=zr.withMutations,Jr.asMutable=zr.asMutable,Jr.asImmutable=zr.asImmutable,Jr.wasAltered=zr.wasAltered,Jr.shift=Jr.pop,Jr.unshift=Jr.push,Jr.unshiftAll=Jr.pushAll;var Pr,Nr=function(t){function e(e){return null===e||void 0===e?se():ie(e)&&!d(e)?e:se().withMutations(function(r){var n=t(e);vt(n.size),n.forEach(function(t){return r.add(t)})})}return t&&(e.__proto__=t), e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return this(arguments)},e.fromKeys=function(t){return this(Te(t).keySeq())},e.intersect=function(t){return t=Le(t).toArray(),t.length?Hr.intersect.apply(e(t.pop()),t):se()},e.union=function(t){return t=Le(t).toArray(),t.length?Hr.union.apply(e(t.pop()),t):se()},e.prototype.toString=function(){return this.__toString("Set {","}")},e.prototype.has=function(t){return this._map.has(t)},e.prototype.add=function(t){return oe(this,this._map.set(t,!0))},e.prototype.remove=function(t){return oe(this,this._map.remove(t))},e.prototype.clear=function(){return oe(this,this._map.clear())},e.prototype.union=function(){for(var e=[],r=arguments.length;r--;)e[r]=arguments[r];return e=e.filter(function(t){return 0!==t.size}),0===e.length?this:0!==this.size||this.__ownerID||1!==e.length?this.withMutations(function(r){for(var n=0;n0;)e[r]=arguments[r+1];return this.union.apply(this,e)},e.prototype.sort=function(t){return $r(nt(this,t))},e.prototype.sortBy=function(t,e){return $r(nt(this,e,t))},e.prototype.wasAltered=function(){return this._map.wasAltered()},e.prototype.__iterate=function(t,e){var r=this ;return this._map.__iterate(function(e,n){return t(n,n,r)},e)},e.prototype.__iterator=function(t,e){return this._map.map(function(t,e){return e}).__iterator(t,e)},e.prototype.__ensureOwner=function(t){if(t===this.__ownerID)return this;var e=this._map.__ensureOwner(t);return t?this.__make(e,t):0===this.size?se():(this.__ownerID=t,this._map=e,this)},e}(We);Nr.isSet=ie;var Vr="@@__IMMUTABLE_SET__@@",Hr=Nr.prototype;Hr[Vr]=!0,Hr.delete=Hr.remove,Hr.mergeDeep=Hr.merge,Hr.mergeDeepWith=Hr.mergeWith,Hr.withMutations=zr.withMutations,Hr.asMutable=zr.asMutable,Hr.asImmutable=zr.asImmutable,Hr.__empty=se,Hr.__make=ue;var Yr,Qr,Xr=function(t){function e(t,r,n){if(!(this instanceof e))return new e(t,r,n);if(lt(0!==n,"Cannot step a Range by 0"),t=t||0,void 0===r&&(r=1/0),n=void 0===n?1:Math.abs(n),r=0&&e=0&&rthis.size?e:this.find(function(e,r){return r===t},void 0,e)},has:function(t){return(t=u(this,t))>=0&&(void 0!==this.size?this.size===1/0||t | Iterable<[string, any]>> ): this; + /** + * Returns a new instance of this Record type with the value for the + * specific key set to its default value. + * + * @alias remove + */ + delete(key: K): this; + remove(key: K): this; + + /** + * Returns a new instance of this Record type with all values set + * to their default values. + */ + clear(): this; + // Deep persistent changes setIn(keyPath: Iterable, value: any): this; diff --git a/type-definitions/immutable.js.flow b/type-definitions/immutable.js.flow index b70f35b914..e1513dcd26 100644 --- a/type-definitions/immutable.js.flow +++ b/type-definitions/immutable.js.flow @@ -1091,6 +1091,10 @@ declare class RecordInstance { ...collections: Array<$Shape | Iterable<[string, any]>> ): this; + delete>(key: K): this; + remove>(key: K): this; + clear(): this; + setIn(keyPath: Iterable, value: any): this; updateIn(keyPath: Iterable, updater: (value: any) => any): this; mergeIn(keyPath: Iterable, ...collections: Array): this;