rosmaro-graph-from-arrows
v1.0.0
Published
Build a simple rosmaro graph from just the arrows
Downloads
7
Readme
Rosmaro Graph From Arrows
for simple graphs, Rosmaro is verbose, this module just simplifies making a graph from just the Arrows
npm i rosmaro-graph-from-arrows --save
then define your arrows
const fromArrows = require('rosmaro-graph-from-arrows')
let arrows = {
Off: { 'evening start': { target: 'EveningLights' } },
EveningLights: { 'bed': { target: 'EveningOff' } },
EveningOff: {
'morning activity': { target: 'MorningLights' },
'quiet morning': { target: 'Off' },
},
MorningLights: { 'dawn start': { target: 'Off' } }
}
// handler functions
const Off = ({action, context, node}) => {
if (action.type === 'PING' && between(action, 'sunset', 'sunrise')) return change(action, context, node, 'evening start')
return noChange(context)
}
let handlers = {main, Off, EveningLights, EveningOff, MorningLights} // this are functions
const {graph, bindings} = fromArrows(arrows, handlers)