Skip to content

Instantly share code, notes, and snippets.

@StephanHoyer
Forked from der-On/formatters.js
Last active August 29, 2015 14:14
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save StephanHoyer/fc50c213083a3b0cae36 to your computer and use it in GitHub Desktop.
Save StephanHoyer/fc50c213083a3b0cae36 to your computer and use it in GitHub Desktop.
"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