本文整理汇总了TypeScript中bluebird.onPossiblyUnhandledRejection函数的典型用法代码示例。如果您正苦于以下问题:TypeScript onPossiblyUnhandledRejection函数的具体用法?TypeScript onPossiblyUnhandledRejection怎么用?TypeScript onPossiblyUnhandledRejection使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了onPossiblyUnhandledRejection函数的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: require
import {Question, QuestionTypes} from './types/question.type';
var bodyParser = require('body-parser');
import * as Promise from 'bluebird';
Promise.onPossiblyUnhandledRejection((error) => {
throw error;
});
var database;
var wifiManager = require('./modules/wifi-manager')();
var server = require('./modules/server');
module.exports = (SERVICE_NAME: string, password: string, questions?: Array<Question>, express?, app?, _database?) => {
if (!express) {
express = require('express');
}
if (!app) {
app = express();
}
database = _database;
if (!database) {
database = require('./modules/database')(SERVICE_NAME);
database.init().then(() => {
database.start();
});
}
if (!Array.isArray(questions)) {
if (!questions) {
questions = [];
示例2: invariant
import { processResponse } from '../response/processResponse';
import { RequestError } from '../util/requestError';
import { invariant, isPromise } from '../util/tools';
import {
// @ts-ignore - Exported variable .. cannot be named https://github.com/Microsoft/TypeScript/issues/9944
IAdapterResponse,
IKeyValue,
TDescriptorRequestHook,
TRequestResult
} from '../util/types';
import { ResourceDescriptor } from './descriptor';
// We only quietly consume RequestError's
Promise.onPossiblyUnhandledRejection((err: any, _promise: Promise<any>) => {
if (err instanceof RequestError) {
return;
}
throw err;
});
export const requestForDescriptor = (descriptor: ResourceDescriptor,
options: IKeyValue = {},
callback?: TDescriptorRequestHook | null): Promise<TRequestResult> => {
const store = descriptor.store;
invariant(Boolean(descriptor.adapter), 'requestForDescriptor: no adapter specified');
invariant(descriptor.adapter instanceof BaseAdapter,
`requestForDescriptor: expected BaseAdapter base but found \`${descriptor.adapter!.constructor.name}\``
);
let promise = descriptor.adapter!.invoke(descriptor, options);
示例3: TestRunner
sms.install();
}
Promise.longStackTraces();
}
let dtPath = util.fixPath(path.resolve(argv['path']));
let cpuCores = os.cpus().length;
if (argv.help) {
optimist.help();
process.exit(0);
}
Promise.onPossiblyUnhandledRejection((reason) => {
console.error('Error: Promise.possiblyUnhandledRejection:');
console.dir(reason);
throw reason;
});
let testFull = (process.env['TRAVIS_BRANCH'] ? /\w\/full$/.test(process.env['TRAVIS_BRANCH']) : false);
new TestRunner({
testerPath: util.fixPath(path.dirname(testerPkgPath)),
dtPath: dtPath,
concurrent: (argv['single-thread'] ? 1 : Math.round(cpuCores * .75)),
tscPath: argv['tsc-path'],
tslintConfig: path.join(path.dirname(testerPkgPath), 'conf', 'tslint.json'),
changes: (testFull ? false : argv['changes']),
tests: argv['dry'] ? false : argv['tests'],
lint: argv['dry'] ? false : argv['lint'],
示例4: coroutine2
yield foo;
return bar;
};
const coroutine2 = Bluebird.coroutine<Bar, number, string>(generator2);
barProm = coroutine2(5, "foo");
const coroutineCustomYield = Bluebird.coroutine(generator1, { yieldHandler: (value) => "whatever" });
/*
barProm = Bluebird.spawn<number>(f);
*/
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
BlueBird = Bluebird.getNewLibraryCopy();
BlueBird = Bluebird.noConflict();
Bluebird.onPossiblyUnhandledRejection((reason: any) => {});
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// TODO expand tests to overloads
fooArrProm = Bluebird.all(fooThenArrThen);
fooArrProm = Bluebird.all(fooArrProm);
fooArrProm = Bluebird.all(fooThenArr);
fooArrProm = Bluebird.all(fooArr);
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
objProm = Bluebird.props(objProm);
objProm = Bluebird.props(obj);
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -