1 | /*!
|
2 | * ignore
|
3 | */
|
4 |
|
5 | ;
|
6 |
|
7 | const assert = require('assert');
|
8 | const mquery = require('mquery');
|
9 |
|
10 | /**
|
11 | * Helper for multiplexing promise implementations
|
12 | *
|
13 | * @api private
|
14 | */
|
15 |
|
16 | const store = {
|
17 | _promise: null
|
18 | };
|
19 |
|
20 | /**
|
21 | * Get the current promise constructor
|
22 | *
|
23 | * @api private
|
24 | */
|
25 |
|
26 | store.get = function() {
|
27 | return store._promise;
|
28 | };
|
29 |
|
30 | /**
|
31 | * Set the current promise constructor
|
32 | *
|
33 | * @api private
|
34 | */
|
35 |
|
36 | store.set = function(lib) {
|
37 | assert.ok(typeof lib === 'function',
|
38 | `mongoose.Promise must be a function, got ${lib}`);
|
39 | store._promise = lib;
|
40 | mquery.Promise = lib;
|
41 | };
|
42 |
|
43 | /*!
|
44 | * Use native promises by default
|
45 | */
|
46 |
|
47 | store.set(global.Promise);
|
48 |
|
49 | module.exports = store;
|