Skip to content

Function: noCase() ​

noCase(input, options?): string

Convert a string in any case (camelCase, PascalCase, snake_case, kebab-case, CONSTANT_CASE, sentences) into lower case words separated by single spaces. A word starts at each lower-to-upper change (fooBar), at the last capital of an acronym (XMLHttp gives xml http), and after any run of characters which are neither letters nor digits (spaces, _, -, punctuation, which are removed). The letters of any script are kept.

Parameters ​

input ​

string

The string to convert; an empty string, or one without letters and digits, gives ''.

options? ​

NoCaseOptions

How the words are split, and the locale of the lower case.

Returns ​

string

The lower case words, separated by spaces.

Example ​

typescript
import {noCase} from 'lakutata/utils'

console.log(noCase('helloWorld_fooBar-BAZ'))
//hello world foo bar baz
console.log(noCase('XMLHttpRequest'), '|', noCase('version2Beta', {separateNumbers: true}))
//xml http request | version 2 beta

Released under the MIT License.