import { protect } from "https://deno.land/x/rimbu@0.13.5/deep/mod.ts";
Returns the same value wrapped in the Protected
type.
Examples
Example 1
Example 1
const obj = Deep.protect({ a: 1, b: { c: true, d: [1] } })
obj.a = 2 // compiler error: a is readonly
obj.b.c = false // compiler error: c is readonly
obj.b.d.push(2) // compiler error: d is a readonly array
(obj as any).b.d.push(2) // will actually mutate the object
Parameters
source: T
- the value to wrap