UNPKG

677 BJavaScriptView Raw
1/*!
2 * ignore
3 */
4
5'use strict';
6
7const assert = require('assert');
8const mquery = require('mquery');
9
10/**
11 * Helper for multiplexing promise implementations
12 *
13 * @api private
14 */
15
16const store = {
17 _promise: null
18};
19
20/**
21 * Get the current promise constructor
22 *
23 * @api private
24 */
25
26store.get = function() {
27 return store._promise;
28};
29
30/**
31 * Set the current promise constructor
32 *
33 * @api private
34 */
35
36store.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
47store.set(global.Promise);
48
49module.exports = store;