@ianwalter/clone

A configurable utility to clone JavaScript data (Objects, Arrays, etc)

Usage no npm install needed!

<script type="module">
  import ianwalterClone from 'https://cdn.skypack.dev/@ianwalter/clone';
</script>

README

@ianwalter/clone

A configurable utility to clone JavaScript data (Objects, Arrays, etc)

npm page CI

About

I created clone because I wanted to use the terrific nanoclone utility but not have the source Object's prototype properties be copied.

The difference, for my purposes, is to be able to clone an Object without cloning it's getters and setters. The state management library Vuex uses Object getters and setters for it's "reactive" functionality and there are times when you might want to extract and mutate data from the store without those mutations affecting the original data in the store.

Installation

yarn add @ianwalter/clone

Usage

import clone from '@ianwalter/clone'

const clonedBook = clone(book)

License

Apache 2.0 with Commons Clause - See LICENSE

 

Created by Ian Walter