VulpesOS/gaia/apps/camera/js/lib/string-utils.js
OverSu b38dea0597 Publish Vulpes Preview 15 sources for desktop, Android and Tundra
Share Gaia assets and adapters, keep private profiles and development documents local, and update both public READMEs.
2026-09-30 23:13:03 +02:00

27 lines
644 B
JavaScript
Executable file

define(function(require) {
'use strict';
var StringUtils = {};
StringUtils.toCamelCase = function(str) {
// Convert SNAKE_CASE strings to hyphenated
str = str.toLowerCase().replace(/_/g, '-');
return str.replace(/-([a-z])/g, function(g) {
return g[1].toUpperCase();
});
};
StringUtils.toHyphenate = function(str) {
return str.replace(/([a-z][A-Z])/g, function(g) {
return g[0] + '-' + g[1].toLowerCase();
});
};
StringUtils.lastPathComponent = function(path) {
var pathComponents = path.split('/');
return pathComponents[pathComponents.length - 1];
};
return StringUtils;
});