* 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)
| 294 | * @return The updated document |
| 295 | */ |
| 296 | function 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 | } |
| 303 | exports.applyReducer = applyReducer; |
| 304 | /** |
| 305 | * Validates a single operation. Called from `jsonpatch.validate`. Throws `JsonPatchError` in case of an error. |
nothing calls this directly
no test coverage detected