当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript bluebird.cast函数代码示例

本文整理汇总了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;未经允许,请勿转载。