Convert a reference token to a non-negative array index (rejects `-` and negatives).
(token: string)
| 309 | |
| 310 | /** Convert a reference token to a non-negative array index (rejects `-` and negatives). */ |
| 311 | function toIndex(token: string): number { |
| 312 | if (!/^(0|[1-9]\d*)$/.test(token)) { |
| 313 | throw new Error(`Invalid array index: "${token}"`) |
| 314 | } |
| 315 | return Number(token) |
| 316 | } |
| 317 | |
| 318 | function applyOperation(doc: Schema.Json, op: JsonPatchOperation): Schema.Json { |
| 319 | if (op.path === "") { |
no test coverage detected