exports.commify = function (str){ return _AN_Call_replace('replace', String(str).split('').reverse().join(''), /(...)(?!$)/g, '$1,').split('').reverse().join(''); } ; exports.padRight = function (str, minlength){ while (_AN_Read_length('length', str) < minlength){ str = str + ' '; } return str; } ; exports.longest = function (arr){ return arr.reduce(function (a, x){ if (_AN_Read_length('length', x) > a) { return _AN_Read_length('length', x); } return a; } , 0); } ; exports.truncate = function (str, max){ if (_AN_Read_length('length', str) <= max) { return str; } return str.substr(0, max - 1) + '…'; } ; exports.endsWith = function endsWith(str, suffix){ return str.indexOf(suffix, _AN_Read_length('length', str) - _AN_Read_length('length', suffix)) !== -1; } ; var templateRegExp = /\{\{\s*(\w+)\s*\}\}/g; exports.template = function template(contents, data){ return _AN_Call_replace('replace', contents.toString(), templateRegExp, function (match, token){ var result = data[token]; if (result === null || result === undefined) { result = ''; } return result; } ); } ; exports.camelize = function (str){ _AN_Call_replace('replace', str.trim(), /[-_\s]+(.)?/g, function (match, c){ return c.toUpperCase(); } ); } ; exports.ucfirst = function (str){ return str.charAt(0).toUpperCase() + str.slice(1); } ;