as-model 0.1.9 → 0.1.11
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/index.js +1 -3
- package/esm/index.js +34 -19
- package/esm/key/index.js +43 -38
- package/esm/model/index.js +30 -17
- package/esm/store/enhance/selector.js +43 -50
- package/esm/store/enhance/signal.js +21 -29
- package/esm/store/index.js +56 -40
- package/esm/store/instance.js +41 -55
- package/esm/tools/proxy.js +34 -14
- package/esm/tools/shallowEqual.js +11 -12
- package/esm/updater/index.js +61 -47
- package/esm/updater/notifier.js +59 -71
- package/esm/updater/tunnel.js +61 -63
- package/esm/validation/index.js +7 -7
- package/index.d.ts +1 -3
- package/package.json +1 -1
- package/esm/model/type.js +0 -0
- package/esm/tools.js +0 -78
package/esm/updater/notifier.js
CHANGED
|
@@ -1,69 +1,72 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defProps = Object.defineProperties;
|
|
3
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
+
var __spreadValues = (a, b) => {
|
|
9
|
+
for (var prop in b || (b = {}))
|
|
10
|
+
if (__hasOwnProp.call(b, prop))
|
|
11
|
+
__defNormalProp(a, prop, b[prop]);
|
|
12
|
+
if (__getOwnPropSymbols)
|
|
13
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
+
if (__propIsEnum.call(b, prop))
|
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
|
16
|
+
}
|
|
17
|
+
return a;
|
|
18
|
+
};
|
|
19
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
4
20
|
function defaultNotifyImplement(dispatches, action) {
|
|
5
|
-
dispatches.forEach(
|
|
21
|
+
dispatches.forEach((callback) => {
|
|
6
22
|
callback(action);
|
|
7
23
|
});
|
|
8
24
|
}
|
|
9
25
|
function generateNotifier(updater, middleWare) {
|
|
10
26
|
function pendAction(value) {
|
|
11
|
-
updater.mutate(
|
|
12
|
-
|
|
27
|
+
updater.mutate((u) => {
|
|
28
|
+
const { dispatching } = u;
|
|
13
29
|
if (!dispatching) {
|
|
14
|
-
|
|
15
|
-
value
|
|
16
|
-
};
|
|
30
|
+
const wrap = { value };
|
|
17
31
|
wrap.tail = wrap;
|
|
18
|
-
return
|
|
19
|
-
dispatching: wrap
|
|
20
|
-
});
|
|
32
|
+
return __spreadProps(__spreadValues({}, u), { dispatching: wrap });
|
|
21
33
|
}
|
|
22
|
-
|
|
34
|
+
const { tail } = dispatching;
|
|
23
35
|
if (!tail) {
|
|
24
36
|
return u;
|
|
25
37
|
}
|
|
26
|
-
|
|
27
|
-
prev: tail,
|
|
28
|
-
value
|
|
29
|
-
};
|
|
38
|
+
const current = { prev: tail, value };
|
|
30
39
|
tail.next = current;
|
|
31
40
|
dispatching.tail = current;
|
|
32
|
-
return
|
|
33
|
-
dispatching
|
|
34
|
-
});
|
|
41
|
+
return __spreadProps(__spreadValues({}, u), { dispatching });
|
|
35
42
|
});
|
|
36
43
|
}
|
|
37
44
|
function unshiftAction() {
|
|
38
|
-
return updater.mutate(
|
|
39
|
-
|
|
45
|
+
return updater.mutate((u) => {
|
|
46
|
+
const { dispatching } = updater;
|
|
40
47
|
if (!dispatching) {
|
|
41
48
|
return u;
|
|
42
49
|
}
|
|
43
|
-
|
|
50
|
+
const { next, tail } = dispatching;
|
|
44
51
|
if (tail === dispatching || !next) {
|
|
45
52
|
dispatching.tail = void 0;
|
|
46
|
-
return
|
|
47
|
-
dispatching: void 0
|
|
48
|
-
});
|
|
53
|
+
return __spreadProps(__spreadValues({}, u), { dispatching: void 0 });
|
|
49
54
|
}
|
|
50
55
|
next.prev = void 0;
|
|
51
|
-
|
|
56
|
+
const newFirst = next;
|
|
52
57
|
newFirst.tail = tail;
|
|
53
|
-
return
|
|
54
|
-
dispatching: newFirst
|
|
55
|
-
});
|
|
58
|
+
return __spreadProps(__spreadValues({}, u), { dispatching: newFirst });
|
|
56
59
|
}).dispatching;
|
|
57
60
|
}
|
|
58
61
|
function consumeTemporaries() {
|
|
59
|
-
|
|
60
|
-
updater.mutate(
|
|
61
|
-
|
|
62
|
-
dispatches:
|
|
62
|
+
const { temporaryDispatches } = updater;
|
|
63
|
+
updater.mutate(
|
|
64
|
+
(u) => u.temporaryDispatches.length ? __spreadProps(__spreadValues({}, u), {
|
|
65
|
+
dispatches: [...u.dispatches, ...u.temporaryDispatches],
|
|
63
66
|
temporaryDispatches: []
|
|
64
|
-
}) : u
|
|
65
|
-
|
|
66
|
-
|
|
67
|
+
}) : u
|
|
68
|
+
);
|
|
69
|
+
const initializedAction = {
|
|
67
70
|
state: updater.state,
|
|
68
71
|
prevState: updater.state,
|
|
69
72
|
instance: updater.instance,
|
|
@@ -71,27 +74,23 @@ function generateNotifier(updater, middleWare) {
|
|
|
71
74
|
type: null,
|
|
72
75
|
method: null
|
|
73
76
|
};
|
|
74
|
-
temporaryDispatches.forEach(
|
|
77
|
+
temporaryDispatches.forEach((call) => {
|
|
75
78
|
call(initializedAction);
|
|
76
79
|
});
|
|
77
80
|
}
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
instance: nextInstance
|
|
86
|
-
});
|
|
81
|
+
const { config, model } = updater;
|
|
82
|
+
const dispatch = function dispatch2(action) {
|
|
83
|
+
const { dispatches, controlled } = updater;
|
|
84
|
+
const dispatchCallbacks = [...dispatches];
|
|
85
|
+
const { state } = action;
|
|
86
|
+
const nextInstance = model(state);
|
|
87
|
+
const nextAction = __spreadProps(__spreadValues({}, action), { instance: nextInstance });
|
|
87
88
|
if (!controlled) {
|
|
88
|
-
updater.mutate(
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
});
|
|
94
|
-
});
|
|
89
|
+
updater.mutate((u) => __spreadProps(__spreadValues({}, u), {
|
|
90
|
+
state,
|
|
91
|
+
instance: nextInstance,
|
|
92
|
+
version: u.version + 1
|
|
93
|
+
}));
|
|
95
94
|
}
|
|
96
95
|
try {
|
|
97
96
|
if (typeof config.batchNotify === "function") {
|
|
@@ -100,11 +99,7 @@ function generateNotifier(updater, middleWare) {
|
|
|
100
99
|
defaultNotifyImplement(dispatchCallbacks, nextAction);
|
|
101
100
|
}
|
|
102
101
|
} catch (e) {
|
|
103
|
-
updater.mutate(
|
|
104
|
-
return _object_spread_props(_object_spread({}, u), {
|
|
105
|
-
dispatching: void 0
|
|
106
|
-
});
|
|
107
|
-
});
|
|
102
|
+
updater.mutate((u) => __spreadProps(__spreadValues({}, u), { dispatching: void 0 }));
|
|
108
103
|
throw e;
|
|
109
104
|
}
|
|
110
105
|
};
|
|
@@ -112,30 +107,23 @@ function generateNotifier(updater, middleWare) {
|
|
|
112
107
|
if (action == null || updater.isDestroyed) {
|
|
113
108
|
return;
|
|
114
109
|
}
|
|
115
|
-
|
|
110
|
+
const { dispatching } = updater;
|
|
116
111
|
pendAction(action);
|
|
117
112
|
if (dispatching) {
|
|
118
113
|
return;
|
|
119
114
|
}
|
|
120
115
|
while (updater.dispatching) {
|
|
121
|
-
|
|
116
|
+
const wrap = updater.dispatching;
|
|
122
117
|
if (wrap) {
|
|
123
118
|
middleWare({
|
|
124
|
-
getState
|
|
125
|
-
return {
|
|
126
|
-
state: updater.state,
|
|
127
|
-
instance: updater.instance
|
|
128
|
-
};
|
|
119
|
+
getState() {
|
|
120
|
+
return { state: updater.state, instance: updater.instance };
|
|
129
121
|
},
|
|
130
122
|
dispatch: notify
|
|
131
123
|
})(dispatch)(wrap.value);
|
|
132
124
|
unshiftAction();
|
|
133
125
|
} else {
|
|
134
|
-
updater.mutate(
|
|
135
|
-
return _object_spread_props(_object_spread({}, u), {
|
|
136
|
-
dispatching: void 0
|
|
137
|
-
});
|
|
138
|
-
});
|
|
126
|
+
updater.mutate((u) => __spreadProps(__spreadValues({}, u), { dispatching: void 0 }));
|
|
139
127
|
}
|
|
140
128
|
}
|
|
141
129
|
consumeTemporaries();
|
package/esm/updater/tunnel.js
CHANGED
|
@@ -1,29 +1,43 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defProps = Object.defineProperties;
|
|
3
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
+
var __spreadValues = (a, b) => {
|
|
9
|
+
for (var prop in b || (b = {}))
|
|
10
|
+
if (__hasOwnProp.call(b, prop))
|
|
11
|
+
__defNormalProp(a, prop, b[prop]);
|
|
12
|
+
if (__getOwnPropSymbols)
|
|
13
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
+
if (__propIsEnum.call(b, prop))
|
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
|
16
|
+
}
|
|
17
|
+
return a;
|
|
18
|
+
};
|
|
19
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
4
20
|
import { noop } from "../tools";
|
|
5
21
|
function createUnInitializedUpdater() {
|
|
6
22
|
return {
|
|
7
|
-
notify:
|
|
23
|
+
notify: (a) => {
|
|
8
24
|
},
|
|
9
|
-
createTunnel:
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
};
|
|
14
|
-
}
|
|
25
|
+
createTunnel: (dispatcher) => ({
|
|
26
|
+
connect: noop,
|
|
27
|
+
disconnect: noop
|
|
28
|
+
})
|
|
15
29
|
};
|
|
16
30
|
}
|
|
17
31
|
function destroy(updater) {
|
|
18
32
|
function destroyDispatching() {
|
|
19
|
-
updater.mutate(
|
|
20
|
-
|
|
33
|
+
updater.mutate((u) => {
|
|
34
|
+
const { dispatching } = u;
|
|
21
35
|
if (!dispatching) {
|
|
22
36
|
return u;
|
|
23
37
|
}
|
|
24
|
-
|
|
38
|
+
let wrapper = dispatching;
|
|
25
39
|
while (wrapper) {
|
|
26
|
-
|
|
40
|
+
const { next } = wrapper;
|
|
27
41
|
wrapper.next = void 0;
|
|
28
42
|
wrapper.prev = void 0;
|
|
29
43
|
if (next) {
|
|
@@ -32,58 +46,46 @@ function destroy(updater) {
|
|
|
32
46
|
wrapper = next;
|
|
33
47
|
}
|
|
34
48
|
dispatching.tail = void 0;
|
|
35
|
-
return
|
|
36
|
-
dispatching: void 0,
|
|
37
|
-
initialized: false
|
|
38
|
-
});
|
|
49
|
+
return __spreadProps(__spreadValues({}, u), { dispatching: void 0, initialized: false });
|
|
39
50
|
});
|
|
40
51
|
}
|
|
41
|
-
updater.mutate(
|
|
42
|
-
|
|
43
|
-
effect(
|
|
52
|
+
updater.mutate((u, effect) => {
|
|
53
|
+
const destroyed = createUnInitializedUpdater();
|
|
54
|
+
effect(() => {
|
|
44
55
|
destroyDispatching();
|
|
45
56
|
});
|
|
46
|
-
return
|
|
47
|
-
sidePayload: void 0,
|
|
48
|
-
isDestroyed: true
|
|
49
|
-
});
|
|
57
|
+
return __spreadProps(__spreadValues(__spreadValues({}, u), destroyed), { sidePayload: void 0, isDestroyed: true });
|
|
50
58
|
});
|
|
51
59
|
}
|
|
52
60
|
function generateTunnelCreator(updater) {
|
|
53
61
|
function subscribe(dispatchFn) {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
62
|
+
const {
|
|
63
|
+
dispatches,
|
|
64
|
+
temporaryDispatches,
|
|
65
|
+
controlled: isControlled
|
|
66
|
+
} = updater;
|
|
67
|
+
const copied = [...dispatches, ...temporaryDispatches];
|
|
68
|
+
const exist = copied.indexOf(dispatchFn) >= 0;
|
|
57
69
|
if (exist) {
|
|
58
|
-
return updater.mutate(
|
|
59
|
-
return _object_spread_props(_object_spread({}, u), {
|
|
60
|
-
isDestroyed: false
|
|
61
|
-
});
|
|
62
|
-
});
|
|
70
|
+
return updater.mutate((u) => __spreadProps(__spreadValues({}, u), { isDestroyed: false }));
|
|
63
71
|
}
|
|
64
72
|
if (isControlled) {
|
|
65
|
-
return updater.mutate(
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
],
|
|
70
|
-
isDestroyed: false
|
|
71
|
-
});
|
|
72
|
-
});
|
|
73
|
+
return updater.mutate((u) => __spreadProps(__spreadValues({}, u), {
|
|
74
|
+
dispatches: [dispatchFn],
|
|
75
|
+
isDestroyed: false
|
|
76
|
+
}));
|
|
73
77
|
}
|
|
74
|
-
return updater.mutate(
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
dispatchFn
|
|
78
|
-
]);
|
|
78
|
+
return updater.mutate((u, effect) => {
|
|
79
|
+
const { temporaryDispatches: tds, dispatches: ds } = u;
|
|
80
|
+
const nextTds = [...tds, dispatchFn];
|
|
79
81
|
if (u.dispatching) {
|
|
80
|
-
return
|
|
82
|
+
return __spreadProps(__spreadValues({}, u), {
|
|
81
83
|
temporaryDispatches: nextTds,
|
|
82
84
|
isDestroyed: false
|
|
83
85
|
});
|
|
84
86
|
}
|
|
85
|
-
effect(
|
|
86
|
-
|
|
87
|
+
effect((up) => {
|
|
88
|
+
const initializedAction = {
|
|
87
89
|
state: up.state,
|
|
88
90
|
prevState: up.state,
|
|
89
91
|
instance: up.instance,
|
|
@@ -91,41 +93,37 @@ function generateTunnelCreator(updater) {
|
|
|
91
93
|
type: null,
|
|
92
94
|
method: null
|
|
93
95
|
};
|
|
94
|
-
nextTds.forEach(
|
|
96
|
+
nextTds.forEach((td) => {
|
|
95
97
|
td(initializedAction);
|
|
96
98
|
});
|
|
97
99
|
});
|
|
98
|
-
return
|
|
100
|
+
return __spreadProps(__spreadValues({}, u), {
|
|
99
101
|
temporaryDispatches: [],
|
|
100
|
-
dispatches:
|
|
102
|
+
dispatches: [...ds, ...nextTds],
|
|
101
103
|
isDestroyed: false
|
|
102
104
|
});
|
|
103
105
|
});
|
|
104
106
|
}
|
|
105
107
|
return function tunnel(dispatcher) {
|
|
106
108
|
function disconnect() {
|
|
107
|
-
updater.mutate(
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
});
|
|
112
|
-
var nextTds = tds.filter(function(d) {
|
|
113
|
-
return d !== dispatcher;
|
|
114
|
-
});
|
|
109
|
+
updater.mutate((u) => {
|
|
110
|
+
const { dispatches: ds, temporaryDispatches: tds } = u;
|
|
111
|
+
const nextDs = ds.filter((d) => d !== dispatcher);
|
|
112
|
+
const nextTds = tds.filter((d) => d !== dispatcher);
|
|
115
113
|
if (ds.length === nextDs.length && tds.length === nextTds.length) {
|
|
116
114
|
return u;
|
|
117
115
|
}
|
|
118
|
-
return
|
|
116
|
+
return __spreadProps(__spreadValues({}, u), {
|
|
119
117
|
dispatches: nextDs,
|
|
120
118
|
temporaryDispatches: nextTds
|
|
121
119
|
});
|
|
122
120
|
});
|
|
123
121
|
}
|
|
124
122
|
return {
|
|
125
|
-
connect
|
|
123
|
+
connect() {
|
|
126
124
|
subscribe(dispatcher);
|
|
127
125
|
},
|
|
128
|
-
disconnect
|
|
126
|
+
disconnect() {
|
|
129
127
|
disconnect();
|
|
130
128
|
}
|
|
131
129
|
};
|
package/esm/validation/index.js
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import { _ as _define_property } from "@swc/helpers/_/_define_property";
|
|
2
|
-
import { _ as _type_of } from "@swc/helpers/_/_type_of";
|
|
3
1
|
import { modelKeyIdentifier, modelStoreIdentifier, modelUsageIdentifier } from "../identifiers";
|
|
4
|
-
|
|
2
|
+
const noStateAModelKey = "no-state-a-model-key";
|
|
5
3
|
function createNoStateModel() {
|
|
6
4
|
return function noStateModel(state) {
|
|
7
|
-
return
|
|
5
|
+
return {
|
|
6
|
+
[noStateAModelKey]: true
|
|
7
|
+
};
|
|
8
8
|
};
|
|
9
9
|
}
|
|
10
10
|
function isInstanceFromNoStateModel(instance) {
|
|
11
11
|
if (instance == null) {
|
|
12
12
|
return false;
|
|
13
13
|
}
|
|
14
|
-
if (
|
|
14
|
+
if (typeof instance !== "object") {
|
|
15
15
|
return false;
|
|
16
16
|
}
|
|
17
|
-
|
|
17
|
+
const ins = instance;
|
|
18
18
|
return !!ins[noStateAModelKey];
|
|
19
19
|
}
|
|
20
20
|
function isModelKey(data) {
|
|
@@ -35,7 +35,7 @@ function isModelStore(data) {
|
|
|
35
35
|
}
|
|
36
36
|
return data.modelStoreIdentifier === modelStoreIdentifier && data.modelStoreIdentifier();
|
|
37
37
|
}
|
|
38
|
-
|
|
38
|
+
const validations = {
|
|
39
39
|
isInstanceFromNoStateModel,
|
|
40
40
|
isModelKey,
|
|
41
41
|
isModelStore,
|
package/index.d.ts
CHANGED
|
@@ -199,9 +199,7 @@ declare interface SignalStore<
|
|
|
199
199
|
startStatistics: () => void;
|
|
200
200
|
stopStatistics: () => void;
|
|
201
201
|
subscribe: (dispatcher: Dispatch) => () => void;
|
|
202
|
-
|
|
203
|
-
callback?: (payload: P | undefined) => P | undefined
|
|
204
|
-
) => P | undefined;
|
|
202
|
+
store: Store<S, T, R>;
|
|
205
203
|
};
|
|
206
204
|
}
|
|
207
205
|
|
package/package.json
CHANGED
package/esm/model/type.js
DELETED
|
File without changes
|
package/esm/tools.js
DELETED
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
import { _ as _object_spread } from "@swc/helpers/_/_object_spread";
|
|
2
|
-
import { _ as _type_of } from "@swc/helpers/_/_type_of";
|
|
3
|
-
function getDescriptors(target, receiver, ownOrPrototype, handler) {
|
|
4
|
-
var it = Object.keys(ownOrPrototype);
|
|
5
|
-
var result = {};
|
|
6
|
-
it.forEach(function(key) {
|
|
7
|
-
result[key] = {
|
|
8
|
-
get: function() {
|
|
9
|
-
if (!handler.get) {
|
|
10
|
-
return target[key];
|
|
11
|
-
}
|
|
12
|
-
return handler.get(target, key, receiver);
|
|
13
|
-
},
|
|
14
|
-
set: function(v) {
|
|
15
|
-
if (!handler.set) {
|
|
16
|
-
target[key] = v;
|
|
17
|
-
return;
|
|
18
|
-
}
|
|
19
|
-
var valid = handler.set(target, key, v, receiver);
|
|
20
|
-
if (!valid) {
|
|
21
|
-
throw new Error("".concat(key, " in proxy target is not mutable"));
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
};
|
|
25
|
-
});
|
|
26
|
-
return result;
|
|
27
|
-
}
|
|
28
|
-
var createSimpleProxy = function(target, handler) {
|
|
29
|
-
var proxy = {};
|
|
30
|
-
var own = getDescriptors(target, proxy, target, handler);
|
|
31
|
-
var prototype = getDescriptors(target, proxy, Object.getPrototypeOf(target), handler);
|
|
32
|
-
Object.defineProperties(proxy, _object_spread({}, prototype, own));
|
|
33
|
-
return proxy;
|
|
34
|
-
};
|
|
35
|
-
var createProxy = function(target, handler) {
|
|
36
|
-
if (typeof Proxy !== "function") {
|
|
37
|
-
return createSimpleProxy(target, handler);
|
|
38
|
-
}
|
|
39
|
-
return new Proxy(target, handler);
|
|
40
|
-
};
|
|
41
|
-
function isObject(data) {
|
|
42
|
-
return data && (typeof data === "undefined" ? "undefined" : _type_of(data)) === "object";
|
|
43
|
-
}
|
|
44
|
-
function shallowEqual(prev, current) {
|
|
45
|
-
if (Object.is(prev, current)) {
|
|
46
|
-
return true;
|
|
47
|
-
}
|
|
48
|
-
if (!isObject(prev) || !isObject(current)) {
|
|
49
|
-
return false;
|
|
50
|
-
}
|
|
51
|
-
var prevKeys = Object.keys(prev);
|
|
52
|
-
var currentKeys = Object.keys(current);
|
|
53
|
-
if (prevKeys.length !== currentKeys.length) {
|
|
54
|
-
return false;
|
|
55
|
-
}
|
|
56
|
-
var pre = prev;
|
|
57
|
-
var curr = current;
|
|
58
|
-
var hasDiffKey = prevKeys.some(function(key) {
|
|
59
|
-
return !Object.prototype.hasOwnProperty.call(curr, key);
|
|
60
|
-
});
|
|
61
|
-
if (hasDiffKey) {
|
|
62
|
-
return false;
|
|
63
|
-
}
|
|
64
|
-
var hasDiffValue = currentKeys.some(function(key) {
|
|
65
|
-
var currentValue = curr[key];
|
|
66
|
-
var prevValue = pre[key];
|
|
67
|
-
return !Object.is(currentValue, prevValue);
|
|
68
|
-
});
|
|
69
|
-
return !hasDiffValue;
|
|
70
|
-
}
|
|
71
|
-
function noop() {
|
|
72
|
-
}
|
|
73
|
-
export {
|
|
74
|
-
createProxy,
|
|
75
|
-
createSimpleProxy,
|
|
76
|
-
noop,
|
|
77
|
-
shallowEqual
|
|
78
|
-
};
|