0.1.2 • Published 5 years ago

dankyou v0.1.2

Weekly downloads
7
License
MIT
Repository
github
Last release
5 years ago

DankYou

npm Build Status Coverage Status

Simple helper to iterate through a graph-like data structure. For now, the usage is focusing only on flowcharts. This is a work-in-progress project. It would still require a few things to be done before the first major version release.

Install

npm install dankyou

Usage

Given this kind of input:

const input = {
  root: 1,
  nodes: {
    a: { text: 'First' },
    b: { text: 'Yes or no?' },
    c: { text: 'You said No' },
    d: { text: 'You said Yes' },
    e: { text: 'Very well, bye' }
  },
  edges: [
    { from: 'a', to: 'b' },
    { from: 'b', to: 'c', text: 'No' },
    { from: 'b', to: 'd', text: 'Yes' },
    { from: 'c', to: 'e' },
    { from: 'd', to: 'e' }
  ]
}

You should be able to iterate through the input.

import DankYou from 'dankyou'
const dankyou = new DankYou(input)

dankyou.next().value
// { id: 'a',
//   node: { text: 'First' },
//   edges: { prev: [], next: [{ from: 'a', to: 'b' }] } }

dankyou.next().value
// { id: 'b',
//   node: { text: 'Yes or no?' },
//   edges: { prev: [{ from: 'a', to: 'b' }], next: [{ from: 'b', to: 'c', text: 'No' }, { from: 'b', to: 'd', text: 'Yes' }] } }

dankyou.next(4).value
// { id: 'd',
//   node: { text: 'You said Yes' },
//   edges: { prev: [{ from: 'b', to: 'd', text: 'Yes' }], next: [{ from: 'd', to: 'e' }] } }

dankyou.next().value
// { id: 'e',
//   node: { text: 'Very well, bye' },
//   edges: { prev: [{ from: 'd', to: 'e' }], next: [] } }

Test

npm run test

Build

npm run build

License

MIT

0.1.2

5 years ago

0.1.1

5 years ago

0.1.0

5 years ago

0.0.6

5 years ago

0.0.5

5 years ago

0.0.4

5 years ago

0.0.3

5 years ago

0.0.2

5 years ago

0.0.1

5 years ago