Support Non-enumerable props via options 🌝
Non-enumerable props are supported again + new LIMIT option!
Non-enumerable
By default, copy-anything only copies enumerable properties. If you also want to copy non-enumerable properties you can do so by passing that as an option.
const original = {name: 'Bulbasaur'}
// bulbasaur's ID is non-enumerable
Object.defineProperty(original, 'id', {
value: '001',
writable: true,
enumerable: false,
configurable: true
})
const copy1 = copy(original)
const copy2 = copy(original, {nonenumerable: true})
(copy1.id === undefined)
(copy2.id === '001')Limit to specific props
You can limit to specific props.
const original = {name: 'Flareon', type: ['fire'], id: '136'}
const copy = copy(original, {props: ['name']})
(copy === {name: 'Flareon'})Please note, if the props you have specified are non-enumerable, you will also need to pass
{nonenumerable: true}.
Enjoy!! 🌅