3 var isExtendable = require('is-extendable');
4 var forIn = require('for-in');
6 function mixinDeep(target, objects) {
7 var len = arguments.length, i = 0;
9 var obj = arguments[i];
11 forIn(obj, copy, target);
18 * Copy properties from the source object to the
22 * @param {String} `key`
25 function copy(val, key) {
26 if (!isValidKey(key)) {
31 if (isObject(val) && isObject(obj)) {
39 * Returns true if `val` is an object or function.
45 function isObject(val) {
46 return isExtendable(val) && !Array.isArray(val);
50 * Returns true if `key` is a valid key to use when extending objects.
52 * @param {String} `key`
56 function isValidKey(key) {
57 return key !== '__proto__' && key !== 'constructor' && key !== 'prototype';
64 module.exports = mixinDeep;