planttheidea / fast-copy

A blazing fast deep object copier
MIT License
1.13k stars 31 forks source link

nonenumerable props? #26

Closed mesqueeb closed 4 years ago

mesqueeb commented 4 years ago

this didn't work for me:

  let target, res
  target = { value: 42 }
  Object.defineProperty(target, 'id', {
    value: 1,
    writable: true,
    enumerable: false,
    configurable: true
  })
  res = copy(target)
  t.is(res.id, 1)
planttheidea commented 4 years ago

By default, no, only enumerable properties are copied. However, this edge case is one of the reasons copy.strict was added, it should copy the key with the same object descriptor. It is not as fast, but it should produce the result you seek.