Skip to content

Commit 5e7f38f

Browse files
committed
remove some unnecessary code
1 parent af8d284 commit 5e7f38f

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

src/init-child.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ export default function initChild(this: IPOS) {
44
let resolve: Function
55
const promise = new Promise(res => resolve = res)
66

7-
this.messaging?.listenForType('sync', message => {
7+
// @ts-ignore Object is possibly 'undefined'
8+
this.messaging.listenForType('sync', message => {
89
if (!message.fields || !(message.fields instanceof Map)) return
910
Array.from(message.fields.entries())
1011
.map(([key, value]: [string, any]) => {
@@ -14,10 +15,12 @@ export default function initChild(this: IPOS) {
1415
resolve()
1516
})
1617
// register with parent process
17-
this.messaging?.send('register')
18-
19-
if (this.messaging)
20-
this.mountListeners(this.messaging)
18+
// @ts-ignore Object is possibly 'undefined'
19+
this.messaging.send('register')
20+
this.mountListeners(
21+
// @ts-ignore Object is possibly 'undefined'
22+
this.messaging
23+
)
2124

2225
return promise
2326
}

src/intercept.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@ export default function intercept<V>(value: V, key: string, interceptCallback: (
2020

2121
return new Proxy(value, {
2222
get(target, name: string) {
23-
if (name === '__proxy')
24-
return true
2523
if (name === '__original')
2624
return value
2725
if (Reflect.has(target, name) && (mutatingMethods.get(value.constructor)?.includes(name) || registeredClasses.includes(value.constructor))) {
@@ -38,7 +36,7 @@ export default function intercept<V>(value: V, key: string, interceptCallback: (
3836
}
3937
},
4038
set(target: V, name, value: any): boolean {
41-
if (!target || typeof target !== 'object') return false
39+
// if (!target || typeof target !== 'object') return false
4240
target[name as keyof typeof target] = value
4341
interceptCallback(key, '$$iposDefine', name, value)
4442
return true

src/main.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,7 @@ export default class IPOS {
103103

104104
protected createStealthy(key: string, value: object): void {
105105
this.fieldsRaw.set(key, value)
106-
if (typeof value === 'object')
107-
value = intercept(value, key, this.sendMethodCall.bind(this))
106+
value = intercept(value, key, this.sendMethodCall.bind(this))
108107

109108
this.fields.set(key, value)
110109
this.fieldsReverseMap.set(value, key)

0 commit comments

Comments
 (0)