UNPKG

jsongraph

Version:

powerful minimalist graph/dataflow programming based on jsonschema references (nodejs/coffeescript)

61 lines (47 loc) 906 B
// Generated by CoffeeScript 1.9.3 (function() { var data, graph, jg, json; jg = require('jsongraph'); json = { graph: { a: { value: "{book.category[0].text}" }, b: { value: "{foo}", value_int: { "$ref": "#/data/book/code" }, value_str: { "$ref": "#/data/book/category[0].text" } } } }; data = { book: { code: 1, category: [ { text: "fairytales stories" } ] }, foo: function() { return ++this.book.code; } }; jg.opts.verbose = 2; graph = jg.init(json); graph.evaluate(data); graph.dump(); data.book.category[0].text = "foo"; graph.set('a', graph.evaluate(data, { graph: graph.get('a') })); graph.dump(); graph.evaluate(data, { parsers: ["ref", "expr"] }); graph.dump(); }).call(this);