Skip to content
Myr

test: improve `enumerableOnly` function

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by aleclarson · committed by aleclarson · parent b9170d2 · Browse files · 1 file+9 added−2 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+9 added−2 removed

  • tests:+9 added−2 removed

1 file+9 added−2 removed

modified:__tests__/base.js+9 added-2 removed
3 unmodified lines
4 setUseProxies,5 nothing,6 isDraft7} from "../src/index"8import {shallowCopy} from "../src/common"9import deepFreeze from "deep-freeze"10import cloneDeep from "lodash.clonedeep"11import * as lodash from "lodash"12
1519 unmodified lines
1532 })1533}15341535function enumerableOnly(x) {1535 // this can be done better...1536 return JSON.parse(JSON.stringify(x))1536 const copy = shallowCopy(x)1537 for (const key in copy) {1538 const value = copy[key]1539 if (value && typeof value === "object") {1540 copy[key] = enumerableOnly(value)1541 }1542 }1543 return copy1544}