strings.ts 565 B

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