本文整理汇总了TypeScript中@ts-task/task.Task.resolve方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Task.resolve方法的具体用法?TypeScript Task.resolve怎么用?TypeScript Task.resolve使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类@ts-task/task.Task
的用法示例。
在下文中一共展示了Task.resolve方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: render
render () {
const self = this;
return Task.resolve(this)
.map(({inputFile, helpers}) => this.renderer.render(inputFile, {mddoc: helpers}))
.chain(html => writeFileCreateDir(self.outputFile, html))
.map(tap(_ => console.log(green('We wrote ') + grey(self.outputFile))));
}
示例2: taskReducer
const loop = (index: number) => (curr: A): Task<A, E | UnknownError> => {
if (index >= items.length) {
return Task.resolve(curr);
} else {
return taskReducer(curr, items[index])
.chain(loop(index + 1));
}
};
示例3: function
return function (stat: fs.Stats) {
// If its not a directory, resolve it on the spot with the name of the file
if (!stat.isDirectory()) {
return Task.resolve([filename]);
}
// If it is, resolve it once its subdirectory is resolved
else {
return doWalkDir(filename, options);
}
};
示例4: nextStep
export function sequence<E1> (steps: Step<E1>[]): Task<void, E1> {
// clone the steps
const newSteps = [...steps] as [Step<any>];
// Remove the next step from the array
const nextStep = newSteps.shift();
// If there are any left, resolve inmediatly
if (!nextStep) {
return Task.resolve(void 0);
} else {
// If there is a step invoke it
return nextStep().chain(
() => sequence(newSteps)
);
}
}
示例5:
const task1Mock = jest.fn((x: number) => Task.resolve(1 + x));