UNPKG

jsonpath-faster

Version:

Query JavaScript objects with JSONPath expressions. Compiles and caches JSONpath to JS

21 lines (17 loc) 496 B
"use strict"; const tap = require("tap"); const jp = require(".."); tap.test("vivify root", async () => { const obj = jp.visit(undefined, "$", () => "Hello"); tap.same(obj, "Hello", "vivified root"); }); tap.test("vivify deep node", async () => { const doc = { id: "FOO" }; const out = jp.visit(doc, "$.meta.author", () => "andy@hexten.net"); tap.same( doc, { id: "FOO", meta: { author: "andy@hexten.net" } }, "doc updated" ); tap.same(doc, out, "doc returned"); });