Skip to content

Instantly share code, notes, and snippets.

@jeremybuis
Created April 10, 2014 15:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jeremybuis/10393830 to your computer and use it in GitHub Desktop.
Save jeremybuis/10393830 to your computer and use it in GitHub Desktop.
An implementation of the extend function for object mixin
// Taken from
// http://raganwald.com/2014/04/10/mixins-forwarding-delegation.html
(function(window) {
var __slice = [].slice;
function extend () {
var consumer = arguments[0],
providers = __slice.call(arguments, 1),
key,
i,
provider,
except;
for (i = 0; i < providers.length; ++i) {
provider = providers[i];
except = provider['except'] || [];
except.push('except');
for (key in provider) {
if (except.indexOf(key) < 0 && provider.hasOwnProperty(key)) {
consumer[key] = provider[key];
};
};
};
return consumer;
};
window.extend = extend;
})(window);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment