-
Notifications
You must be signed in to change notification settings - Fork 17
/
promise.js
75 lines (68 loc) · 2.89 KB
/
promise.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
function factory() {
class Bluebird extends Promise { }
Bluebird.TypeError = TypeError; // Bluebird.TypeError is used in tests
require('./promiseErrors/OperationalError')(Bluebird);
require('./promiseErrors/AggregateError')(Bluebird);
require('./promiseErrors/TimeoutError')(Bluebird);
require('./promiseFns/delay')(Bluebird);
require('./promiseFns/timeout')(Bluebird);
require('./promiseFns/tap')(Bluebird);
require('./promiseFns/props')(Bluebird);
require('./promiseFns/spread')(Bluebird);
require('./promiseFns/promisify')(Bluebird);
require('./promiseFns/join')(Bluebird);
require('./promiseFns/try')(Bluebird);
require('./promiseFns/method')(Bluebird);
require('./promiseFns/each')(Bluebird);
require('./promiseFns/mapSeries')(Bluebird);
require('./promiseFns/map')(Bluebird);
require('./promiseFns/filter')(Bluebird);
require('./promiseFns/get')(Bluebird);
require('./promiseFns/call')(Bluebird);
require('./promiseFns/reflect')(Bluebird);
require('./promiseFns/finally')(Bluebird);
require('./promiseFns/return')(Bluebird);
require('./promiseFns/reduce')(Bluebird);
require('./promiseFns/throw')(Bluebird);
require('./promiseFns/catchReturn')(Bluebird);
require('./promiseFns/catchThrow')(Bluebird);
require('./promiseFns/catch')(Bluebird);
require('./promiseFns/error')(Bluebird);
require('./promiseFns/coroutine')(Bluebird);
require('./promiseFns/cast')(Bluebird);
require('./promiseFns/asCallback')(Bluebird);
require('./promiseFns/noConflict')(Bluebird);
require('./promiseFns/defer')(Bluebird);
require('./promiseFns/done')(Bluebird);
require('./promiseFns/suppressUnhandledRejections')(Bluebird);
require('./promiseFns/onPossiblyUnhandledRejection')(Bluebird);
require('./promiseFns/some')(Bluebird);
require('./promiseFns/any')(Bluebird);
require('./promiseFns/disposer')(Bluebird);
require('./promiseFns/using')(Bluebird);
require('./promiseFns/tapCatch')(Bluebird);
const logger = {log: console.warn, active: true};
//const warningThen = require("./promiseFns/then")(Bluebird, logger);
require('./promiseFns/setScheduler')(Bluebird);
Bluebird.config = (obj) => {
// if(!obj.warnings) {
// logger.active = false;
// } else {
// logger.active = true;
// }
};
Bluebird.longStackTraces = () => {}; // long stack traces by debugger and not bb
Bluebird.hasLongStackTraces = () => false;
// converted from async to traditional .then() since native async/await return native promises.
Bluebird.prototype.all = function all() {
return this.then(r => Bluebird.all(r));
};
return Bluebird;
}
const copy = factory();
copy.getNewLibraryCopy = () => {
const newCopy = factory();
newCopy.getNewLibraryCopy = copy.getNewLibraryCopy;
return newCopy;
};
module.exports = copy;