Skip to main content
Module

x/ana_components/deps.ts>applyDefaults

🅰️ UI library for Ana
Go to Latest
function applyDefaults
import { applyDefaults } from "https://deno.land/x/ana_components@v0.0.13/deps.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

  interface Example {
    foo: string
    bar?: string
  }

  function doSomething(props: Partial<Example>) {
    const { foo, bar } = applyDefaults({foo: 'foo'}, props)
  }

Type Parameters

T extends { }

Parameters

d: T

Default values for non-optional values in interface T.

i: Partial<T>

New values recieved with type Partial<T>

Returns

An object of type T that contains the default d values and the new input i values.