Created
July 14, 2016 15:44
-
-
Save edgarberm/47ad5a1077cd721b0d590fb4e28f1562 to your computer and use it in GitHub Desktop.
Copy the prototype methods of the given constructor method into the given context, if they do not already exist.
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
const assignPrototypeMethods = ( constructorMethod, context ) => { | |
// Loop over the BaseController's prototype methods and assign them to the current context | |
for ( var methodName in constructorMethod.prototype ) { | |
if (constructorMethod.prototype.hasOwnProperty( methodName ) && !context[ methodName ]) { | |
// Copy the method into the current controller context. | |
context[ methodName ] = constructorMethod.prototype[ methodName ]; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment