typeorm
Version:
Data-Mapper ORM for TypeScript, ES7, ES6, ES5. Supports MySQL, PostgreSQL, MariaDB, SQLite, MS SQL Server, Oracle, WebSQL, MongoDB databases.
31 lines (29 loc) • 981 B
JavaScript
/**
* Converts string into camelCase.
*
* @see http://stackoverflow.com/questions/2970525/converting-any-string-into-camel-case
*/
export function camelCase(str) {
return str.replace(/^([A-Z])|[\s-_](\w)/g, function (match, p1, p2, offset) {
if (p2)
return p2.toUpperCase();
return p1.toLowerCase();
});
}
/**
* Converts string into snake-case.
*
* @see http://stackoverflow.com/questions/30521224/javascript-convert-pascalcase-to-underscore-case
*/
export function snakeCase(str) {
return str.replace(/(?:^|\.?)([A-Z])/g, function (x, y) { return "_" + y.toLowerCase(); }).replace(/^_/, "");
}
/**
* Converts string into title-case.
*
* @see http://stackoverflow.com/questions/196972/convert-string-to-title-case-with-javascript
*/
export function titleCase(str) {
return str.replace(/\w\S*/g, function (txt) { return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase(); });
}
//# sourceMappingURL=StringUtils.js.map