Created
August 22, 2011 19:56
-
-
Save vstarck/1163358 to your computer and use it in GitHub Desktop.
Camelize Decorator
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
// Decora la funcion camelizando su resultado | |
function camelizeDecorator(fn) { | |
return function() { | |
return fn.apply(null, arguments).replace(/[-\s_]+(.)?/g, function(match, chr) { | |
return chr ? chr.toUpperCase() : ''; | |
}); | |
} | |
} | |
function k(a) { | |
return a; | |
} | |
camelizedK = camelizeDecorator(k); | |
camelizedK('esto_es un-string'); // "estoEsUnString" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment