Skip to content

Releases: mesqueeb/copy-anything

new release format!

04 Feb 13:58
Compare
Choose a tag to compare
  • chore: update dependencies 6577901
  • chore: update dependencies bce2d67
  • Merge pull request #6 from mesqueeb/dependabot/npm_and_yarn/lodash-4.17.19 d42dcf0
  • Bump lodash from 4.17.15 to 4.17.19 63c3869

v2.0.1...v2.0.3

Named exports 🕶

14 Mar 23:57
Compare
Choose a tag to compare

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 🌝

17 Aug 03:15
665b683
Compare
Choose a tag to compare

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 💥

16 Aug 02:28
Compare
Choose a tag to compare

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 🦄

13 Jul 06:04
Compare
Choose a tag to compare

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! 🌈

25 Feb 01:35
Compare
Choose a tag to compare

Now it not only clones objects, but also arrays as well as objects in arrays!
See the updated readme!

Enjoy!! 🦄