@mapstore/patcher

0.1.1 • Public • Published

Patcher

This lib allows to use jsonpath rules inside a json patch rules

How to use it

import {mergeConfigsPatch} from '@mapstore/patcher';


const sourceFile = {
  name: "Alfredo",
  isValid: true,
  children: [{
    name: "Luke"
  }]
}
const jsonPathRules = [{
  "op": "remove",
  "jsonpath": "$.name"
}]
const jsonPatchRules = [{
  "op": "remove",
  "path": "/name"
}]

const resultJsonPath = mergeConfigsPatch(sourceFile, jsonPathRules);
const resultJsonPatch = mergeConfigsPatch(sourceFile, jsonPatchRules);

console.log(resultJsonPath === resultJsonPatch)
true

console.log(resultJsonPath)
{
  isValid: true,
  children: [{
    name: "Luke"
  }]
}

references

jsonpath

json-patch

Readme

Keywords

none

Package Sidebar

Install

npm i @mapstore/patcher

Weekly Downloads

3

Version

0.1.1

License

ISC

Unpacked Size

78.2 kB

Total Files

23

Last publish

Collaborators

  • offtherailz
  • mv88
  • allyoucanmap
  • mbarto