MCPcopy Create free account
hub / github.com/Starcounter-Jack/JSON-Patch / applyReducer

Function applyReducer

commonjs/core.js:296–302  ·  view source on GitHub ↗

* Apply a single JSON Patch Operation on a JSON document. * Returns the updated document. * Suitable as a reducer. * * @param document The document to patch * @param operation The operation to apply * @return The updated document

(document, operation, index)

Source from the content-addressed store, hash-verified

294 * @return The updated document
295 */
296function applyReducer(document, operation, index) {
297 var operationResult = applyOperation(document, operation);
298 if (operationResult.test === false) { // failed test
299 throw new exports.JsonPatchError("Test operation failed", 'TEST_OPERATION_FAILED', index, operation, document);
300 }
301 return operationResult.newDocument;
302}
303exports.applyReducer = applyReducer;
304/**
305 * Validates a single operation. Called from `jsonpatch.validate`. Throws `JsonPatchError` in case of an error.

Callers

nothing calls this directly

Calls 1

applyOperationFunction · 0.70

Tested by

no test coverage detected