Skip to content

Commit 15e1cf9

Browse files
committed
refactor(proxy-state-tree): extract proxy cache check to own method to increase readability
1 parent 0c3722b commit 15e1cf9

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

packages/node_modules/proxy-state-tree/src/Proxyfier.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -145,11 +145,14 @@ export class Proxifier {
145145
getMutationTree() {
146146
return this.tree.master.mutationTree || (this.tree as IMutationTree<any>)
147147
}
148-
private createArrayProxy(value, path) {
149-
if (
148+
private isProxyCached(value, path) {
149+
return (
150150
value[this.CACHED_PROXY] &&
151151
String(value[this.CACHED_PROXY][PATH]) === String(path)
152-
) {
152+
)
153+
}
154+
private createArrayProxy(value, path) {
155+
if (this.isProxyCached(value, path)) {
153156
return value[this.CACHED_PROXY]
154157
}
155158

@@ -253,10 +256,7 @@ export class Proxifier {
253256
}
254257

255258
private createObjectProxy(object, path) {
256-
if (
257-
object[this.CACHED_PROXY] &&
258-
String(object[this.CACHED_PROXY][PATH]) === String(path)
259-
) {
259+
if (this.isProxyCached(object, path)) {
260260
return object[this.CACHED_PROXY]
261261
}
262262

0 commit comments

Comments
 (0)