New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

deep-copy-ts

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

deep-copy-ts

A deep-copy utility function for TypeScript

latest
Source
npmnpm
Version
0.5.4
Version published
Weekly downloads
4K
-24.83%
Maintainers
1
Weekly downloads
 
Created
Source

NPM Build Status

deep-copy-ts

A deep-copy (a.k.a. clone) utility function for TypeScript, based on ts-deepcopy. Explore it in CodeSandbox.

Installation

npm i deep-copy-ts

Usage

import { deepCopy } from "deep-copy-ts";

const obj = {
  // Primitive value
  a: 1,
  b: "b",
  c: {
    a: [{ a: "caa1" }, { a: "caa2" }],
  },
  d: null,
  e: undefined,
  f: true,
  // Reference value
  g: [1, 2, 3],
  h: () => {
    return "h";
  },
  i: {
    a: 1,
    b: "i.b",
    c: "",
    d: null,
    e: undefined,
    f: true,
    g: [1, 2, 3],
    h: () => {
      return "i.h";
    },
    i: { a: 1 },
  },
  j: new Date(),
  k: new DataView(new ArrayBuffer(16), 0),
  l: new RegExp("ab+c", "i"),
  m: new ArrayBuffer(16),
  n: new Float32Array(new ArrayBuffer(16), 0),
  o: new Float64Array(new ArrayBuffer(16), 0),
  p: new Int8Array(new ArrayBuffer(16), 0),
  q: new Int16Array(new ArrayBuffer(16), 0),
  r: new Int32Array(new ArrayBuffer(16), 0),
  s: new Uint8Array(new ArrayBuffer(16), 0),
  t: new Uint16Array(new ArrayBuffer(16), 0),
  u: new Uint32Array(new ArrayBuffer(16), 0),
  v: new Uint8ClampedArray(new ArrayBuffer(16), 0),
  // not supported in Safari yet
  w: new BigInt64Array(new ArrayBuffer(16), 0),
  x: new BigUint64Array(new ArrayBuffer(16), 0),
};

const obj2 = deepCopy(obj);
console.log("obj2: " + JSON.stringify(obj2, null, 2));
console.log("obj2.h: " + obj2.h);

Developing

npm i
npm start

Publishing

npm run dry-run       # To check all files that will be send to npm
npm run patch-release # or minor-release/major-release

FAQs

Package last updated on 06 Jan 2022

Did you know?

Socket

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