Files
JiboSDK/node_modules/jibo/lib/behaviors/base/sequence.js
2026-03-22 03:21:45 +02:00

1 line
836 B
JavaScript

"use strict";var t=require("../../bt/factory"),r=require("../../bt/base"),e=r.Status,i=r.createBehavior;module.exports=i({constructor:function(t){this.children=t||[],this.current=-1},start:function(){if(0===this.children.length)return!0;this.current=0;var t=this.children[this.current].start();return this.current=t?this.current:-1,t},stop:function(){-1!==this.current&&this.current<this.children.length&&(this.current=-1)},update:function(){if(-1!==this.current&&this.current<this.children.length){var t=this.children[this.current].update();if(t===e.SUCCEEDED)return this.current++,this.current<this.children.length?this.children[this.current].start()?e.IN_PROGRESS:e.FAILED:e.SUCCEEDED;if(t===e.IN_PROGRESS||t==e.PAUSED)return e.IN_PROGRESS}else if(0===this.children.length)return e.SUCCEEDED;return e.FAILED}}),t.addBehavior(module);