if (!String.prototype.trim) { String.prototype.trim = function () { return this.replace(/^\s+/, '').replace(/\s+$/, ''); }; } function camelize(string) { return string.replace(/-+(.)?/g, function(match, character) { return character ? character.toUpperCase() : ''; }); } function capitalize(string) { return string.charAt(0).toUpperCase() + string.slice(1).toLowerCase(); } fabric.util.string = { camelize: camelize, capitalize: capitalize };