sly-utils
Version:
sly-utils is a modular and efficient JavaScript utility library designed to simplify complex tasks.
25 lines (24 loc) • 497 B
TypeScript
/**
* Utility method to make a nested object immutable
* @param {object} Nested object to be frozen
*
* @example
* const myObj = {
* internal: {
* a: null,
* b: {
* nested: true
* }
* },
* };
*
* deepFreeze(myObj);
*
* myObj.internal.a = "anotherValue";
* console.log(myObj.internal.a); // => null
*
* myObj.internal.b.nested = false;
* console.log(myObj.internal.b.nested); // => true
*
*/
export declare const deepFreeze: <T extends object>(obj: T) => T;