Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolve incorrect JsonPatchError format for Arrays #221

Merged
merged 7 commits into from Mar 29, 2019
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 3 additions & 2 deletions README.md
Expand Up @@ -209,7 +209,7 @@ Returns an array of [`OperationResult`](#operationresult-type) objects - one ite

- See [Validation notes](#validation-notes).

#### `function applyOperation<T>(document: T, operation: Operation, validateOperation: boolean | Validator<T> = false, mutateDocument: boolean = true, banPrototypeModifications: boolean = true): OperationResult<T>`
#### `function applyOperation<T>(document: T, operation: Operation, validateOperation: boolean | Validator<T> = false, mutateDocument: boolean = true, banPrototypeModifications: boolean = true, index: number = 0): OperationResult<T>`

Applies single operation object `operation` on `document`.

Expand All @@ -218,6 +218,7 @@ Applies single operation object `operation` on `document`.
- `validateOperation` Whether to validate the operation, or to pass a validator callback
- `mutateDocument` Whether to mutate the original document or clone it before applying
- `banPrototypeModifications` Whether to ban modifications to `__proto__`, defaults to `true`.
- `index` The index of the operation in your patch array. Useful for better error reporting when that operation fails to apply.

It modifies the `document` object and `operation` - it gets the values by reference.
If you would like to avoid touching your values, clone them: `jsonpatch.applyOperation(document, jsonpatch.deepClone(operation))`.
Expand All @@ -229,7 +230,7 @@ Returns an [`OperationResult`](#operationresult-type) object `{newDocument: any,

- See [Validation notes](#validation-notes).

#### `jsonpatch.applyReducer<T>(document: T, operation: Operation): T`
#### `jsonpatch.applyReducer<T>(document: T, operation: Operation, index: number): T`

**Ideal for `patch.reduce(jsonpatch.applyReducer, document)`**.

Expand Down