in src/utils/json-patch.js [171:200]
function remove(document, path) {
let parent = null;
let node = document;
let lastToken = null;
for (const { node: next, token } of walk(document, path)) {
parent = node;
node = next;
lastToken = token;
}
if (!parent) {
throw new InvalidPointerError(path);
}
if (Array.isArray(parent)) {
try {
const index = parseArrayIndex(lastToken, parent);
parent.splice(index, 1);
} catch (e) {
throw new InvalidPointerError(path);
}
} else if (node) {
delete parent[lastToken];
} else {
throw new InvalidPointerError(path);
}
return document;
}