How to use the jsonpointer.set function in jsonpointer

To help you get started, we’ve selected a few jsonpointer examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github danger / danger-js / source / platforms / git / gitJSONToGitDSL.ts View on Github external
if (Array.isArray(afterValue) && Array.isArray(beforeValue)) {
        const arrayBefore = beforeValue as any[]
        const arrayAfter = afterValue as any[]

        diff.added = arrayAfter.filter(o => !includes(arrayBefore, o))
        diff.removed = arrayBefore.filter(o => !includes(arrayAfter, o))
        // Do the same, but for keys inside an object if they both are objects.
      } else if (isobject(afterValue) && isobject(beforeValue)) {
        const beforeKeys = keys(beforeValue) as string[]
        const afterKeys = keys(afterValue) as string[]
        diff.added = afterKeys.filter(o => !includes(beforeKeys, o))
        diff.removed = beforeKeys.filter(o => !includes(afterKeys, o))
      }

      jsonpointer.set(accumulator, backAStepPath, diff)
      return accumulator
    }, Object.create(null))
  }
github netlify / build / packages / git-utils / src / unused.js View on Github external
// If they both are arrays, add some extra metadata about what was
    // added or removed. This makes it really easy to act on specific
    // changes to JSON DSLs
    if (Array.isArray(afterValue) && Array.isArray(beforeValue)) {
      const arrayBefore = beforeValue
      const arrayAfter = afterValue
      diff.added = arrayAfter.filter(o => !includes(arrayBefore, o))
      diff.removed = arrayBefore.filter(o => !includes(arrayAfter, o))
      // Do the same, but for keys inside an object if they both are objects.
    } else if (isobject(afterValue) && isobject(beforeValue)) {
      const beforeKeys = keys(beforeValue)
      const afterKeys = keys(afterValue)
      diff.added = afterKeys.filter(o => !includes(beforeKeys, o))
      diff.removed = beforeKeys.filter(o => !includes(afterKeys, o))
    }
    jsonpointer.set(accumulator, backAStepPath, diff)
    return accumulator
  }, Object.create(null))
}
github slurmulon / json-where / src / pointer.js View on Github external
update(rel, obj, data) {
    return jsonPointer.set(obj, rel, data)
  }

jsonpointer

Simple JSON Addressing.

MIT
Latest version published 2 years ago

Package Health Score

74 / 100
Full package analysis

Similar packages