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

TypeScript bluebird.cast函数代码示例

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

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



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

示例1: loadRegistryInfo

// triggers the registry download if registry hasn't been downloaded yet
function loadRegistryInfo() {
    const registryInfo = ExtensionManager.extensions[packageJson.name].registryInfo;
    if (!registryInfo) {
        return Promise.cast(ExtensionManager.downloadRegistry());
    }
    return Promise.resolve();
}
开发者ID:MarcelGerber,项目名称:brackets-git,代码行数:8,代码来源:ExtensionInfo.ts


示例2: resolve

                .then((_text) => {
                    let text = _text;
                    if (text === null) {
                        return resolve();
                    }

                    if (removeBom) {
                        // remove BOM - \uFEFF
                        text = text.replace(/\uFEFF/g, "");
                    }
                    if (normalizeLineEndings) {
                        // normalizes line endings
                        text = text.replace(/\r\n/g, "\n");
                    }
                    // process lines
                    const lines = text.split("\n");

                    if (lineNumbers) {
                        lineNumbers.forEach((lineNumber) => {
                            if (typeof lines[lineNumber] === "string") {
                                lines[lineNumber] = lines[lineNumber].replace(/\s+$/, "");
                            }
                        });
                    } else {
                        lines.forEach((ln, lineNumber) => {
                            if (typeof lines[lineNumber] === "string") {
                                lines[lineNumber] = lines[lineNumber].replace(/\s+$/, "");
                            }
                        });
                    }

                    // add empty line to the end, i've heard that git likes that for some reason
                    if (addEndlineToTheEndOfFile) {
                        const lastLineNumber = lines.length - 1;
                        if (lines[lastLineNumber].length > 0) {
                            lines[lastLineNumber] = lines[lastLineNumber].replace(/\s+$/, "");
                        }
                        if (lines[lastLineNumber].length > 0) {
                            lines.push("");
                        }
                    }

                    text = lines.join("\n");
                    return Promise.cast(FileUtils.writeText(fileEntry, text))
                        .catch((err) => {
                            ErrorHandler.logError("Wasn't able to clean whitespace from file: " + fullPath);
                            resolve();
                            throw err;
                        })
                        .then(() => {
                            // refresh the file if it's open in the background
                            DocumentManager.getAllOpenDocuments().forEach((doc) => {
                                if (doc.file.fullPath === fullPath) {
                                    reloadDoc(doc);
                                }
                            });
                            // diffs were cleaned in this file
                            resolve();
                        });
                });
开发者ID:MarcelGerber,项目名称:brackets-git,代码行数:60,代码来源:Utils.ts


示例3: Promise

    return new Promise((resolve) => {

        const folder = getProjectRoot();

        // if we previously tried, assume nothing has changed
        if (writeTestResults[folder]) {
            return resolve(writeTestResults[folder]);
        }

        // create entry for temporary file
        const fileEntry = FileSystem.getFileForPath(folder + ".bracketsGitTemp");

        function finish(bool) {
            // delete the temp file and resolve
            fileEntry.unlink(() => {
                writeTestResults[folder] = bool;
                resolve(bool);
            });
        }

        // try writing some text into the temp file
        Promise.cast(FileUtils.writeText(fileEntry, ""))
            .then(() => finish(true))
            .catch(() => finish(false));
    });
开发者ID:MarcelGerber,项目名称:brackets-git,代码行数:25,代码来源:Utils.ts


示例4: commitAllFiles

function commitAllFiles() {
    // do not return anything here, core expects jquery promise
    Promise.cast(CommandManager.execute("file.saveAll"))
        .then(() => {
            return Git2.resetIndex();
        })
        .then(() => {
            return handleGitCommit(lastCommitMessage, false, COMMIT_MODE.ALL);
        });
}
开发者ID:MarcelGerber,项目名称:brackets-git,代码行数:10,代码来源:Panel.ts


示例5: reloadDoc

export function reloadDoc(doc) {
    return Promise.cast(FileUtils.readAsText(doc.file))
        .then((text) => {
            doc.refreshText(text, new Date());
        })
        .catch((err) => {
            ErrorHandler.logError("Error reloading contents of " + doc.file.fullPath);
            ErrorHandler.logError(err);
        });
}
开发者ID:MarcelGerber,项目名称:brackets-git,代码行数:10,代码来源:Utils.ts


示例6: Promise

 return new Promise((resolve, reject) => {
     // FUTURE: maybe use git commit --file=-
     const fileEntry = FileSystem.getFileForPath(Preferences.get("currentGitRoot") + ".bracketsGitTemp");
     Promise.cast(FileUtils.writeText(fileEntry, message))
         .then(() => {
             args.push("-F", ".bracketsGitTemp");
             return git(args);
         })
         .then((res) => fileEntry.unlink(() => resolve(res)))
         .catch((err) => fileEntry.unlink(() => reject(err)));
 });
开发者ID:MarcelGerber,项目名称:brackets-git,代码行数:11,代码来源:GitCli.ts


示例7: function

ConfigBuilder.prototype.start = function(){
  var current:any;
  var _configBuilder:any = this;
  current = Promise.cast();
  return Promise.map(this.commands, function(callback:any) {
    return current = current.then(function() {
      return callback();
    });
  }).then(function() {
    return start(_configBuilder.toJSON());
  });
}
开发者ID:carlosmarte,项目名称:workflow-amd-karma,代码行数:12,代码来源:index.ts


示例8: get

export function get() {
    if (jsonPromise) {
        return jsonPromise;
    }
    const readPromise = FileUtils.readAsText(FileSystem.getFileForPath(getPackageJsonPath()));
    jsonPromise = Promise.cast(readPromise)
        .then((content) => {
            packageJson = JSON.parse(content);
            return packageJson;
        });
    return jsonPromise;
}
开发者ID:MarcelGerber,项目名称:brackets-git,代码行数:12,代码来源:ExtensionInfo.ts


示例9: refresh

 FileSystem.resolve(Preferences.get("currentGitRoot") + file, (err, fileEntry) => {
     if (err) {
         ErrorHandler.showError(err, "Could not resolve file");
         return;
     }
     Promise.cast(ProjectManager.deleteItem(fileEntry))
         .then(() => {
             refresh();
         })
         .catch((err2) => {
             ErrorHandler.showError(err2, "File deletion failed");
         });
 });
开发者ID:MarcelGerber,项目名称:brackets-git,代码行数:13,代码来源:Panel.ts


示例10: lintFile

function lintFile(filename) {
    const fullPath = Preferences.get("currentGitRoot") + filename;
    let codeInspectionPromise;

    try {
        codeInspectionPromise = CodeInspection.inspectFile(FileSystem.getFileForPath(fullPath));
    } catch (e) {
        ErrorHandler.logError("CodeInspection.inspectFile failed to execute for file " + fullPath);
        ErrorHandler.logError(e);
        codeInspectionPromise = Promise.reject(e);
    }

    return Promise.cast(codeInspectionPromise);
}
开发者ID:MarcelGerber,项目名称:brackets-git,代码行数:14,代码来源:Panel.ts



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
TypeScript bluebird.config函数代码示例发布时间:2022-05-25
下一篇:
TypeScript bluebird.attempt函数代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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