Created
July 9, 2014 16:57
-
-
Save ixtli/d217f17738f61968bc74 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
/** | |
* Apply an object's prototype as a mixin to another object's prototype | |
* @param {Object} destination The class to mix in to | |
* @param {(Object|Array)} source An object or array of objects to mix in | |
*/ | |
function mixIn(destination, source) | |
{ | |
if (typeof source !== TYPE_OF_ARRAY) | |
{ | |
$.extend(destination.prototype, source.prototype); | |
return; | |
} | |
var len = source.length; | |
if (!len) | |
{ | |
return; | |
} | |
var arr = new Array(len + 1); | |
arr[0] = destination.prototype; | |
for (var i = 1; i < len; i++) | |
{ | |
arr[i] = source[i].prototype; | |
} | |
$.extend.apply($, arr); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment