strings.ts 567 B

1234567891011121314
  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 = '') => string.replace(/[|\\{}()[\]^$+*?.]/g, '\\$&').replace(/-/g, '\\x2d')
  11. // NOTE: improve capitalize types. Restore previous code after the [PR](https://github.com/vuejs/core/pull/6212) merge
  12. export const capitalize = <T extends string>(str: T) => toCapitalize(str) as Capitalize<T>