Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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);
}
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);
}