1.0.0 • Published 5 years ago

rosmaro-graph-from-arrows v1.0.0

Weekly downloads
1
License
ISC
Repository
-
Last release
5 years ago

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)
1.0.0

5 years ago