Skip to content

@longmo-utils/common / snakeCase

Function: snakeCase()

ts
function snakeCase(str): string;

将字符串转换为下划线命名

Parameters

ParameterTypeDescription
strstring输入字符串

Returns

string

下划线命名字符串

Example

ts
snakeCase('helloWorld') // 'hello_world'
snakeCase('hello-world') // 'hello_world'
snakeCase('hello world') // 'hello_world'

Released under the MIT License.