當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript promise.denodeify函數代碼示例

本文整理匯總了TypeScript中promise.denodeify函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript denodeify函數的具體用法?TypeScript denodeify怎麽用?TypeScript denodeify使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了denodeify函數的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: execute

  execute(environment: env.Environment, argumentList: Array<string>, finished: (env: env.Environment) => void) {
    if(argumentList.length === 0) {
      finished(environment);
      return;
    }
    var newFolder = argumentList[0];
    if(newFolder === "..") {
      this.navigateBack(environment).then((env)=>{
        finished(env);
      });
      return;
    }
    var newPath = path.join(environment.workingDirectory, newFolder);
    var fsExists = Promise.denodeify(fs.exists);
    new Promise(function(resolve, reject){
      fs.exists(newPath, (exists)=>{
        resolve(exists);
      });
    }).then((exists) => {
      if(exists) {
        finished(new env.Environment(newPath));
        return;
      }
      else {
        this.stderr("Path " + newPath + " does not exist");
        finished(environment);
        return;
      }

      new Promise(function(resolve, reject){
        fs.exists(newFolder, (exists)=>{
          resolve(exists);
        });
      }).then((exists) => {
        if(exists) {
          finished(new env.Environment(newFolder));
        } else {
          finished(environment);
        }
      });
    });
  }
開發者ID:schultyy,項目名稱:jsterm,代碼行數:42,代碼來源:command.ts

示例2: require

// dependencies
var CryptoA:any = require("crypto");
var Events:any  = require("events");
var Util:any    = require("util");
var Url:any     = require("url");
var UA:any      = require("universal-analytics");
var debug:any   = require("debug")("ali-mns");

var Promise:any = require("promise");

var Request:{ new (input: RequestInfo, init?: RequestInit): Request; prototype: Request; } = require("request");
Request['requestP'] = Promise.denodeify(Request);
Request['debug'] = false;

var Xml2js:any  = require("xml2js");
Xml2js.parseStringP = Promise.denodeify(Xml2js.parseString);

var XmlBuilder:any = require("xmlbuilder");
開發者ID:InCar,項目名稱:ali-mns,代碼行數:18,代碼來源:ali-mns.ts


注:本文中的promise.denodeify函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。