Releases: mesqueeb/copy-anything
new release format!
Named exports 🕶
v2.0 breaking changes
- only named exports
// before:
import copy from 'copy-anything'
// now:
import { copy } from 'copy-anything'
Reasoning
I was experiencing a lot of problems with just the default export depending on the environment: browser, different versions of nodeJS, rollup/webpack/parcel, ... and also depending on wether the CJS or ESM built file was imported.
Named exports work much more consistently throughout all environments! 🌝
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!! 🌅
[REVERT] support for (non- &) enumerable props & symbols 💥
I reverted latest version to version 1.2.4!! (now pushed as 1.4.0)
Reverted the: Support for (non- &) enumerable props & symbols 🦄
The latest pushed branch is now:
https://github.com/mesqueeb/copy-anything/tree/revert-to-1.2.4
Reason:
Copy'ing non-enumerable props by default caused A LOT of applications of mine to crash because my copies were receiving those hidden props that were previously not there, which caused to break reactivity in many cases.
If you still need to copy (non- &) enumerable props & symbols
then please set version to 1.3.0.
I need to think of the best way to make this optional instead.
Support for (non- &) enumerable props & symbols 🦄
The library now completely supports:
- (non- &) enumerable props
- (non- &) enumerable symbols
enjoy!! 🎉
--
copy-anything was made with ♥ by Luca Ban.
If this library helped you in any way you can support me by buying me a cup of coffee. ☕️
Now works with Arrays! 🌈
Now it not only clones objects, but also arrays as well as objects in arrays!
See the updated readme!
Enjoy!! 🦄