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


TypeScript bluebird.promisifyAll函数代码示例

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


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

示例1: removeFromBand

  static removeFromBand(memberName: string, bandName: string) : void {

    var client = Promise.promisifyAll(new SparqlClient(endpoint));
    var updateClient = Promise.promisifyAll(new SparqlClient(updateEndpoint));

    client
      .query(itemsQuery)
      .bind('BandName', "\"" + bandName + "\"@en")
      .bind('MemberName', "\"" + memberName + "\"@en")
      .executeAsync()
      .then(results => {
        var member = [];
        var band = [];

        for (var result of results.results.bindings) {
          member.push(result.Member.value);
          band.push(result.Band.value);
        }

        member = _.uniq(member)[0];
        band = _.uniq(band)[0];

        updateClient
          .query(deleteQuery)
          .bind('Band', band)
          .bind('Member', member)
          .executeAsync()
          .then(() => {
            return {};
          });
      });
  }
开发者ID:miguel76,项目名称:MusicDB,代码行数:32,代码来源:artistSparqlRepository.ts

示例2: function

var setGlobals = function () {
  var Promise = require('bluebird');
  Promise.longStackTraces();
  global.Promise = Promise;

  var Mapstrace = require('mapstrace');
  Promise.promisifyAll(Mapstrace);
  global.PrettyError = function (err, msg, cb) {
    return Mapstrace.build(err, true, function (result) {
      sails.log.error(msg);
      sails.log.error(err.toString() + ':\n' + Mapstrace.stringify(result));
      if (cb) cb();
    })
  };
  process.on("unhandledRejection", function (error, promise) {
    PrettyError(error, '[Bluebird]Unhandled rejection:', function () {
      sails.log.error('From promise:', promise)
    });
  });
  process.on("uncaughtException", function (error) {
    PrettyError(error, 'An uncaught exception has caused Node.js to crash!', function () {
      process.exit(1);
    });
  });

    if (sails.config.environment === 'production') {
        sails.hooks.http.app.locals.assetPrefix = '/assets'
    } else {
        sails.hooks.http.app.locals.assetPrefix = '/assets'
    }
};
开发者ID:ModMountain,项目名称:web-old,代码行数:31,代码来源:bootstrap.ts

示例3: function

fp.discover().forEach(function (entry)
        {
            console.log(sprintf("%8d %-8s %-8s %-32s", entry.handle, entry.driver_type,  entry.driver, entry.driver_detail));

            if (verbose)
            {
                var reader = promise.promisifyAll(fp.get_reader(entry.handle));
                console.log(sprintf("\t Enroll stages: %d", reader.enroll_stages));
                console.log(sprintf("\t Supports imaging: %s", reader.supports_imaging));
                console.log(sprintf("\t Supports identification: %s", reader.supports_identification));
                console.log(sprintf("\t Image height: %d", reader.img_height));
                console.log(sprintf("\t Image width: %d", reader.img_width));
                reader.start_enrollAsync().then(
                    function (result)
                    {
                        console.log(result);
                    }
                    )
                    .catch(
                        function (err)
                        {
                            console.log("ERR");
                            console.log(err);
                        }
                    )

                    console.log("DONE");
            }
        });
开发者ID:no2chem,项目名称:node-libfprint,代码行数:29,代码来源:fprint_enroll.ts

示例4: EditDescription

    EditDescription(idea: IIdea, user: ILoggedOnUser): Promise<any> {
        var docClient = Bluebird.promisifyAll(new AWS.DynamoDB.DocumentClient()) as AWS.DocumentAsyncClient;
        var ideaEntity = ideaPrePostProcessor.PreProcess(idea);

        return this.CanModifyIdea(ideaEntity, user)
            .then(canModify => {
                if (!canModify) {
                    return Promise.reject({ message: "Action is not authorized." })
                }

                var params = {
                    TableName: tableName,
                    Key: {
                        id: ideaEntity.id
                    },
                    UpdateExpression: "set description = :d",
                    ExpressionAttributeValues: {
                        ":d": ideaEntity.description
                    },
                    ReturnValues: "UPDATED_NEW",
                    AttributeUpdates: undefined
                };

                return docClient.updateAsync(params);
            })
            .then(data => { return data; });
    }
开发者ID:hakant,项目名称:HackathonPlannerAPI,代码行数:27,代码来源:IdeaRepository.ts

示例5: constructor

 constructor(opts: ILoggerOpts, logglyOpts : ILoggerLogglyOpts) {
     var tags = [opts.pack.name, opts.pack.ver].concat(opts.tags).filter((f) => !!f);
     var logOpts = {
         token: logglyOpts.token,
         subdomain: logglyOpts.subdomain,
         tags: tags,
         json:true
     };
     this.loggly = promise.promisifyAll(loggly.createClient(logOpts));
 }
开发者ID:data-avail,项目名称:da-helpers,代码行数:10,代码来源:logger-loggly.ts

示例6: UpsertIdea

    UpsertIdea(idea: IIdea, user: ILoggedOnUser): Promise<any> {
        var docClient = Bluebird.promisifyAll(new AWS.DynamoDB.DocumentClient()) as AWS.DocumentAsyncClient;
        var ideaEntity = ideaPrePostProcessor.PreProcess(idea);

        var params = {
            TableName: tableName,
            Item: ideaEntity
        };

        return docClient.putAsync(params)
            .then(data => { return data; });
    }
开发者ID:hakant,项目名称:HackathonPlannerAPI,代码行数:12,代码来源:IdeaRepository.ts

示例7: constructor

 constructor(wsdl: WSDL, endpoint?: string, options?: IOptions) {
   super();
   options = options || {};
   this.wsdl = wsdl;
   this._initializeOptions(options);
   this._initializeServices(endpoint);
   this.httpClient = options.httpClient || new HttpClient(options);
   const promiseOptions: BluebirdPromise.PromisifyAllOptions<this> = { multiArgs: true };
   if (options.overridePromiseSuffix) {
     promiseOptions.suffix = options.overridePromiseSuffix;
   }
   BluebirdPromise.promisifyAll(this, promiseOptions);
 }
开发者ID:vpulim,项目名称:node-soap,代码行数:13,代码来源:client.ts

示例8: asyncAwait

async function asyncAwait():Promise<void> {
    let service:any = new Foursquare(undefined, "xxx", "xxx"); // Replace "xxx" with valid credentials

    Promise.promisifyAll(service);

    try {
        let pois:POI[] = await service.getNearbyPOIsAsync(49.4557091, 8.5279138, 3000, "sparkasse", ["bank"]);
        printPOIs(pois);
        pois = await service.getNearbyPOIsAsync(49.4557091, 8.5279138, 800, null, ["restaurant"]);
        printPOIs(pois);
    } catch(err) {
        console.log(err);
    }
}
开发者ID:CloudRail,项目名称:cloudrail-si-node-sdk,代码行数:14,代码来源:index.ts

示例9: promiseBased

function promiseBased():void {
    let service:any = new Foursquare(undefined, "xxx", "xxx"); // Replace "xxx" with valid credentials

    Promise.promisifyAll(service);

    service.getNearbyPOIsAsync(49.4557091, 8.5279138, 3000, "sparkasse", ["bank"]).then((pois:POI[]) => {
        printPOIs(pois);
        return service.getNearbyPOIsAsync(49.4557091, 8.5279138, 800, null, ["restaurant"]);
    }).then((pois:POI[]) => {
        printPOIs(pois);
    }).catch((err:Error) => {
        console.log(err);
    });
}
开发者ID:CloudRail,项目名称:cloudrail-si-node-sdk,代码行数:14,代码来源:index.ts


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