Shallow clones an object, including non-enumerable properties, while respecting the original data and accessor descriptors of the properties. This means that for instances getters and setters are copied faithfully. Optionally allows for shimming/overwriting properties by redefining or manipulating existing property descriptors.
npm install shallow-clone-shim --save
const assert =const clone =const original = Objectassertassertconst copy =assertassert
object = clone(object, original[, shim])
Shallow copies all own properties of the
enumerable and non-enumerable properties are copied.
object is also returned.
If the optional
shim argument is supplied, it's expected to be an
object containing functions. The names of the
shim object propeties is
expected to match the names of properties in the
original object. Each
shim function is called with the property descriptor for that particular
original. The function is expected to return a valid
property descriptor as expected by
returned desciptor will replace the original descriptor in the copied