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


TypeScript bluebird.onPossiblyUnhandledRejection函数代码示例

本文整理汇总了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 = [];
开发者ID:dudeofawesome,项目名称:wifi-setup,代码行数:31,代码来源:main.ts

示例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);
开发者ID:netarc,项目名称:refrax,代码行数:31,代码来源:requestForDescriptor.ts

示例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'],
开发者ID:rakatyal,项目名称:definition-tester,代码行数:31,代码来源:index.ts

示例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);

// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
开发者ID:csrakowski,项目名称:DefinitelyTyped,代码行数:31,代码来源:bluebird-tests.ts


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