Socket
Socket
Sign inDemoInstall

h-clone

Package Overview
Dependencies
182
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    h-clone

a simple and morden deep clone tool


Version published
Weekly downloads
2
increased by100%
Maintainers
1
Install size
24.4 MB
Created
Weekly downloads
 

Readme

Source

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

import clone from 'h-clone'

const target = {
    name: 'tom',
    age: 12,
    boy: true,
    info: {
        add: 'xxx'
    }
};

const copy = clone(target);

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:

  1. The lastIndex field of RegExp objects is not preserved.
  2. 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.
  3. The prototype chain does not get walked and duplicated.
  4. Error and Function objects cannot be duplicated by the structured clone algorithm; attempting to do so will throw a DATA_CLONE_ERR exception.
  5. Attempting to clone DOM nodes will likewise throw a DATA_CLONE_ERR exception.

but, most of our use case, it's enough!

lisence

MIT

Keywords

FAQs

Last updated on 12 Sep 2019

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc