knockout-contrib

:metal: KnockoutJS Goodies Monorepo

View the Project on GitHub Profiscience/knockout-contrib

utils.defaults

Version Dependency Status Peer Dependency Status Dev Dependency Status Downloads

This package is intended for consumption via the [@profiscience/knockout-contrib] metapackage

Usage

defaults(dest, defaultValues[, mapArrays = false])

Creates observables for enumerable properties of defaultValues where undefined in the destination object.

If mapArrayElements is true, array elements will be created using utils.fromJS.

import { defaults } from '@profiscience/knockout-contrib'

const foos = { foo: 'foo' }
defaults(foos, { foo: 'bar', bar: 'bar' })

foos()
// { foo: 'foo', bar: 'bar' }