1
0
Fork 0
mirror of https://github.com/Radarr/Radarr synced 2024-12-25 01:11:43 +00:00

converted underscore.mixin.deepExtend to proper AMD module.

This commit is contained in:
Keivan Beigi 2013-07-15 17:46:20 -07:00
parent 28a919e74a
commit e0aceb98d2

View file

@ -3,9 +3,14 @@
*
* Based on https://gist.github.com/echong/3861963
*/
(function() {
var arrays, basicObjects, deepClone, deepExtend, deepExtendCouple, isBasicObject,
__slice = [].slice;
define(
[
'underscore'
], function (_) {
var arrays, basicObjects, deepClone, deepExtend, deepExtendCouple, isBasicObject, __slice =
[
].slice;
deepClone = function (obj) {
var func, isArr;
@ -25,16 +30,21 @@
func = function (memo, value, key) {
if (isArr) {
memo.push(deepClone(value));
} else {
}
else {
memo[key] = deepClone(value);
}
return memo;
};
return _.reduce(obj, func, isArr ? [] : {});
return _.reduce(obj, func, isArr ?
[
] :{});
};
isBasicObject = function (object) {
if (object == null) return false;
if (object == null) {
return false;
}
return (object.prototype === {}.prototype || object.prototype === Object.prototype) && _.isObject(object) && !_.isArray(object) && !_.isFunction(object) && !_.isDate(object) && !_.isRegExp(object) && !_.isArguments(object);
};
@ -80,7 +90,9 @@
deepExtend = function () {
var finalObj, maxDepth, objects, _i;
objects = 2 <= arguments.length ? __slice.call(arguments, 0, _i = arguments.length - 1) : (_i = 0, []), maxDepth = arguments[_i++];
objects = 2 <= arguments.length ? __slice.call(arguments, 0, _i = arguments.length - 1) :(_i = 0,
[
]), maxDepth = arguments[_i++];
if (!_.isNumber(maxDepth)) {
objects.push(maxDepth);
maxDepth = 20;
@ -98,7 +110,6 @@
return finalObj;
};
require(['underscore'], function (_) {
_.mixin({
deepClone : deepClone,
@ -109,4 +120,3 @@
});
});
}).call(this);