if-parser.js 541 B

12345678910111213141516171819
  1. /** 语句:if 条件判断(解析在此,执行在 sequence-runner) */
  2. const types = ['if']
  3. function parse(action, parseContext) {
  4. const { parseActions } = parseContext
  5. const parsed = {
  6. type: 'if',
  7. condition: action.condition,
  8. then: (action.then || action.ture) ? parseActions(action.then || action.ture) : [],
  9. else: action.else ? parseActions(action.else) : [],
  10. }
  11. return Object.assign({}, action, parsed)
  12. }
  13. async function execute() {
  14. return { success: true }
  15. }
  16. module.exports = { types, parse, execute }