h-clone
a simple and morden deep clone tool.
because h-clone use history api
to make a structure date copy, so it only support modern brower env. ie10+ maybe?
usage
const target = name: 'tom' age: 12 boy: true info: add: 'xxx' ; const copy = ;
support type
- All primitive types, however, not symbols
- Boolean object
- String object
- Date
- RegExp
- Blob
- File
- FileList
- ArrayBuffer
- ArrayBufferView
- ImageBitmap
- ImageData
- Array
- Object
- Map
- Set
tips:
- The lastIndex field of RegExp objects is not preserved.
- Property descriptors, setters, and getters (as well as similar metadata-like features) are not duplicated. For example, if an object is marked read-only using a property descriptor, it will be read-write in the duplicate, since that's the default condition.
- The prototype chain does not get walked and duplicated.
- Error and Function objects cannot be duplicated by the structured clone algorithm; attempting to do so will throw a DATA_CLONE_ERR exception.
- Attempting to clone DOM nodes will likewise throw a DATA_CLONE_ERR exception.
but, most of our use case, it's enough!
lisence
MIT