object-delta-mask

0.0.3 • Public • Published

Object Delta Mask

Produces a grpc json mask string that can be used for patch http verbs. The string constains the property paths of what is differnent from the source object. See JSON Mapping : FieldMask string "f.fooBar,h"

Installation

  • npm: npm install object-delta-mask
const mask = require('object-delta-mask');

  let merchant = {
                name: "home",
                description: "james is a nice boy",
                id: 203203,
                age: 23,
                isActive: false,
                price: {
                    micro: 2000,
                    isCheap: false,
                    address: {
                        line1: "dfdfd"
                    }
                }
            };
  let dirtyMerchant = {
                name: "home",
                description: "james is a boy",
                id: 203203,
                age: 20,
                isActive: true,
                price: {
                    micro: 2001,
                    isCheap: true,
                    address: {
                        line1: "fddd"
                    }
                }
            };
  
  let result = mask.createMask(merchant, dirtyMerchant);
    
    
  //result ="description,age,isActive,price.micro,price.isCheap,price.address.line1"

Package Sidebar

Install

npm i object-delta-mask

Weekly Downloads

3

Version

0.0.3

License

MIT

Last publish

Collaborators

  • redten