immutable 5.0.0-beta.1 → 5.0.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/es/package.json.js +1 -1
- package/dist/immutable.d.ts +16 -4
- package/dist/immutable.js +1 -1
- package/dist/immutable.min.js +1 -1
- package/package.json +1 -1
package/dist/es/package.json.js
CHANGED
package/dist/immutable.d.ts
CHANGED
|
@@ -91,6 +91,16 @@
|
|
|
91
91
|
*/
|
|
92
92
|
|
|
93
93
|
declare namespace Immutable {
|
|
94
|
+
/** @ignore */
|
|
95
|
+
type OnlyObject<T> = Extract<T, object>;
|
|
96
|
+
|
|
97
|
+
/** @ignore */
|
|
98
|
+
type ContainObject<T> = OnlyObject<T> extends object
|
|
99
|
+
? OnlyObject<T> extends never
|
|
100
|
+
? false
|
|
101
|
+
: true
|
|
102
|
+
: false;
|
|
103
|
+
|
|
94
104
|
/**
|
|
95
105
|
* @ignore
|
|
96
106
|
*
|
|
@@ -100,19 +110,19 @@ declare namespace Immutable {
|
|
|
100
110
|
export type DeepCopy<T> = T extends Record<infer R>
|
|
101
111
|
? // convert Record to DeepCopy plain JS object
|
|
102
112
|
{
|
|
103
|
-
[key in keyof R]:
|
|
113
|
+
[key in keyof R]: ContainObject<R[key]> extends true ? unknown : R[key];
|
|
104
114
|
}
|
|
105
115
|
: T extends MapOf<infer R>
|
|
106
116
|
? // convert MapOf to DeepCopy plain JS object
|
|
107
117
|
{
|
|
108
|
-
[key in keyof R]:
|
|
118
|
+
[key in keyof R]: ContainObject<R[key]> extends true ? unknown : R[key];
|
|
109
119
|
}
|
|
110
120
|
: T extends Collection.Keyed<infer KeyedKey, infer V>
|
|
111
121
|
? // convert KeyedCollection to DeepCopy plain JS object
|
|
112
122
|
{
|
|
113
123
|
[key in KeyedKey extends string | number | symbol
|
|
114
124
|
? KeyedKey
|
|
115
|
-
: string]:
|
|
125
|
+
: string]: V extends object ? unknown : V;
|
|
116
126
|
}
|
|
117
127
|
: // convert IndexedCollection or Immutable.Set to DeepCopy plain JS array
|
|
118
128
|
T extends Collection<infer _, infer V>
|
|
@@ -123,7 +133,9 @@ declare namespace Immutable {
|
|
|
123
133
|
? Array<DeepCopy<V>>
|
|
124
134
|
: T extends object // plain JS object are converted deeply
|
|
125
135
|
? {
|
|
126
|
-
[ObjectKey in keyof T]:
|
|
136
|
+
[ObjectKey in keyof T]: ContainObject<T[ObjectKey]> extends true
|
|
137
|
+
? unknown
|
|
138
|
+
: T[ObjectKey];
|
|
127
139
|
}
|
|
128
140
|
: // other case : should be kept as is
|
|
129
141
|
T;
|
package/dist/immutable.js
CHANGED
package/dist/immutable.min.js
CHANGED
|
@@ -52,4 +52,4 @@ takeUntil:function(t,r){return this.takeWhile(Ze(t),r)},update:function(t){retur
|
|
|
52
52
|
r.prototype=Object.create(t&&t.prototype)).constructor=r).of=function(){return this(arguments)},r.fromKeys=function(t){return this(O(t).keySeq())},r.prototype.toString=function(){return this.__toString("OrderedSet {","}")},r}(ke);nn.isOrderedSet=Me;var on,un=nn.prototype;function sn(t,r){var e=Object.create(un);return e.size=t?t.size:0,e._map=t,e.__ownerID=r,e}function an(){return on=on||sn(ge())}un[k]=!0,un.zip=Ye.zip,un.zipWith=Ye.zipWith,un.zipAll=Ye.zipAll,un.__empty=an,un.__make=sn;Ye=function(u,s){var a;!function(t){if(x(t))throw Error("Can not call `Record` with an immutable Record as default values. Use a plain javascript object instead.");if(A(t))throw Error("Can not call `Record` with an immutable Collection as default values. Use a plain javascript object instead.");if(null===t||"object"!=typeof t)throw Error("Can not call `Record` with a non-object as default values. Use a plain javascript object instead.")}(u);var c=function(t){var n=this;if(t instanceof c)return t;if(!(this instanceof c))return new c(t);if(!a){a=!0;var r=Object.keys(u),e=f._indices={};f._name=s,f._keys=r,f._defaultValues=u;for(var i=0;i<r.length;i++){var o=r[i];e[o]=i,f[o]?"object"==typeof console&&console.warn&&console.warn("Cannot define "+hn(this)+' with property "'+o+'" since that property name is part of the Record API.'):function(t,r){try{Object.defineProperty(t,r,{get:function(){return this.get(r)},set:function(t){$t(this.__ownerID,"Cannot set on an immutable record."),this.set(r,t)}})}catch(t){}}(f,o)}}return this.__ownerID=void 0,this._values=ee().withMutations(function(e){e.setSize(n._keys.length),O(t).forEach(function(t,r){e.set(n._indices[r],t===n._defaultValues[r]?void 0:t)})}),this},f=c.prototype=Object.create(cn);return f.constructor=c,s&&(c.displayName=s),c};Ye.prototype.toString=function(){for(var t,r=hn(this)+" { ",e=this._keys,n=0,i=e.length;n!==i;n++)r+=(n?", ":"")+(t=e[n])+": "+or(this.get(t));return r+" }"},Ye.prototype.equals=function(t){return this===t||x(t)&&_n(this).equals(_n(t))},
|
|
53
53
|
Ye.prototype.hashCode=function(){return _n(this).hashCode()},Ye.prototype.has=function(t){return this._indices.hasOwnProperty(t)},Ye.prototype.get=function(t,r){if(!this.has(t))return r;r=this._values.get(this._indices[t]);return void 0===r?this._defaultValues[t]:r},Ye.prototype.set=function(t,r){if(this.has(t)){r=this._values.set(this._indices[t],r===this._defaultValues[t]?void 0:r);if(r!==this._values&&!this.__ownerID)return fn(this,r)}return this},Ye.prototype.remove=function(t){return this.set(t)},Ye.prototype.clear=function(){var t=this._values.clear().setSize(this._keys.length);return this.__ownerID?this:fn(this,t)},Ye.prototype.wasAltered=function(){return this._values.wasAltered()},Ye.prototype.toSeq=function(){return _n(this)},Ye.prototype.toJS=function(){return Ae(this)},Ye.prototype.entries=function(){return this.__iterator(K)},Ye.prototype.__iterator=function(t,r){return _n(this).__iterator(t,r)},Ye.prototype.__iterate=function(t,r){return _n(this).__iterate(t,r)},Ye.prototype.__ensureOwner=function(t){if(t===this.__ownerID)return this;var r=this._values.__ensureOwner(t);return t?fn(this,r,t):(this.__ownerID=t,this._values=r,this)},Ye.isRecord=x,Ye.getDescriptiveName=hn;var cn=Ye.prototype;function fn(t,r,e){t=Object.create(Object.getPrototypeOf(t));return t._values=r,t.__ownerID=e,t}function hn(t){return t.constructor.displayName||t.constructor.name||"Record"}function _n(r){return ot(r._keys.map(function(t){return[t,r.get(t)]}))}cn[D]=!0,cn[r]=cn.remove,cn.deleteIn=cn.removeIn=vr,cn.getIn=We,cn.hasIn=Je.hasIn,cn.merge=mr,cn.mergeWith=wr,cn.mergeIn=Er,cn.mergeDeep=Ir,cn.mergeDeepWith=Or,cn.mergeDeepIn=jr,cn.setIn=pr,cn.update=dr,cn.updateIn=gr,cn.withMutations=qr,cn.asMutable=Mr,cn.asImmutable=Dr,cn[B]=cn.entries,cn.toJSON=cn.toObject=Je.toObject,cn.inspect=cn.toSource=function(){return""+this};var pn,B=function(t){function n(t,r){if(!(this instanceof n))return new n(t,r);if(this._value=t,this.size=void 0===r?1/0:Math.max(0,r),0===this.size){if(pn)return pn;pn=this}}return t&&(n.__proto__=t),((
|
|
54
54
|
n.prototype=Object.create(t&&t.prototype)).constructor=n).prototype.toString=function(){return 0===this.size?"Repeat []":"Repeat [ "+this._value+" "+this.size+" times ]"},n.prototype.get=function(t,r){return this.has(t)?this._value:r},n.prototype.includes=function(t){return _t(this._value,t)},n.prototype.slice=function(t,r){var e=this.size;return p(t,r,e)?this:new n(this._value,w(r,e)-y(t,e))},n.prototype.reverse=function(){return this},n.prototype.indexOf=function(t){return _t(this._value,t)?0:-1},n.prototype.lastIndexOf=function(t){return _t(this._value,t)?this.size:-1},n.prototype.__iterate=function(t,r){for(var e=this.size,n=0;n!==e&&!1!==t(this._value,r?e-++n:n++,this););return n},n.prototype.__iterator=function(t,r){var e=this,n=this.size,i=0;return new P(function(){return i===n?N():W(t,r?n-++i:i++,e._value)})},n.prototype.equals=function(t){return t instanceof n?_t(this._value,t._value):De(t)},n}(Z);function ln(t,r){return S(r)?r.toList():a(r)?r.toMap():r.toSet()}Je=I;t.Collection=I,t.Iterable=Je,t.List=ee,t.Map=Ar,t.OrderedMap=ye,t.OrderedSet=nn,t.PairSorting={LeftThenRight:-1,RightThenLeft:1},t.Range=Be,t.Record=Ye,t.Repeat=B,t.Seq=F,t.Set=ke,t.Stack=Se,t.fromJS=function(t,r){return function e(n,i,o,t,u,r){if("string"!=typeof o&&!A(o)&&(X(o)||H(o)||nr(o))){if(~n.indexOf(o))throw new TypeError("Cannot convert circular structure to Immutable");n.push(o),u&&""!==t&&u.push(t);var t=i.call(r,t,F(o).map(function(t,r){return e(n,i,t,r,u,o)}),u&&u.slice());return n.pop(),u&&u.pop(),t}return o}([],r||ln,t,"",r&&2<r.length?[]:void 0,{"":t})},t.get=sr,t.getIn=Pe,t.has=ur,t.hasIn=Ne,t.hash=yt,t.is=_t,t.isAssociative=b,t.isCollection=f,t.isImmutable=A,t.isIndexed=S,t.isKeyed=a,t.isList=re,t.isMap=ct,t.isOrdered=R,t.isOrderedMap=ft,t.isOrderedSet=Me,t.isPlainObject=nr,t.isRecord=x,t.isSeq=M,t.isSet=qe,t.isStack=ze,t.isValueObject=ht,t.merge=function(t){for(var r=[],e=arguments.length-1;0<e--;)r[e]=arguments[e+1];return br(t,r)},t.mergeDeep=function(t){for(var r=[],e=arguments.length-1;0<e--;)r[e]=arguments[e+1]
|
|
55
|
-
;return Sr(t,r)},t.mergeDeepWith=function(t,r){for(var e=[],n=arguments.length-2;0<n--;)e[n]=arguments[n+2];return Sr(r,e,t)},t.mergeWith=function(t,r){for(var e=[],n=arguments.length-2;0<n--;)e[n]=arguments[n+2];return br(r,e,t)},t.remove=cr,t.removeIn=lr,t.set=fr,t.setIn=_r,t.update=yr,t.updateIn=hr,t.version="5.0.0-beta.
|
|
55
|
+
;return Sr(t,r)},t.mergeDeepWith=function(t,r){for(var e=[],n=arguments.length-2;0<n--;)e[n]=arguments[n+2];return Sr(r,e,t)},t.mergeWith=function(t,r){for(var e=[],n=arguments.length-2;0<n--;)e[n]=arguments[n+2];return br(r,e,t)},t.remove=cr,t.removeIn=lr,t.set=fr,t.setIn=_r,t.update=yr,t.updateIn=hr,t.version="5.0.0-beta.2",Object.defineProperty(t,"__esModule",{value:!0})});
|