element-plus/packages/utils/strings.ts
qiang c4d0c6f90a
refactor(components): [tabs] improve types (#9561)
Co-authored-by: 三咲智子 <sxzz@sxzz.moe>
2022-09-06 16:26:17 +00:00

17 lines
565 B
TypeScript

import { capitalize as toCapitalize } from '@vue/shared'
export {
camelize,
hyphenate,
hyphenate as kebabCase, // alias
} from '@vue/shared'
/**
* fork from {@link https://github.com/sindresorhus/escape-string-regexp}
*/
export const escapeStringRegexp = (string = '') =>
string.replace(/[|\\{}()[\]^$+*?.]/g, '\\$&').replace(/-/g, '\\x2d')
// NOTE: improve capitalize types. Restore previous code after the [PR](https://github.com/vuejs/core/pull/6212) merge
export const capitalize = <T extends string>(str: T) =>
toCapitalize(str) as Capitalize<T>