@aegenet/belt-oclone
v2.3.0
Published
Simple object clone
Downloads
85
Readme
@aegenet/belt-oclone
Simple clone
💾 Installation
yarn add @aegenet/belt-oclone@^2.0.0
# or
npm i @aegenet/belt-oclone@^2.0.0
📝 Usage
import { oclone } from '@aegenet/belt-oclone';
const clone = oclone({
id: 5,
}),
// clone ={
// id: 5,
// }
const myClass = class {
id = 5;
method() {
return 'ha';
}
};
const source = new myClass();
const clone = oclone(source/*, { keepType: false }*/);
// clone ={
// id: 5,
// }
clone.method(); // throw error
const myClass = class {
id = 5;
method() {
return 'ha';
}
};
const source = new myClass();
const clone = oclone(source, { keepType: true });
// clone ={
// id: 5,
// method: () => void
// }
clone.method(); // 'ha'