Skip to content

Instantly share code, notes, and snippets.

@felixheck
Created May 19, 2016 15:10
Show Gist options
  • Save felixheck/e385d4b86890adbaae205c2fc80b8607 to your computer and use it in GitHub Desktop.
Save felixheck/e385d4b86890adbaae205c2fc80b8607 to your computer and use it in GitHub Desktop.
/**
* @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