import { applyDefaults } from "https://deno.land/x/ana_utils@v0.0.5/src/utils.ts";
This function uses an object that stores the default values for an interface T
. It uses an input object of type Partial with new values to replace matching properties.
Examples
Example 1
Example 1
interface Example {
foo: string
bar?: string
}
function doSomething(props: Partial<Example>) {
const { foo, bar } = applyDefaults({foo: 'foo'}, props)
}