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

Function toIndex

packages/effect/src/JsonPatch.ts:311–316  ·  view source on GitHub ↗

Convert a reference token to a non-negative array index (rejects `-` and negatives).

(token: string)

Source from the content-addressed store, hash-verified

309
310/** Convert a reference token to a non-negative array index (rejects `-` and negatives). */
311function 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
318function applyOperation(doc: Schema.Json, op: JsonPatchOperation): Schema.Json {
319 if (op.path === "") {

Callers 2

applyOperationFunction · 0.85
resolveParentFunction · 0.85

Calls 1

NumberInterface · 0.70

Tested by

no test coverage detected