33 lines
743 B
JavaScript
33 lines
743 B
JavaScript
|
(function() {
|
||
|
var __slice = [].slice,
|
||
|
__hasProp = {}.hasOwnProperty;
|
||
|
|
||
|
this.extend = function() {
|
||
|
var destination, k, source, sources, v, _i, _len;
|
||
|
|
||
|
destination = arguments[0], sources = 2 <= arguments.length ? __slice.call(arguments, 1) : [];
|
||
|
for (_i = 0, _len = sources.length; _i < _len; _i++) {
|
||
|
source = sources[_i];
|
||
|
for (k in source) {
|
||
|
v = source[k];
|
||
|
destination[k] = v;
|
||
|
}
|
||
|
}
|
||
|
return destination;
|
||
|
};
|
||
|
|
||
|
this.is_empty = function(obj) {
|
||
|
var key;
|
||
|
|
||
|
if (Array.isArray(obj) || typeof obj === 'string') {
|
||
|
return obj.length === 0;
|
||
|
}
|
||
|
for (key in obj) {
|
||
|
if (!__hasProp.call(obj, key)) continue;
|
||
|
return false;
|
||
|
}
|
||
|
return true;
|
||
|
};
|
||
|
|
||
|
}).call(this);
|