Skip to content

Commit

Permalink
chore: cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
sheremet-va committed Feb 8, 2024
1 parent 9a60ae3 commit 782cbb1
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/spyOn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,10 @@ export function internalSpyOn<T, K extends string & keyof T>(
'cannot spyOn on a primitive value'
)

let getMeta = (): [string | symbol | number, 'value' | 'get' | 'set'] => {
let [accessName, accessType] = ((): [
string | symbol | number,
'value' | 'get' | 'set'
] => {
if (!isType('object', methodName)) {
return [methodName, 'value']
}
Expand All @@ -59,9 +62,7 @@ export function internalSpyOn<T, K extends string & keyof T>(
return [methodName.setter, 'set']
}
throw new Error('specify getter or setter to spy on')
}

let [accessName, accessType] = getMeta()
})()
let objDescriptor = getDescriptor(obj, accessName)
let proto = Object.getPrototypeOf(obj)
let protoDescriptor = proto && getDescriptor(proto, accessName)
Expand Down

0 comments on commit 782cbb1

Please sign in to comment.