mirror of
https://github.com/mgerb/mywebsite
synced 2026-01-12 02:42:48 +00:00
updated bunch of file paths and changed the way posts are loaded
This commit is contained in:
183
node_modules/mongoose/lib/utils.js
generated
vendored
183
node_modules/mongoose/lib/utils.js
generated
vendored
@@ -19,7 +19,7 @@ var Document;
|
||||
* @api private
|
||||
*/
|
||||
|
||||
exports.toCollectionName = function (name, options) {
|
||||
exports.toCollectionName = function(name, options) {
|
||||
options = options || {};
|
||||
if ('system.profile' === name) return name;
|
||||
if ('system.indexes' === name) return name;
|
||||
@@ -107,16 +107,16 @@ var uncountables = exports.uncountables;
|
||||
* @api private
|
||||
*/
|
||||
|
||||
function pluralize (str) {
|
||||
var rule, found;
|
||||
if (!~uncountables.indexOf(str.toLowerCase())){
|
||||
found = rules.filter(function(rule){
|
||||
function pluralize(str) {
|
||||
var found;
|
||||
if (!~uncountables.indexOf(str.toLowerCase())) {
|
||||
found = rules.filter(function(rule) {
|
||||
return str.match(rule[0]);
|
||||
});
|
||||
if (found[0]) return str.replace(found[0][0], found[0][1]);
|
||||
}
|
||||
return str;
|
||||
};
|
||||
}
|
||||
|
||||
/*!
|
||||
* Determines if `a` and `b` are deep equal.
|
||||
@@ -129,7 +129,7 @@ function pluralize (str) {
|
||||
* @api private
|
||||
*/
|
||||
|
||||
exports.deepEqual = function deepEqual (a, b) {
|
||||
exports.deepEqual = function deepEqual(a, b) {
|
||||
if (a === b) return true;
|
||||
|
||||
if (a instanceof Date && b instanceof Date)
|
||||
@@ -150,7 +150,7 @@ exports.deepEqual = function deepEqual (a, b) {
|
||||
return a == b;
|
||||
|
||||
if (a === null || b === null || a === undefined || b === undefined)
|
||||
return false
|
||||
return false;
|
||||
|
||||
if (a.prototype !== b.prototype) return false;
|
||||
|
||||
@@ -212,7 +212,7 @@ exports.deepEqual = function deepEqual (a, b) {
|
||||
* @api private
|
||||
*/
|
||||
|
||||
exports.clone = function clone (obj, options) {
|
||||
exports.clone = function clone(obj, options) {
|
||||
if (obj === undefined || obj === null)
|
||||
return obj;
|
||||
|
||||
@@ -258,15 +258,15 @@ var clone = exports.clone;
|
||||
* ignore
|
||||
*/
|
||||
|
||||
function cloneObject (obj, options) {
|
||||
var retainKeyOrder = options && options.retainKeyOrder
|
||||
, minimize = options && options.minimize
|
||||
, ret = {}
|
||||
, hasKeys
|
||||
, keys
|
||||
, val
|
||||
, k
|
||||
, i
|
||||
function cloneObject(obj, options) {
|
||||
var retainKeyOrder = options && options.retainKeyOrder,
|
||||
minimize = options && options.minimize,
|
||||
ret = {},
|
||||
hasKeys,
|
||||
keys,
|
||||
val,
|
||||
k,
|
||||
i;
|
||||
|
||||
if (retainKeyOrder) {
|
||||
for (k in obj) {
|
||||
@@ -297,14 +297,14 @@ function cloneObject (obj, options) {
|
||||
return minimize
|
||||
? hasKeys && ret
|
||||
: ret;
|
||||
};
|
||||
}
|
||||
|
||||
function cloneArray (arr, options) {
|
||||
function cloneArray(arr, options) {
|
||||
var ret = [];
|
||||
for (var i = 0, l = arr.length; i < l; i++)
|
||||
ret.push(clone(arr[i], options));
|
||||
return ret;
|
||||
};
|
||||
}
|
||||
|
||||
/*!
|
||||
* Shallow copies defaults into options.
|
||||
@@ -315,10 +315,10 @@ function cloneArray (arr, options) {
|
||||
* @api private
|
||||
*/
|
||||
|
||||
exports.options = function (defaults, options) {
|
||||
var keys = Object.keys(defaults)
|
||||
, i = keys.length
|
||||
, k ;
|
||||
exports.options = function(defaults, options) {
|
||||
var keys = Object.keys(defaults),
|
||||
i = keys.length,
|
||||
k;
|
||||
|
||||
options = options || {};
|
||||
|
||||
@@ -338,7 +338,7 @@ exports.options = function (defaults, options) {
|
||||
* @api private
|
||||
*/
|
||||
|
||||
exports.random = function () {
|
||||
exports.random = function() {
|
||||
return Math.random().toString().substr(3);
|
||||
};
|
||||
|
||||
@@ -350,10 +350,10 @@ exports.random = function () {
|
||||
* @api private
|
||||
*/
|
||||
|
||||
exports.merge = function merge (to, from) {
|
||||
var keys = Object.keys(from)
|
||||
, i = keys.length
|
||||
, key;
|
||||
exports.merge = function merge(to, from) {
|
||||
var keys = Object.keys(from),
|
||||
i = keys.length,
|
||||
key;
|
||||
|
||||
while (i--) {
|
||||
key = keys[i];
|
||||
@@ -371,6 +371,49 @@ exports.merge = function merge (to, from) {
|
||||
|
||||
var toString = Object.prototype.toString;
|
||||
|
||||
/*!
|
||||
* Applies toObject recursively.
|
||||
*
|
||||
* @param {Document|Array|Object} obj
|
||||
* @return {Object}
|
||||
* @api private
|
||||
*/
|
||||
|
||||
exports.toObject = function toObject(obj) {
|
||||
var ret;
|
||||
|
||||
if (exports.isNullOrUndefined(obj)) {
|
||||
return obj;
|
||||
}
|
||||
|
||||
if (obj instanceof Document) {
|
||||
return obj.toObject();
|
||||
}
|
||||
|
||||
if (Array.isArray(obj)) {
|
||||
ret = [];
|
||||
|
||||
for (var i = 0, len = obj.length; i < len; ++i) {
|
||||
ret.push(toObject(obj[i]));
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
if ((obj.constructor && exports.getFunctionName(obj.constructor) === 'Object') ||
|
||||
(!obj.constructor && exports.isObject(obj))) {
|
||||
ret = {};
|
||||
|
||||
for (var k in obj) {
|
||||
ret[k] = toObject(obj[k]);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
return obj;
|
||||
};
|
||||
|
||||
/*!
|
||||
* Determines if `arg` is an object.
|
||||
*
|
||||
@@ -379,9 +422,12 @@ var toString = Object.prototype.toString;
|
||||
* @return {Boolean}
|
||||
*/
|
||||
|
||||
exports.isObject = function (arg) {
|
||||
exports.isObject = function(arg) {
|
||||
if (Buffer.isBuffer(arg)) {
|
||||
return true;
|
||||
}
|
||||
return '[object Object]' == toString.call(arg);
|
||||
}
|
||||
};
|
||||
|
||||
/*!
|
||||
* A faster Array.prototype.slice.call(arguments) alternative
|
||||
@@ -401,20 +447,20 @@ exports.args = sliced;
|
||||
* @api private
|
||||
*/
|
||||
|
||||
exports.tick = function tick (callback) {
|
||||
exports.tick = function tick(callback) {
|
||||
if ('function' !== typeof callback) return;
|
||||
return function () {
|
||||
return function() {
|
||||
try {
|
||||
callback.apply(this, arguments);
|
||||
} catch (err) {
|
||||
// only nextTick on err to get out of
|
||||
// the event loop and avoid state corruption.
|
||||
process.nextTick(function () {
|
||||
process.nextTick(function() {
|
||||
throw err;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
/*!
|
||||
* Returns if `v` is a mongoose object that has a `toObject()` method we can use.
|
||||
@@ -425,7 +471,7 @@ exports.tick = function tick (callback) {
|
||||
* @api private
|
||||
*/
|
||||
|
||||
exports.isMongooseObject = function (v) {
|
||||
exports.isMongooseObject = function(v) {
|
||||
Document || (Document = require('./document'));
|
||||
MongooseArray || (MongooseArray = require('./types').Array);
|
||||
MongooseBuffer || (MongooseBuffer = require('./types').Buffer);
|
||||
@@ -443,7 +489,7 @@ var isMongooseObject = exports.isMongooseObject;
|
||||
* @api private
|
||||
*/
|
||||
|
||||
exports.expires = function expires (object) {
|
||||
exports.expires = function expires(object) {
|
||||
if (!(object && 'Object' == object.constructor.name)) return;
|
||||
if (!('expires' in object)) return;
|
||||
|
||||
@@ -461,12 +507,15 @@ exports.expires = function expires (object) {
|
||||
* Populate options constructor
|
||||
*/
|
||||
|
||||
function PopulateOptions (path, select, match, options, model) {
|
||||
function PopulateOptions(path, select, match, options, model, subPopulate) {
|
||||
this.path = path;
|
||||
this.match = match;
|
||||
this.select = select;
|
||||
this.options = options;
|
||||
this.model = model;
|
||||
if (typeof subPopulate === 'object') {
|
||||
this.populate = subPopulate;
|
||||
}
|
||||
this._docs = {};
|
||||
}
|
||||
|
||||
@@ -480,7 +529,7 @@ exports.PopulateOptions = PopulateOptions;
|
||||
* populate helper
|
||||
*/
|
||||
|
||||
exports.populate = function populate (path, select, model, match, options) {
|
||||
exports.populate = function populate(path, select, model, match, options, subPopulate) {
|
||||
// The order of select/conditions args is opposite Model.find but
|
||||
// necessary to keep backward compatibility (select could be
|
||||
// an array, string, or object literal).
|
||||
@@ -492,7 +541,7 @@ exports.populate = function populate (path, select, model, match, options) {
|
||||
}
|
||||
|
||||
if (Array.isArray(path)) {
|
||||
return path.map(function(o){
|
||||
return path.map(function(o) {
|
||||
return exports.populate(o)[0];
|
||||
});
|
||||
}
|
||||
@@ -502,6 +551,7 @@ exports.populate = function populate (path, select, model, match, options) {
|
||||
options = path.options;
|
||||
select = path.select;
|
||||
model = path.model;
|
||||
subPopulate = path.populate;
|
||||
path = path.path;
|
||||
}
|
||||
} else if ('string' !== typeof model && 'function' !== typeof model) {
|
||||
@@ -514,14 +564,18 @@ exports.populate = function populate (path, select, model, match, options) {
|
||||
throw new TypeError('utils.populate: invalid path. Expected string. Got typeof `' + typeof path + '`');
|
||||
}
|
||||
|
||||
if (typeof subPopulate === 'object') {
|
||||
subPopulate = exports.populate(subPopulate);
|
||||
}
|
||||
|
||||
var ret = [];
|
||||
var paths = path.split(' ');
|
||||
for (var i = 0; i < paths.length; ++i) {
|
||||
ret.push(new PopulateOptions(paths[i], select, match, options, model));
|
||||
ret.push(new PopulateOptions(paths[i], select, match, options, model, subPopulate));
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
};
|
||||
|
||||
/*!
|
||||
* Return the value of `obj` at the given `path`.
|
||||
@@ -530,9 +584,9 @@ exports.populate = function populate (path, select, model, match, options) {
|
||||
* @param {Object} obj
|
||||
*/
|
||||
|
||||
exports.getValue = function (path, obj, map) {
|
||||
exports.getValue = function(path, obj, map) {
|
||||
return mpath.get(path, obj, '_doc', map);
|
||||
}
|
||||
};
|
||||
|
||||
/*!
|
||||
* Sets the value of `obj` at the given `path`.
|
||||
@@ -542,9 +596,9 @@ exports.getValue = function (path, obj, map) {
|
||||
* @param {Object} obj
|
||||
*/
|
||||
|
||||
exports.setValue = function (path, val, obj, map) {
|
||||
exports.setValue = function(path, val, obj, map) {
|
||||
mpath.set(path, val, obj, '_doc', map);
|
||||
}
|
||||
};
|
||||
|
||||
/*!
|
||||
* Returns an array of values from object `o`.
|
||||
@@ -555,17 +609,17 @@ exports.setValue = function (path, val, obj, map) {
|
||||
*/
|
||||
|
||||
exports.object = {};
|
||||
exports.object.vals = function vals (o) {
|
||||
var keys = Object.keys(o)
|
||||
, i = keys.length
|
||||
, ret = [];
|
||||
exports.object.vals = function vals(o) {
|
||||
var keys = Object.keys(o),
|
||||
i = keys.length,
|
||||
ret = [];
|
||||
|
||||
while (i--) {
|
||||
ret.push(o[keys[i]]);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
};
|
||||
|
||||
/*!
|
||||
* @see exports.options
|
||||
@@ -581,9 +635,9 @@ exports.object.shallowCopy = exports.options;
|
||||
*/
|
||||
|
||||
var hop = Object.prototype.hasOwnProperty;
|
||||
exports.object.hasOwnProperty = function (obj, prop) {
|
||||
exports.object.hasOwnProperty = function(obj, prop) {
|
||||
return hop.call(obj, prop);
|
||||
}
|
||||
};
|
||||
|
||||
/*!
|
||||
* Determine if `val` is null or undefined
|
||||
@@ -591,9 +645,9 @@ exports.object.hasOwnProperty = function (obj, prop) {
|
||||
* @return {Boolean}
|
||||
*/
|
||||
|
||||
exports.isNullOrUndefined = function (val) {
|
||||
return null == val
|
||||
}
|
||||
exports.isNullOrUndefined = function(val) {
|
||||
return null == val;
|
||||
};
|
||||
|
||||
/*!
|
||||
* ignore
|
||||
@@ -612,10 +666,10 @@ exports.array = {};
|
||||
* @private
|
||||
*/
|
||||
|
||||
exports.array.flatten = function flatten (arr, filter, ret) {
|
||||
exports.array.flatten = function flatten(arr, filter, ret) {
|
||||
ret || (ret = []);
|
||||
|
||||
arr.forEach(function (item) {
|
||||
arr.forEach(function(item) {
|
||||
if (Array.isArray(item)) {
|
||||
flatten(item, filter, ret);
|
||||
} else {
|
||||
@@ -674,7 +728,7 @@ exports.array.unique = function(arr) {
|
||||
*/
|
||||
|
||||
exports.buffer = {};
|
||||
exports.buffer.areEqual = function (a, b) {
|
||||
exports.buffer.areEqual = function(a, b) {
|
||||
if (!Buffer.isBuffer(a)) return false;
|
||||
if (!Buffer.isBuffer(b)) return false;
|
||||
if (a.length !== b.length) return false;
|
||||
@@ -706,9 +760,9 @@ exports.decorate = function(destination, source) {
|
||||
*/
|
||||
|
||||
exports.mergeClone = function(to, from) {
|
||||
var keys = Object.keys(from)
|
||||
, i = keys.length
|
||||
, key
|
||||
var keys = Object.keys(from),
|
||||
i = keys.length,
|
||||
key;
|
||||
|
||||
while (i--) {
|
||||
key = keys[i];
|
||||
@@ -741,4 +795,3 @@ exports.each = function(arr, fn) {
|
||||
fn(arr[i]);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user