aws-apply-patch-operations

applys patchOperations to the object

Usage no npm install needed!

<script type="module">
  import awsApplyPatchOperations from 'https://cdn.skypack.dev/aws-apply-patch-operations';
</script>

README

apply-patch-operations

applys patchOperations to the object.

Usage

example.js:

var applyPatchOperations = require('aws-apply-patch-operations');

var obj = {
  a: {_a: '_x'},
  b: {_b: 2}
};

var operations = applyPatchOperations(obj, [
  { op: 'replace', path: '/a/_a', value: '_y' },
  { op: 'replace', path: '/b/_b', value: '3' }
]);
console.dir(operations);
$ node ./example.js
{ a: {_a: '_y'},
  b: {_b: 3} }

Supported operations

  • add
  • remove
  • replace

API

var applyPatchOperations = require('apply-patch-operations');

applyPatchOperations(obj, patchOperations, opts)

  • Arguments
    • obj - Object
    • patchOperations - Array<map>
      • path - String
      • op - String - "add" | "remove" | "replace"
      • value - String
    • opts - map
      • mutable - defaults to false - Boolean
  • Return value
    • patchedObject - Object