MCPcopy Create free account
hub / github.com/Effect-TS/effect / tokenize

Function tokenize

packages/effect/src/JsonPatch.ts:302–308  ·  view source on GitHub ↗

* Tokenize a JSON Pointer into unescaped reference tokens. * * - `""` (empty pointer) refers to the root and returns `[]` * - Non-empty pointers must start with `/`

(pointer: string)

Source from the content-addressed store, hash-verified

300 * - Non-empty pointers must start with `/`
301 */
302function 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). */
311function toIndex(token: string): number {

Callers 1

resolveParentFunction · 0.70

Calls 2

mapMethod · 0.45
splitMethod · 0.45

Tested by

no test coverage detected