summaryrefslogtreecommitdiffstats
path: root/node_modules/mongoose/lib/promise_provider.js
blob: 3febf3687844de8252bbae6cd0d0913952755fa2 (plain) (blame)
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
/*!
 * ignore
 */

'use strict';

const assert = require('assert');
const mquery = require('mquery');

/**
 * Helper for multiplexing promise implementations
 *
 * @api private
 */

const store = {
  _promise: null
};

/**
 * Get the current promise constructor
 *
 * @api private
 */

store.get = function() {
  return store._promise;
};

/**
 * Set the current promise constructor
 *
 * @api private
 */

store.set = function(lib) {
  assert.ok(typeof lib === 'function',
    `mongoose.Promise must be a function, got ${lib}`);
  store._promise = lib;
  mquery.Promise = lib;
};

/*!
 * Use native promises by default
 */

store.set(global.Promise);

module.exports = store;