@scalar/api-client
Version:
the open source API testing client
25 lines (24 loc) • 533 B
JavaScript
const u = (r, o) => {
let e = r;
for (const n of o) {
if (!e)
return;
if (e.type === "object") {
const t = String(n);
e = e.properties.find((i) => i.keyNode.value === t)?.valueNode;
continue;
}
if (e.type === "array") {
const t = typeof n == "number" ? n : Number.parseInt(String(n), 10);
if (!Number.isFinite(t) || t < 0 || t >= e.items.length)
return;
e = e.items[t];
continue;
}
return;
}
return e;
};
export {
u as getJsonAstNodeAtPath
};