Created
May 19, 2016 15:10
-
-
Save felixheck/e385d4b86890adbaae205c2fc80b8607 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @function | |
* @private | |
* | |
* @description | |
* Check if passed item is an object | |
* | |
* @param {*} item The item to be checked | |
* @returns {boolean} The passed item is an object | |
*/ | |
function isObject(item) { | |
return typeof item === 'object'; | |
} | |
/** | |
* @function | |
* @public | |
* | |
* @description | |
* Link multiple source objects to a origin-based objects | |
* | |
* @param {Object} origin The object to be extended | |
* @param {Object} sources The source object to be appended | |
* @returns {Object} New instance of a combined object | |
*/ | |
function oloo(origin, ...sources) { | |
if (isObject(origin) && sources.every(isObject)) { | |
return Object.assign(Object.create(origin), ...sources); | |
} else { | |
return null; | |
} | |
} | |
module.exports = oloo; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment