{"ast":null,"code":"import { Scheduler } from '../Scheduler';\nexport class AsyncScheduler extends Scheduler {\n  constructor(SchedulerAction, now = Scheduler.now) {\n    super(SchedulerAction, () => {\n      if (AsyncScheduler.delegate && AsyncScheduler.delegate !== this) {\n        return AsyncScheduler.delegate.now();\n      } else {\n        return now();\n      }\n    });\n    this.actions = [];\n    this.active = false;\n    this.scheduled = undefined;\n  }\n\n  schedule(work, delay = 0, state) {\n    if (AsyncScheduler.delegate && AsyncScheduler.delegate !== this) {\n      return AsyncScheduler.delegate.schedule(work, delay, state);\n    } else {\n      return super.schedule(work, delay, state);\n    }\n  }\n\n  flush(action) {\n    const {\n      actions\n    } = this;\n\n    if (this.active) {\n      actions.push(action);\n      return;\n    }\n\n    let error;\n    this.active = true;\n\n    do {\n      if (error = action.execute(action.state, action.delay)) {\n        break;\n      }\n    } while (action = actions.shift());\n\n    this.active = false;\n\n    if (error) {\n      while (action = actions.shift()) {\n        action.unsubscribe();\n      }\n\n      throw error;\n    }\n  }\n\n} //# sourceMappingURL=AsyncScheduler.js.map","map":null,"metadata":{},"sourceType":"module"}