Namibian Pyjama Merchant

    @javier.alejandro.castro/immutable-patch

    0.1.1 • Public • Published

    Immutable Patch

    Apply RFC 6902 style patches to Immutable.JS data structures, such as Maps, Lists, and Sets.

    Forked from immutablepatch which focuses more on RFC 6902 style patches, requiring string values for the paths. This fork supports immutable-diff style patches.

    Getting Started

    You may get the module via npm:

    npm install @javier.alejandro.castro/immutable-patch
    

    And apply JSON patches to an immutable JSON object:

    var Immutable = require('immutable');
    var patch = require('@javier.alejandro.castro/immutable-patch');
    
    var list = Immutable.fromJS([1, 2, [3, 4]]);
    var ops = Immutable.fromJS([
      {op: 'replace', path: ['2','1'], value: 10}
    ]);
    
    var result = patch(list, ops);
    // var expected = Immutable.fromJS([1, 2, [3, 10]]);

    You will probably need immutable-diff to generate diff operations.

    Install

    npm i @javier.alejandro.castro/immutable-patch

    DownloadsWeekly Downloads

    1

    Version

    0.1.1

    License

    MIT

    Unpacked Size

    23.8 kB

    Total Files

    9

    Last publish

    Collaborators

    • javier.alejandro.castro