arnaucube
arnaucube/thoughtsPublic Self-hosted repository
thoughts/node_modules/mongoose/lib/promise_provider.js
node_modules/mongoose/lib/promise_provider.jsRaw
 1/*!
 2 * Module dependencies.
 3 */
 4
 5var MPromise = require('./promise');
 6
 7/**
 8 * Helper for multiplexing promise implementations
 9 *
10 * @api private
11 */
12
13var Promise = {
14  _promise: MPromise
15};
16
17/**
18 * Get the current promise constructor
19 *
20 * @api private
21 */
22Promise.get = function() {
23  return Promise._promise;
24};
25
26/**
27 * Set the current promise constructor
28 *
29 * @api private
30 */
31
32Promise.set = function(lib) {
33  if (lib === MPromise) {
34    return Promise.reset();
35  }
36  Promise._promise = require('./ES6Promise');
37  Promise._promise.use(lib);
38  require('mquery').Promise = Promise._promise.ES6;
39};
40
41/**
42 * Resets to using mpromise
43 *
44 * @api private
45 */
46
47Promise.reset = function() {
48  Promise._promise = MPromise;
49};
50
51module.exports = Promise;