Permalink
Cannot retrieve contributors at this time
26 lines (24 sloc)
700 Bytes
| 'use strict'; | |
| function assignment (result) { | |
| var stack = Array.prototype.slice.call(arguments, 1); | |
| var item; | |
| var key; | |
| while (stack.length) { | |
| item = stack.shift(); | |
| for (key in item) { | |
| if (item.hasOwnProperty(key)) { | |
| if (typeof result[key] === 'object' && result[key] && Object.prototype.toString.call(result[key]) !== '[object Array]') { | |
| if (typeof item[key] === 'object' && item[key] !== null) { | |
| result[key] = assignment({}, result[key], item[key]); | |
| } else { | |
| result[key] = item[key]; | |
| } | |
| } else { | |
| result[key] = item[key]; | |
| } | |
| } | |
| } | |
| } | |
| return result; | |
| } | |
| module.exports = assignment; |