UNPKG

ut2

Version:

一个现代 JavaScript 实用工具库。[点击查看在线文档]。

27 lines (26 loc) 730 B
/** * 转换字符串为连接符小写。 * * @alias module:String.kebabCase * @since 1.0.0 * @see {@link https://en.wikipedia.org/wiki/Letter_case#Special_case_styles kebab case} * @param {string} string 要转换的字符串。 * @param {RegExp | string} [pattern] 拆分词组的匹配模式。 * @returns {string} 转换后的字符串。 * @example * * kebabCase('foo bar'); // 'foo-bar' * * kebabCase('foo-bar'); // 'foo-bar' * * kebabCase('Foo Bar'); // 'foo-bar' * * kebabCase('FOO BAR'); // 'foo-bar' * * kebabCase('--FOO-BAR--'); // 'foo-bar' * * kebabCase('__FOO_BAR__'); // 'foo-bar' * */ declare function kebabCase(string: string, pattern?: RegExp | string): string; export default kebabCase;