ld-walk
v0.8.0
Published
This library provides a few utilities to facilitate resource location within a distributed graph of JSON-LD documents
Downloads
9
Readme
ld-walk
This library provides a few utilities to facilitate resource location within a distributed graph of JSON-LD documents. It builds on https://github.com/goofballLogic/ld-query to enable working with JSON-LD in a manner reminiscent of a browser DOM.
For example, let's say I have a starting point of
const api = "http://test.com/api/";
and a context document like:
const context = {
"@vocab": "http://test.com/vocab/"
};
If I initialise the walker like this:
import walker from "./Walker.js";
const apiWalker = walker.walk(context).from(api);
I could ask it to find nodes containing @id and dereference them like this:
const products = apiWalker.walk("catalog products books").toQuery();
Which would give me back a query object for the books node (or null if the walk failed at any point). Or alternatively, toJSON()
would return raw JSON instead.