View Code? Open in Web Editor
NEW
Code examples for my How To Grok Higher Order Classes article, exploring how to approach applying higher order function paradigms against class definitions.
License: MIT License
higher-order-classes's People
higher-order-classes's Issues
Your examples are pretty high up on Google for some search results. Are you accepting PRs?
What would you think of this alternative approach?
export default function decorator ( opts ) {
return ( Class ) => {
class Decorator extends Class { }
Object . assign ( Decorator . prototype , {
someValue : opts . someValue ,
doSomething : function doSomething ( ) {
}
} ) ;
Object . defineProperty ( Decorator , 'name' , { value : `decorator(${ Class . name } )` } ) ;
return Decorator ;
} ;
}