* Tokenize a JSON Pointer into unescaped reference tokens. * * - `""` (empty pointer) refers to the root and returns `[]` * - Non-empty pointers must start with `/`
(pointer: string)
| 300 | * - Non-empty pointers must start with `/` |
| 301 | */ |
| 302 | function tokenize(pointer: string): Array<string> { |
| 303 | if (pointer === "") return [] |
| 304 | if (pointer.charCodeAt(0) !== 47 /* "/" */) { |
| 305 | throw new Error(`Invalid JSON Pointer, it must start with "/": ${JSON.stringify(pointer)}`) |
| 306 | } |
| 307 | return pointer.split("/").slice(1).map(unescapeToken) |
| 308 | } |
| 309 | |
| 310 | /** Convert a reference token to a non-negative array index (rejects `-` and negatives). */ |
| 311 | function toIndex(token: string): number { |
no test coverage detected