本文整理匯總了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));