Sha256: 35e19e352386a6957d09fc3fa343b0ff041f182a23baeae1a1d9a02d3f99b48c
Contents?: true
Size: 1.18 KB
Versions: 34
Compression:
Stored size: 1.18 KB
Contents
/** * Duplication of $.extend(), so whole jQuery dont have to be loaded * @param {boolean|Object} deep * @param {Object} target * @param {Object} [source] * @return {Object} */ EasyGem.extend = function (deep, target, source) { var copyIsArray; if (typeof deep !== "boolean") { source = target; target = deep; deep = false; } if (source === undefined) return target; if (typeof target !== "object") { target = {}; } for (var name in source) { if (!source.hasOwnProperty(name)) continue; var trg = target[name]; var src = source[name]; // Prevent never-ending loop if (trg === src) continue; if (deep && src && typeof src === "object") { copyIsArray = Array.isArray(src); if (copyIsArray) { copyIsArray = false; var clone = trg && Array.isArray(trg) ? trg : []; } else { clone = trg && (typeof trg === "object") ? trg : {}; } // Never move original objects, clone them target[name] = EasyGem.extend(deep, clone, src); // Don't bring in undefined values } else if (src !== undefined) { target[name] = src; } } return target; }; EASY.extend = EasyGem.extend;
Version data entries
34 entries across 34 versions & 1 rubygems