UNPKG

@amplitude/ampli

Version:

Amplitude CLI

14 lines (13 loc) 599 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const lodash_1 = require("lodash"); function sanitize(str) { return lodash_1.upperFirst(lodash_1.deburr(str) .replace(/(^\s*[^a-zA-Z_$])|([^a-zA-Z_$\d])/g, ' ') .replace(/^_[a-z]/g, match => match.toUpperCase()) .replace(/_[a-z]/g, match => match.substr(1, match.length).toUpperCase()) .replace(/([\d$]+[a-zA-Z])/g, match => match.toUpperCase()) .replace(/\s+([a-zA-Z])/g, match => lodash_1.trim(match.toUpperCase())) .replace(/\s/g, '')); } exports.default = sanitize;