• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript task.Task类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了TypeScript中@ts-task/task.Task的典型用法代码示例。如果您正苦于以下问题:TypeScript Task类的具体用法?TypeScript Task怎么用?TypeScript Task使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了Task类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。

示例1: generate

    generate (helpers: unknown) {
        const self = this;
        const tasks: Task<unknown, NodeJS.ErrnoException | UnknownError>[] = [];

        if (self.generatorSettings.copyAssets) {
            tasks.push(self.copyAssets());
        }

        // TODO: Remove the files settings, probably walk the dir for .tpl files
        for (let i = 0; i < self.generatorSettings.files.length; i++) {
            // Create the object in charge of rendering the html
            const renderObject = new HtmlWriterFile({
                inputFile: self.generatorSettings.files[i] + '.tpl',
                outputFile: self.generatorSettings.outputDir + '/' + self.generatorSettings.files[i] + '.html',
                renderer: self.renderer
            });

            // ...
            renderObject.setHelpers(helpers);

            // Generate the html
            tasks.push(renderObject.render());
        }

        return Task.all(tasks);
    }
开发者ID:hrajchert,项目名称:mddoc,代码行数:26,代码来源:custom-generator.ts


示例2: generate

    generate () {
        const self = this;
        const tasks: ReturnType<typeof writeFileCreateDir>[] = [];

        self.metadata.renderedFragments = {};

        // For each markdown, create the html fragment
        for (const mdTemplate in self.metadata.jsonml) {
            try {
                const tree = markdown.toHTMLTree(self.metadata.jsonml[mdTemplate]);
                const html = markdown.renderJsonML(tree);

                const outputFilename = self.generatorSettings.outputDir + '/' + mdTemplate + '.html';
                // mhmhmh TODO: This is sooo hardcoded
                self.metadata.renderedFragments[mdTemplate] = 'fragment/' + mdTemplate + '.html';

                tasks.push(writeFileCreateDir(outputFilename, html));

            } catch (e) {
                // TODO: Catch this better
                console.log(red('Problem with ') + mdTemplate);
                throw e;
            }
        }

        return Task.all(tasks);
    }
开发者ID:hrajchert,项目名称:mddoc,代码行数:27,代码来源:html-fragment-generator.ts


示例3: 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))));
 }
开发者ID:hrajchert,项目名称:mddoc,代码行数:7,代码来源:custom-generator.ts


示例4: mkdir

 .catch(err => {
     if (err.code === 'ENOENT') {
         return mkdir(path);
     } else {
         return Task.reject(err);
     }
 });
开发者ID:hrajchert,项目名称:mddoc,代码行数:7,代码来源:write-file-create-dir.ts


示例5: 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));
     }
 };
开发者ID:hrajchert,项目名称:mddoc,代码行数:8,代码来源:task-reduce.ts


示例6: 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);
     }
 };
开发者ID:hrajchert,项目名称:mddoc,代码行数:10,代码来源:walk-dir.ts


示例7: 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)
        );
    }
}
开发者ID:hrajchert,项目名称:mddoc,代码行数:15,代码来源:sequence.ts


示例8:

export function traverseDictionary<T, E> (objOfTasks: Dictionary<Task<T, E>>): Task<Dictionary<T>, UnknownError | E> {
    // Create an array of task with a tuple containing the key and the value
    const tasks =
        Object.keys(objOfTasks)
            .map(key => objOfTasks[key]
                        .map(value => ({key, value}))
            );
    // Wait until all tasks are resolved
    return Task.all(tasks)
                // And transform the array back into an object
                .map(pairs => {
                    const ans: Dictionary<T> = {};
                    pairs.forEach(({key, value}) => ans[key] = value);
                    return ans;
                });
}
开发者ID:hrajchert,项目名称:mddoc,代码行数:16,代码来源:traverse-dictionary.ts


示例9:

        .chain(function (files) {
            const promises: ReturnType<typeof copyFile>[] = [];

            for (let i = 0; i < files.length; i++) {
                const m = files[i].match(matchRe);
                if (m) {
                    const inputFilename = files[i];
                    const outputFilename = dst + '/' + files[i].substr(dirNameLength + 1);
                    // console.log(inputFilename.grey + " => ".green + outputFilename.grey);

                    // Copy the file
                    promises.push(copyFile(inputFilename, outputFilename));
                }
            }
            return Task.all(promises);
        });
开发者ID:hrajchert,项目名称:mddoc,代码行数:16,代码来源:copy-dir.ts



注:本文中的@ts-task/task.Task类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript common.Get函数代码示例发布时间:2022-05-28
下一篇:
TypeScript iterator.isArray函数代码示例发布时间:2022-05-28
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap