Skip to content

Commit 782cbb1

Browse files
committed
chore: cleanup
1 parent 9a60ae3 commit 782cbb1

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/spyOn.ts

+5-4
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,10 @@ export function internalSpyOn<T, K extends string & keyof T>(
4545
'cannot spyOn on a primitive value'
4646
)
4747

48-
let getMeta = (): [string | symbol | number, 'value' | 'get' | 'set'] => {
48+
let [accessName, accessType] = ((): [
49+
string | symbol | number,
50+
'value' | 'get' | 'set'
51+
] => {
4952
if (!isType('object', methodName)) {
5053
return [methodName, 'value']
5154
}
@@ -59,9 +62,7 @@ export function internalSpyOn<T, K extends string & keyof T>(
5962
return [methodName.setter, 'set']
6063
}
6164
throw new Error('specify getter or setter to spy on')
62-
}
63-
64-
let [accessName, accessType] = getMeta()
65+
})()
6566
let objDescriptor = getDescriptor(obj, accessName)
6667
let proto = Object.getPrototypeOf(obj)
6768
let protoDescriptor = proto && getDescriptor(proto, accessName)

0 commit comments

Comments
 (0)