export function deepAssign (target) {
var sources = [], len = arguments.length - 1;
while ( len-- > 0 ) sources[ len ] = arguments[ len + 1 ];
if (isObject(target)) {
each(sources, function (source) {
each(source, function (data, key) {
if (isObject(data)) {
if (!target[key] || !isObject(target[key])) {
target[key] = {}
}
deepAssign(target[key], data)
} else {
target[key] = data
}
})
})
return target
} else {
throw new TypeError('Expected an object literal.')
}
}
export function isObject (object) {
return object !== null && typeof object === 'object'
&& (object.constructor === Object || Object.prototype.toString.call(object) === '[object Object]')
}
export function each (collection, callback) {
if (isObject(collection)) {
var keys = Object.keys(collection)
for (var i = 0; i < keys.length; i++) {
callback(collection[ keys[i] ], keys[i], collection)
}
} else if (Array.isArray(collection)) {
for (var i$1 = 0; i$1 < collection.length; i$1++) {
callback(collection[i$1], i$1, collection)
}
} else {
throw new TypeError('Expected either an array or object literal.')
}
}
export var nextUniqueId = (function () {
var uid = 0
return function () { return uid++; }
})()
|