Nobody Prefers Margarine
    Share your code. npm Orgs help your team discover, share, and reuse code. Create a free org »

    signalk-mergepublic

    SignalK-merge

    Utility to merge two Signal K objects, resolving conflicts using the timestamp of child objects. Small javascript utility to merge two Signal K objects or merge an child-object into a vessel in an existing Signal K tree. Conflicts are resolved by comparing timestamps.

    Installation

    npm install signalk-merge

    Usage

     
    var merge  = require('signalk-merge');
     
    /*
        Merge a full signalK object into another.
        Arguments:
            0: full signalk object
            1: full signalk object
    */
    var signalk = merge.full(signal_k_object_a, signal_k_object_b);
     
     
    /*
        Merge a partial 'navigation' object into vessel 'self'.
        Arguments:
            0: full signalk object
            1: vessel identifier or 'self'
            2: object to merge into the vessel
    */
    signalk = merge.into(signalk, 'self', {
        "navigation": {
            "state": {
                "timestamp": "",
                "state": "under way sailing"
            }
        }
    });
     

    Note: At the moment, it's not possible to merge partial objects into anything else but a vessel. Scheduled for the next release.

    install

    npm i signalk-merge

    Downloadsweekly downloads

    8

    version

    0.1.9

    license

    Apache 2

    repository

    githubgithub

    last publish

    collaborators

    • avatar