mobx 6.12.4 → 6.13.0
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/CHANGELOG.md +17 -5
- package/dist/mobx.cjs.development.js +241 -170
- package/dist/mobx.cjs.development.js.map +1 -1
- package/dist/mobx.cjs.production.min.js +1 -1
- package/dist/mobx.cjs.production.min.js.map +1 -1
- package/dist/mobx.esm.development.js +241 -170
- package/dist/mobx.esm.development.js.map +1 -1
- package/dist/mobx.esm.js +241 -170
- package/dist/mobx.esm.js.map +1 -1
- package/dist/mobx.esm.production.min.js +1 -1
- package/dist/mobx.esm.production.min.js.map +1 -1
- package/dist/mobx.umd.development.js +241 -170
- package/dist/mobx.umd.development.js.map +1 -1
- package/dist/mobx.umd.production.min.js +1 -1
- package/dist/mobx.umd.production.min.js.map +1 -1
- package/dist/types/observableset.d.ts +7 -0
- package/dist/utils/utils.d.ts +3 -2
- package/package.json +1 -1
- package/src/types/observablemap.ts +2 -1
- package/src/types/observableset.ts +48 -0
- package/src/utils/utils.ts +9 -2
|
@@ -42,6 +42,13 @@ export declare class ObservableSet<T = any> implements Set<T>, IInterceptable<IS
|
|
|
42
42
|
entries(): IterableIterator<[T, T]>;
|
|
43
43
|
keys(): IterableIterator<T>;
|
|
44
44
|
values(): IterableIterator<T>;
|
|
45
|
+
intersection<U>(otherSet: ReadonlySetLike<U> | Set<U>): Set<T & U>;
|
|
46
|
+
union<U>(otherSet: ReadonlySetLike<U> | Set<U>): Set<T | U>;
|
|
47
|
+
difference<U>(otherSet: ReadonlySetLike<U>): Set<T>;
|
|
48
|
+
symmetricDifference<U>(otherSet: ReadonlySetLike<U> | Set<U>): Set<T | U>;
|
|
49
|
+
isSubsetOf(otherSet: ReadonlySetLike<unknown>): boolean;
|
|
50
|
+
isSupersetOf(otherSet: ReadonlySetLike<unknown>): boolean;
|
|
51
|
+
isDisjointFrom(otherSet: ReadonlySetLike<unknown> | Set<unknown>): boolean;
|
|
45
52
|
replace(other: ObservableSet<T> | IObservableSetInitialValues<T>): ObservableSet<T>;
|
|
46
53
|
observe_(listener: (changes: ISetDidChange<T>) => void, fireImmediately?: boolean): Lambda;
|
|
47
54
|
intercept_(handler: IInterceptor<ISetWillChange<T>>): Lambda;
|
package/dist/utils/utils.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export declare const assign: {
|
|
2
2
|
<T extends {}, U>(target: T, source: U): T & U;
|
|
3
|
-
<
|
|
4
|
-
<
|
|
3
|
+
<T extends {}, U, V>(target: T, source1: U, source2: V): T & U & V;
|
|
4
|
+
<T extends {}, U, V, W>(target: T, source1: U, source2: V, source3: W): T & U & V & W;
|
|
5
5
|
(target: object, ...sources: any[]): any;
|
|
6
6
|
};
|
|
7
7
|
export declare const getDescriptor: (o: any, p: PropertyKey) => PropertyDescriptor | undefined;
|
|
@@ -31,6 +31,7 @@ export declare function addHiddenProp(object: any, propName: PropertyKey, value:
|
|
|
31
31
|
export declare function addHiddenFinalProp(object: any, propName: PropertyKey, value: any): void;
|
|
32
32
|
export declare function createInstanceofPredicate<T>(name: string, theClass: new (...args: any[]) => T): (x: any) => x is T;
|
|
33
33
|
export declare function isES6Map(thing: any): thing is Map<any, any>;
|
|
34
|
+
export declare function isPlainES6Map(thing: Map<any, any>): boolean;
|
|
34
35
|
export declare function isES6Set(thing: any): thing is Set<any>;
|
|
35
36
|
/**
|
|
36
37
|
* Returns the following: own enumerable keys and symbols.
|
package/package.json
CHANGED
|
@@ -16,6 +16,7 @@ import {
|
|
|
16
16
|
hasListeners,
|
|
17
17
|
interceptChange,
|
|
18
18
|
isES6Map,
|
|
19
|
+
isPlainES6Map,
|
|
19
20
|
isPlainObject,
|
|
20
21
|
isSpyEnabled,
|
|
21
22
|
makeIterable,
|
|
@@ -351,7 +352,7 @@ export class ObservableMap<K = any, V = any>
|
|
|
351
352
|
} else if (Array.isArray(other)) {
|
|
352
353
|
other.forEach(([key, value]) => this.set(key, value))
|
|
353
354
|
} else if (isES6Map(other)) {
|
|
354
|
-
if (other
|
|
355
|
+
if (!isPlainES6Map(other)) {
|
|
355
356
|
die(19, other)
|
|
356
357
|
}
|
|
357
358
|
other.forEach((value, key) => this.set(key, value))
|
|
@@ -243,6 +243,54 @@ export class ObservableSet<T = any> implements Set<T>, IInterceptable<ISetWillCh
|
|
|
243
243
|
} as any)
|
|
244
244
|
}
|
|
245
245
|
|
|
246
|
+
intersection<U>(otherSet: ReadonlySetLike<U> | Set<U>): Set<T & U> {
|
|
247
|
+
if (isES6Set(otherSet)) {
|
|
248
|
+
return otherSet.intersection(this)
|
|
249
|
+
} else {
|
|
250
|
+
const dehancedSet = new Set(this)
|
|
251
|
+
return dehancedSet.intersection(otherSet)
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
union<U>(otherSet: ReadonlySetLike<U> | Set<U>): Set<T | U> {
|
|
256
|
+
if (isES6Set(otherSet)) {
|
|
257
|
+
return otherSet.union(this)
|
|
258
|
+
} else {
|
|
259
|
+
const dehancedSet = new Set(this)
|
|
260
|
+
return dehancedSet.union(otherSet)
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
difference<U>(otherSet: ReadonlySetLike<U>): Set<T> {
|
|
265
|
+
return new Set(this).difference(otherSet)
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
symmetricDifference<U>(otherSet: ReadonlySetLike<U> | Set<U>): Set<T | U> {
|
|
269
|
+
if (isES6Set(otherSet)) {
|
|
270
|
+
return otherSet.symmetricDifference(this)
|
|
271
|
+
} else {
|
|
272
|
+
const dehancedSet = new Set(this)
|
|
273
|
+
return dehancedSet.symmetricDifference(otherSet)
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
isSubsetOf(otherSet: ReadonlySetLike<unknown>): boolean {
|
|
278
|
+
return new Set(this).isSubsetOf(otherSet)
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
isSupersetOf(otherSet: ReadonlySetLike<unknown>): boolean {
|
|
282
|
+
return new Set(this).isSupersetOf(otherSet)
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
isDisjointFrom(otherSet: ReadonlySetLike<unknown> | Set<unknown>): boolean {
|
|
286
|
+
if (isES6Set(otherSet)) {
|
|
287
|
+
return otherSet.isDisjointFrom(this)
|
|
288
|
+
} else {
|
|
289
|
+
const dehancedSet = new Set(this)
|
|
290
|
+
return dehancedSet.isDisjointFrom(otherSet)
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
|
|
246
294
|
replace(other: ObservableSet<T> | IObservableSetInitialValues<T>): ObservableSet<T> {
|
|
247
295
|
if (isObservableSet(other)) {
|
|
248
296
|
other = new Set(other)
|
package/src/utils/utils.ts
CHANGED
|
@@ -141,11 +141,18 @@ export function createInstanceofPredicate<T>(
|
|
|
141
141
|
}
|
|
142
142
|
|
|
143
143
|
export function isES6Map(thing: any): thing is Map<any, any> {
|
|
144
|
-
return thing
|
|
144
|
+
return thing != null && Object.prototype.toString.call(thing) === "[object Map]"
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
export function isPlainES6Map(thing: Map<any, any>): boolean {
|
|
148
|
+
const mapProto = Object.getPrototypeOf(thing)
|
|
149
|
+
const objectProto = Object.getPrototypeOf(mapProto)
|
|
150
|
+
const nullProto = Object.getPrototypeOf(objectProto)
|
|
151
|
+
return nullProto === null
|
|
145
152
|
}
|
|
146
153
|
|
|
147
154
|
export function isES6Set(thing: any): thing is Set<any> {
|
|
148
|
-
return thing
|
|
155
|
+
return thing != null && Object.prototype.toString.call(thing) === "[object Set]"
|
|
149
156
|
}
|
|
150
157
|
|
|
151
158
|
const hasGetOwnPropertySymbols = typeof Object.getOwnPropertySymbols !== "undefined"
|