1 | export type Options = {
|
2 | /**
|
3 | Uppercase the first character: `foo-bar` → `FooBar`.
|
4 |
|
5 | @default false
|
6 | */
|
7 | readonly pascalCase?: boolean;
|
8 |
|
9 | /**
|
10 | Preserve consecutive uppercase characters: `foo-BAR` → `FooBAR`.
|
11 |
|
12 | @default false
|
13 | */
|
14 | readonly preserveConsecutiveUppercase?: boolean;
|
15 |
|
16 | /**
|
17 | The locale parameter indicates the locale to be used to convert to upper/lower case according to any locale-specific case mappings. If multiple locales are given in an array, the best available locale is used.
|
18 |
|
19 | Setting `locale: false` ignores the platform locale and uses the [Unicode Default Case Conversion](https://unicode-org.github.io/icu/userguide/transforms/casemappings.html#simple-single-character-case-mapping) algorithm.
|
20 |
|
21 | Default: The host environment’s current locale.
|
22 |
|
23 | @example
|
24 | ```
|
25 | import camelCase from 'camelcase';
|
26 |
|
27 | camelCase('lorem-ipsum', {locale: 'en-US'});
|
28 | //=> 'loremIpsum'
|
29 |
|
30 | camelCase('lorem-ipsum', {locale: 'tr-TR'});
|
31 | //=> 'loremİpsum'
|
32 |
|
33 | camelCase('lorem-ipsum', {locale: ['en-US', 'en-GB']});
|
34 | //=> 'loremIpsum'
|
35 |
|
36 | camelCase('lorem-ipsum', {locale: ['tr', 'TR', 'tr-TR']});
|
37 | //=> 'loremİpsum'
|
38 | ```
|
39 | */
|
40 | readonly locale?: false | string | readonly string[];
|
41 | };
|
42 |
|
43 | /**
|
44 | Convert a dash/dot/underscore/space separated string to camelCase or PascalCase: `foo-bar` → `fooBar`.
|
45 |
|
46 | Correctly handles Unicode strings.
|
47 |
|
48 | @param input - String to convert to camel case.
|
49 |
|
50 | @example
|
51 | ```
|
52 | import camelCase from 'camelcase';
|
53 |
|
54 | camelCase('foo-bar');
|
55 | //=> 'fooBar'
|
56 |
|
57 | camelCase('foo_bar');
|
58 | //=> 'fooBar'
|
59 |
|
60 | camelCase('Foo-Bar');
|
61 | //=> 'fooBar'
|
62 |
|
63 | camelCase('розовый_пушистый_единорог');
|
64 | //=> 'розовыйПушистыйЕдинорог'
|
65 |
|
66 | camelCase('Foo-Bar', {pascalCase: true});
|
67 | //=> 'FooBar'
|
68 |
|
69 | camelCase('--foo.bar', {pascalCase: false});
|
70 | //=> 'fooBar'
|
71 |
|
72 | camelCase('Foo-BAR', {preserveConsecutiveUppercase: true});
|
73 | //=> 'fooBAR'
|
74 |
|
75 | camelCase('fooBAR', {pascalCase: true, preserveConsecutiveUppercase: true}));
|
76 | //=> 'FooBAR'
|
77 |
|
78 | camelCase('foo bar');
|
79 | //=> 'fooBar'
|
80 |
|
81 | console.log(process.argv[3]);
|
82 | //=> '--foo-bar'
|
83 | camelCase(process.argv[3]);
|
84 | //=> 'fooBar'
|
85 |
|
86 | camelCase(['foo', 'bar']);
|
87 | //=> 'fooBar'
|
88 |
|
89 | camelCase(['__foo__', '--bar'], {pascalCase: true});
|
90 | //=> 'FooBar'
|
91 |
|
92 | camelCase(['foo', 'BAR'], {pascalCase: true, preserveConsecutiveUppercase: true})
|
93 | //=> 'FooBAR'
|
94 |
|
95 | camelCase('lorem-ipsum', {locale: 'en-US'});
|
96 | //=> 'loremIpsum'
|
97 | ```
|
98 | */
|
99 | export default function camelcase(
|
100 | input: string | readonly string[],
|
101 | options?: Options
|
102 | ): string;
|