-
-
Save StephanHoyer/fc50c213083a3b0cae36 to your computer and use it in GitHub Desktop.
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
"use strict"; | |
/* | |
Formatters | |
Usage: | |
f.append(f.trim(' foo '), 'bar') > foobar | |
With composition | |
f.trimAppend = function(value, str) { | |
return f.append(f.trim(value), str); | |
} | |
f.trimAppend(' foo ', 'bar') > foobar | |
Extend with own formatters: | |
f.currency = function(value) { | |
return (Math.round(value * 100) / 100) + ' €'; | |
}; | |
*/ | |
f = {}; | |
f.trim = function(value) { | |
return (value || '').trim(); | |
}; | |
f.append = function(value, str) { | |
return value + '' + str; | |
}; | |
module.exports = f; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment