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

Function toJsonPointerArrayIndex

packages/effect/src/JsonPatch.ts:320–325  ·  view source on GitHub ↗

Converts a JSON Pointer reference token to a non-negative array index.

(token: string)

Source from the content-addressed store, hash-verified

318
319/** Converts a JSON Pointer reference token to a non-negative array index. */
320function 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
327function applyOperation(doc: Schema.Json, op: JsonPatchOperation): Schema.Json {
328 if (op.path === "") {

Callers 2

applyOperationFunction · 0.85
resolveParentFunction · 0.85

Calls 1

NumberFunction · 0.70

Tested by

no test coverage detected