Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

About

A package used to clone and freeze object in more than just a superficial level





Table of content

The content below does not correspond to the object structure of the objects





How to use?

Description

This package allows for cloning and freezing all the way, and even supports circular references!

Import

Terminal

npm install @protagonists/deep

Node.js

const { deepClone, deepFreeze } = require("@protagonists/deep");


Example

Code:

// Imports
const { deepClone } = require("@protagonists/deep");

// Create some object
const John = {
  name: "John",
  age: 37,
  friend: {
    name: "Steve",
    age: 35
  }
}

// Clone it
const clone = deepClone("John");
// Edit a value in the nested object
clone.friend.name = "Meep";

// Log them both
// this show that the nested object in the clone is not the same!
console.log(John);
console.log(clone);

Output:

{
  name: 'John',
  age: 37,
  friend: {
    name: 'Steve',
    age: 35
  }
}
{
  name: 'John',
  age: 37,
  friend: {
    name: 'Meep',
    age: 35
  }
}






This is the bottom, there is nothing more.
Go back up?

About

Simple package to handle objects

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages