Partjson is a data shaping syntax and utility. It fills a JSON-based template to match the intended structure of data collections and aggregated results.
Good fit for
Bad fit for
More details are described in the Syntax and Reserved Terms pages.
https://github.com/siosonel/partjson
// from your project directory
$ npm install partjson
// in code file
import Partjson from "partjson"
const Pj = new Partjson({
template: {...}
// data is optional at instantiation,
// but will trigger processing if provided
data: [{...}, ...],
"=": {
// external functions and properties
}
})
// append to results
Pj.add({
data: [{...}, ...]
})
// re-parse template, clear results
Pj.refresh({
template: {...} // optional if replacing
data: [{...}, ...] // optional if replacing
"=": {...} // optional if replacing
})
// *** Use the results ***
// either loop through the results manually
for(const geneName in Pj.tree.byGene) {
...
}
// or if the @dist() keyword was used
// to target a @root.results container array
viz.renderer(Pj.tree.results)