本文整理汇总了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 {};
});
});
}
示例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'
}
};
示例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");
}
});
示例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; });
}
示例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));
}
示例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; });
}
示例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);
}
示例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);
}
}
示例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);
});
}