Converts a JSON Pointer reference token to a non-negative array index.
(token: string)
| 318 | |
| 319 | /** Converts a JSON Pointer reference token to a non-negative array index. */ |
| 320 | function toJsonPointerArrayIndex(token: string): number { |
| 321 | if (!/^(0|[1-9]\d*)$/.test(token)) { |
| 322 | throw new Error(`Invalid array index: "${token}"`) |
| 323 | } |
| 324 | return Number(token) |
| 325 | } |
| 326 | |
| 327 | function applyOperation(doc: Schema.Json, op: JsonPatchOperation): Schema.Json { |
| 328 | if (op.path === "") { |
no test coverage detected