UNPKG

1.09 kBTypeScriptView Raw
1export interface Options {
2 /**
3 Character or string inserted to separate words in `string`.
4
5 @default '_'
6
7 @example
8 ```
9 import decamelize from 'decamelize';
10
11 decamelize('unicornRainbow');
12 //=> 'unicorn_rainbow'
13
14 decamelize('unicornRainbow', {separator: '-'});
15 //=> 'unicorn-rainbow'
16 ```
17 */
18 readonly separator?: string;
19
20 /**
21 Preserve sequences of uppercase characters.
22
23 @default false
24
25 @example
26 ```
27 import decamelize from 'decamelize';
28
29 decamelize('testGUILabel');
30 //=> 'test_gui_label'
31
32 decamelize('testGUILabel', {preserveConsecutiveUppercase: true});
33 //=> 'test_GUI_label'
34 ```
35 */
36 readonly preserveConsecutiveUppercase?: boolean;
37}
38
39/**
40Convert a camelized string into a lowercased one with a custom separator: `unicornRainbow` → `unicorn_rainbow`.
41
42@param string - The camelcase string to decamelize.
43
44@example
45```
46import decamelize from 'decamelize';
47
48decamelize('unicornRainbow');
49//=> 'unicorn_rainbow'
50
51decamelize('unicornRainbow', {separator: '-'});
52//=> 'unicorn-rainbow'
53```
54*/
55export default function decamelize(string: string, options?: Options): string;