Skip to content

Commit 6a83627

Browse files
committed
Avoid checks on typeOf
1 parent d1d8e52 commit 6a83627

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

esm/index.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,10 @@ export default namespace => {
7171
const typesOf = new WeakMap;
7272
const direct = Symbol();
7373
const proxy = {};
74+
const set = (p, type) => {
75+
typesOf.set(p, type);
76+
return p;
77+
};
7478
const utils = {
7579
proxy,
7680
release,
@@ -87,7 +91,7 @@ export default namespace => {
8791
return value.call(this, $, ..._);
8892
}
8993
}));
90-
proxy[type] = ($, ..._) => JSProxy($, [ $ ], handler, ..._);
94+
proxy[type] = ($, ..._) => set(JSProxy($, [ $ ], handler, ..._), ARRAY);
9195
break;
9296
}
9397
case FUNCTION: {
@@ -96,7 +100,7 @@ export default namespace => {
96100
return value.call(this, $(), ..._);
97101
}
98102
}));
99-
proxy[type] = ($, ..._) => JSProxy($, bound($), handler, ..._);
103+
proxy[type] = ($, ..._) => set(JSProxy($, bound($), handler, ..._), FUNCTION);
100104
break;
101105
}
102106
case OBJECT: {
@@ -105,18 +109,14 @@ export default namespace => {
105109
return value.call(this, $, ..._);
106110
}
107111
}));
108-
proxy[type] = ($, ..._) => JSProxy($, { $ }, handler, ..._);
112+
proxy[type] = ($, ..._) => set(JSProxy($, { $ }, handler, ..._), OBJECT);
109113
break;
110114
}
111115
default: {
112116
const handler = extendHandler(traps, type, direct, value => ({
113117
value
114118
}));
115-
proxy[type] = ($, ..._) => {
116-
const p = JSProxy($, $, handler, ..._);
117-
typesOf.set(p, type);
118-
return p;
119-
};
119+
proxy[type] = ($, ..._) => set(JSProxy($, $, handler, ..._), type);
120120
break;
121121
}
122122
}

0 commit comments

Comments
 (0)