Nonviolent Pigeon Manifestation

    @profiscience/knockout-contrib-utils-merge
    TypeScript icon, indicating that this package has built-in type declarations

    1.0.0-alpha.14 • Public • Published

    @profiscience/knockout-contrib-utils-merge

    Version Dependency Status Peer Dependency Status Dev Dependency Status Downloads

    NOTE: It is recommended to use the @profiscience/knockout-contrib-utils metapackage

    Usage

    merge(dest, src[, mapArrays = false])

    For each enumerable property of src, a) creates an observable when undefined on dest b) updates when existing observable on dest c) sets when existing non-observable on dest.

    If mapArrays is true, array elements will be created as mapped observables, else bare objects/primitives. NOTE: Merging new arrays onto existing ones that have been mapped deep will create new observable elements, not update the existing ones. No attempts are made to key elements, nor will they. If you need more, you probably want ko.mapping which is much more powerful, but far slower.

    import { merge } from '@profiscience/knockout-contrib-utils'
    
    const foos = {
      foo: ko.observable('foo'),
      bar: 'bar'
    }
    
    merge(foos, {
      foo: 'new foo',
      bar: 'new bar',
      baz: 'baz'
    })
    
    foos()
    // {
    //   foo: ko.observable('new foo'),
    //   bar: 'new bar',
    //   baz: ko.observable('baz')
    // }

    Install

    npm i @profiscience/knockout-contrib-utils-merge

    DownloadsWeekly Downloads

    2

    Version

    1.0.0-alpha.14

    License

    WTFPL

    Unpacked Size

    16.4 kB

    Total Files

    10

    Last publish

    Collaborators

    • dorgeron
    • barsh