npm.io
0.0.5 • Published 8 years ago

asl-choice-processor

Licence
MIT
Version
0.0.5
Deps
4
Size
13 kB
Vulns
11
Weekly
0
Stars
121
DeprecatedThis package is deprecated

asl-choice-processor

JavaScript Style Guide license

For determining the next state given an Amazon States Language "Choices" definition and a set of values.

Install

$ npm install asl-choice-processor --save

Usage

const choiceProcessor = require('asl-choice-processor')
const calculateNextState = choiceProcessor(
  {
    Choices: [
      {
        Variable: '$.foo',
        NumericEquals: 1,
        Next: 'FirstMatchState'
      },
      {
        Variable: '$.foo',
        NumericEquals: 2,
        Next: 'SecondMatchState'
      }
    ],
    Default: 'DefaultMatchState'
  }
)

calculateNextState( {foo: 1} ) // FirstMatchState
calculateNextState( {foo: 2} ) // SecondMatchState
calculateNextState( {foo: 3} ) // DefaultMatchState

Tests

$ npm test

License

MIT