1 line
7.6 KiB
JSON
1 line
7.6 KiB
JSON
{"ast":null,"code":"import { AsyncAction } from './AsyncAction';\nimport { AsyncScheduler } from './AsyncScheduler';\nexport class VirtualTimeScheduler extends AsyncScheduler {\n constructor(SchedulerAction = VirtualAction, maxFrames = Number.POSITIVE_INFINITY) {\n super(SchedulerAction, () => this.frame);\n this.maxFrames = maxFrames;\n this.frame = 0;\n this.index = -1;\n }\n\n flush() {\n const {\n actions,\n maxFrames\n } = this;\n let error, action;\n\n while ((action = actions[0]) && action.delay <= maxFrames) {\n actions.shift();\n this.frame = action.delay;\n\n if (error = action.execute(action.state, action.delay)) {\n break;\n }\n }\n\n if (error) {\n while (action = actions.shift()) {\n action.unsubscribe();\n }\n\n throw error;\n }\n }\n\n}\nVirtualTimeScheduler.frameTimeFactor = 10;\nexport class VirtualAction extends AsyncAction {\n constructor(scheduler, work, index = scheduler.index += 1) {\n super(scheduler, work);\n this.scheduler = scheduler;\n this.work = work;\n this.index = index;\n this.active = true;\n this.index = scheduler.index = index;\n }\n\n schedule(state, delay = 0) {\n if (!this.id) {\n return super.schedule(state, delay);\n }\n\n this.active = false;\n const action = new VirtualAction(this.scheduler, this.work);\n this.add(action);\n return action.schedule(state, delay);\n }\n\n requestAsyncId(scheduler, id, delay = 0) {\n this.delay = scheduler.frame + delay;\n const {\n actions\n } = scheduler;\n actions.push(this);\n actions.sort(VirtualAction.sortActions);\n return true;\n }\n\n recycleAsyncId(scheduler, id, delay = 0) {\n return undefined;\n }\n\n _execute(state, delay) {\n if (this.active === true) {\n return super._execute(state, delay);\n }\n }\n\n static sortActions(a, b) {\n if (a.delay === b.delay) {\n if (a.index === b.index) {\n return 0;\n } else if (a.index > b.index) {\n return 1;\n } else {\n return -1;\n }\n } else if (a.delay > b.delay) {\n return 1;\n } else {\n return -1;\n }\n }\n\n}","map":{"version":3,"names":["AsyncAction","AsyncScheduler","VirtualTimeScheduler","constructor","SchedulerAction","VirtualAction","maxFrames","Number","POSITIVE_INFINITY","frame","index","flush","actions","error","action","delay","shift","execute","state","unsubscribe","frameTimeFactor","scheduler","work","active","schedule","id","add","requestAsyncId","push","sort","sortActions","recycleAsyncId","undefined","_execute","a","b"],"sources":["D:/MobileDev/WRB/WrenchBoard2023a/node_modules/rxjs/_esm2015/internal/scheduler/VirtualTimeScheduler.js"],"sourcesContent":["import { AsyncAction } from './AsyncAction';\nimport { AsyncScheduler } from './AsyncScheduler';\nexport class VirtualTimeScheduler extends AsyncScheduler {\n constructor(SchedulerAction = VirtualAction, maxFrames = Number.POSITIVE_INFINITY) {\n super(SchedulerAction, () => this.frame);\n this.maxFrames = maxFrames;\n this.frame = 0;\n this.index = -1;\n }\n flush() {\n const { actions, maxFrames } = this;\n let error, action;\n while ((action = actions[0]) && action.delay <= maxFrames) {\n actions.shift();\n this.frame = action.delay;\n if (error = action.execute(action.state, action.delay)) {\n break;\n }\n }\n if (error) {\n while (action = actions.shift()) {\n action.unsubscribe();\n }\n throw error;\n }\n }\n}\nVirtualTimeScheduler.frameTimeFactor = 10;\nexport class VirtualAction extends AsyncAction {\n constructor(scheduler, work, index = scheduler.index += 1) {\n super(scheduler, work);\n this.scheduler = scheduler;\n this.work = work;\n this.index = index;\n this.active = true;\n this.index = scheduler.index = index;\n }\n schedule(state, delay = 0) {\n if (!this.id) {\n return super.schedule(state, delay);\n }\n this.active = false;\n const action = new VirtualAction(this.scheduler, this.work);\n this.add(action);\n return action.schedule(state, delay);\n }\n requestAsyncId(scheduler, id, delay = 0) {\n this.delay = scheduler.frame + delay;\n const { actions } = scheduler;\n actions.push(this);\n actions.sort(VirtualAction.sortActions);\n return true;\n }\n recycleAsyncId(scheduler, id, delay = 0) {\n return undefined;\n }\n _execute(state, delay) {\n if (this.active === true) {\n return super._execute(state, delay);\n }\n }\n static sortActions(a, b) {\n if (a.delay === b.delay) {\n if (a.index === b.index) {\n return 0;\n }\n else if (a.index > b.index) {\n return 1;\n }\n else {\n return -1;\n }\n }\n else if (a.delay > b.delay) {\n return 1;\n }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