Skip to content

Commit

Permalink
fix: do not mutate descriptor
Browse files Browse the repository at this point in the history
  • Loading branch information
oljekechoro committed Sep 29, 2023
1 parent 925daf4 commit b78f9e8
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/main/ts/utils/deepmap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ export function deepMap(
return
}

const value = descriptor.get ? descriptor.get() : descriptor.value
// descriptor cannot contain both accessor method and value
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/defineProperty#description
delete descriptor.get
delete descriptor.set
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const { get, set, ...rest } = descriptor
const value = get ? get() : descriptor.value

Object.defineProperty(n, key, {
...descriptor,
...rest,
value: deepMap(value, fn, refs, key),
})
})
Expand Down

0 comments on commit b78f9e8

Please sign in to comment.