Last active
August 29, 2015 14:27
-
-
Save avesus/b0bd1538080090e34521 to your computer and use it in GitHub Desktop.
Patches Mithril to accept components as well as strings
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
// If you need a license, this is under the ISC license. | |
// In golfed ES6, just because I could... (84 characters) | |
this.m=(o=>Object.assign((...a)=>(typeof a[0]=='string'?o:o.component)(...a),o))(m); |
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
// If you need a license, this is under the ISC license. | |
// In ES6, just because I could... | |
this.m = ((old, m) => { | |
m = (name, ...rest) => (typeof name === 'string' ? old : old.component)(name, ...rest); | |
Object.assign(m, old); | |
return m; | |
})(m); |
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
// If you need a license, this is under the ISC license. | |
this.m = (function (old) { | |
function m(name) { | |
return (typeof name === 'string' ? old : old.component) | |
.apply(this, arguments); | |
} | |
for (var p in old) if ({}.hasOwnProperty.call(p)) { | |
m[p] = old[p]; | |
} | |
return m; | |
})(m); |
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
// If you need a license, this is under the ISC license. | |
this.m=function(o){function m(n){return(typeof n==='string'?o:o.component).apply(this,arguments)}for(var p in o)if({}.hasOwnProperty.call(p))m[p]=o[p];return m}(m); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment