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

Assigns default values for all properties in an object that are undefined.

Use Object.assign() to create a new empty object and copy the original one to maintain key order, use spread operator ... to combine the default values, finally use obj again to overwrite properties that originally had a value.

type

(obj: any, ...defs: any[]) => unknown