import { Task } from "." ; import { ScriptTarget } from "./script.task" ; import { TaskType } from "./types" ; export type Target < T > = ( ... args : any [ ] ) => Promise < T > ; export type RunnableTaskOptions < R > = { target : ScriptTarget < R > ; children ? : RunnableTask < R > ; } & TaskType ; /**
 * 可运行任务
 */ export class RunnableTask < R > extends Task { target : Target < R > ; children ? : RunnableTask < R > ; constructor ( options ) { super ( options ) ; this . target = options . target ; this . children = options . children ; } param name param target returns static createBlockTask < R > ( { needBlock = true , ... options } ) { return this . createTask ( { needBlock , ... options } ) ; } param name param target param needBlock returns static createTask < R > ( options ) { return new RunnableTask ( options ) ; } param tasks returns static linkTasks < R > ( ... tasks ) { return tasks . reduceRight ( ( a , b ) => { b . children = a ; return b ; } ) ; } }