How to use the json8-pointer.decode function in json8-pointer

To help you get started, we’ve selected a few json8-pointer 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 sonnyp / JSON8 / packages / patch / lib / apply.js View on Github external
function run(doc, patch) {
  const pathTokens = typeof patch.path === "string" ? decode(patch.path) : null;
  const fromTokens = typeof patch.from === "string" ? decode(patch.from) : null;

  switch (patch.op) {
    case "add":
    case "replace":
    case "test":
      if (patch.value === undefined) throw new Error("Missing value parameter");
      return operations[patch.op](doc, pathTokens, patch.value);

    case "move":
    case "copy":
      return operations[patch.op](doc, fromTokens, pathTokens);

    case "remove":
      return operations[patch.op](doc, pathTokens);
  }
github sonnyp / JSON8 / packages / patch / lib / apply.js View on Github external
function run(doc, patch) {
  const pathTokens = typeof patch.path === "string" ? decode(patch.path) : null;
  const fromTokens = typeof patch.from === "string" ? decode(patch.from) : null;

  switch (patch.op) {
    case "add":
    case "replace":
    case "test":
      if (patch.value === undefined) throw new Error("Missing value parameter");
      return operations[patch.op](doc, pathTokens, patch.value);

    case "move":
    case "copy":
      return operations[patch.op](doc, fromTokens, pathTokens);

    case "remove":
      return operations[patch.op](doc, pathTokens);
  }

json8-pointer

JSON Pointer toolkit for JavaScript

ISC
Latest version published 3 years ago

Package Health Score

51 / 100
Full package analysis