Skip to main content
variable deepFreeze
import { deepFreeze } from "https://deno.land/x/30_seconds_of_typescript@v1.0.1/util.ts";

Deep freezes an object.

Use Object.keys() to get all the properties of the passed object, Array.prototype.forEach() to iterate over them. Call Object.freeze(obj) recursively on all properties, checking if each one is frozen using Object.isFrozen() and applying deepFreeze() as necessary. Finally, use Object.freeze() to freeze the given object.

type

(obj: any) => unknown