Updated mongoose

This commit is contained in:
Dobie Wollert
2015-11-24 22:08:58 -08:00
parent 71a05fb732
commit 8b5827c970
618 changed files with 122299 additions and 37754 deletions

96
node_modules/mongoose/lib/promise.js generated vendored
View File

@ -1,9 +1,9 @@
/*!
* Module dependencies
*/
var MPromise = require('mpromise');
var util = require('util');
/**
* Promise constructor.
@ -13,29 +13,57 @@ var MPromise = require('mpromise');
* var query = Candy.find({ bar: true });
* var promise = query.exec();
*
* DEPRECATED. Mongoose 5.0 will use native promises by default (or bluebird,
* if native promises are not present) but still
* support plugging in your own ES6-compatible promises library. Mongoose 5.0
* will **not** support mpromise.
*
* @param {Function} fn a function which will be called when the promise is resolved that accepts `fn(err, ...){}` as signature
* @inherits mpromise https://github.com/aheckmann/mpromise
* @inherits NodeJS EventEmitter http://nodejs.org/api/events.html#events_class_events_eventemitter
* @event `err`: Emits when the promise is rejected
* @event `complete`: Emits when the promise is fulfilled
* @api public
* @deprecated
*/
function Promise (fn) {
function Promise(fn) {
MPromise.call(this, fn);
}
/**
* ES6-style promise constructor wrapper around mpromise.
*
* @param {Function} resolver
* @return {Promise} new promise
* @api public
*/
Promise.ES6 = function(resolver) {
var promise = new Promise();
// No try/catch for backwards compatibility
resolver(
function() {
promise.complete.apply(promise, arguments);
},
function(e) {
promise.error(e);
});
return promise;
};
/*!
* Inherit from mpromise
*/
Promise.prototype = Object.create(MPromise.prototype, {
constructor: {
value: Promise
, enumerable: false
, writable: true
, configurable: true
}
constructor: {
value: Promise,
enumerable: false,
writable: true,
configurable: true
}
});
/*!
@ -84,10 +112,15 @@ Promise.FAILURE = 'err';
* @return {Promise} this
*/
Promise.prototype.error = function (err) {
if (!(err instanceof Error)) err = new Error(err);
Promise.prototype.error = function(err) {
if (!(err instanceof Error)) {
if (err instanceof Object) {
err = util.inspect(err);
}
err = new Error(err);
}
return this.reject(err);
}
};
/**
* Resolves this promise to a rejected state if `err` is passed or a fulfilled state if no `err` is passed.
@ -101,17 +134,18 @@ Promise.prototype.error = function (err) {
* @param {Error} [err] error or null
* @param {Object} [val] value to fulfill the promise with
* @api public
* @deprecated
*/
Promise.prototype.resolve = function (err, val) {
Promise.prototype.resolve = function(err) {
if (err) return this.error(err);
return this.fulfill(val);
}
return this.fulfill.apply(this, Array.prototype.slice.call(arguments, 1));
};
/**
* Adds a single function as a listener to both err and complete.
*
* It will be executed with traditional node.js argument position when the promise is resolved.
* It will be executed with traditional node.js argument position when the promise is resolved.
*
* promise.addBack(function (err, args...) {
* if (err) return handleError(err);
@ -120,9 +154,12 @@ Promise.prototype.resolve = function (err, val) {
*
* Alias of [mpromise#onResolve](https://github.com/aheckmann/mpromise#onresolve).
*
* _Deprecated. Use `onResolve` instead._
*
* @method addBack
* @param {Function} listener
* @return {Promise} this
* @deprecated
*/
Promise.prototype.addBack = Promise.prototype.onResolve;
@ -130,11 +167,26 @@ Promise.prototype.addBack = Promise.prototype.onResolve;
/**
* Fulfills this promise with passed arguments.
*
* Alias of [mpromise#fulfill](https://github.com/aheckmann/mpromise#fulfill).
*
* @method complete
* @method fulfill
* @receiver Promise
* @see https://github.com/aheckmann/mpromise#fulfill
* @param {any} args
* @api public
* @deprecated
*/
/**
* Fulfills this promise with passed arguments.
*
* Alias of [mpromise#fulfill](https://github.com/aheckmann/mpromise#fulfill).
*
* _Deprecated. Use `fulfill` instead._
*
* @method complete
* @receiver Promise
* @param {any} args
* @api public
* @deprecated
*/
Promise.prototype.complete = MPromise.prototype.fulfill;
@ -144,10 +196,13 @@ Promise.prototype.complete = MPromise.prototype.fulfill;
*
* Alias of [mpromise#onFulfill](https://github.com/aheckmann/mpromise#onfulfill).
*
* _Deprecated. Use `onFulfill` instead._
*
* @method addCallback
* @param {Function} listener
* @return {Promise} this
* @api public
* @deprecated
*/
Promise.prototype.addCallback = Promise.prototype.onFulfill;
@ -157,10 +212,13 @@ Promise.prototype.addCallback = Promise.prototype.onFulfill;
*
* Alias of [mpromise#onReject](https://github.com/aheckmann/mpromise#onreject).
*
* _Deprecated. Use `onReject` instead._
*
* @method addErrback
* @param {Function} listener
* @return {Promise} this
* @api public
* @deprecated
*/
Promise.prototype.addErrback = Promise.prototype.onReject;
@ -195,6 +253,7 @@ Promise.prototype.addErrback = Promise.prototype.onReject;
* @param {Function} onFulFill
* @param {Function} onReject
* @return {Promise} newPromise
* @deprecated
*/
/**
@ -222,6 +281,7 @@ Promise.prototype.addErrback = Promise.prototype.onReject;
* @see mpromise#end https://github.com/aheckmann/mpromise#end
* @method end
* @memberOf Promise
* @deprecated
*/
/*!