source: frontend/node_modules/camelcase/readme.md

Last change on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 11 days ago

Fix frontend appearance

  • Property mode set to 100644
File size: 3.9 KB
Line 
1# camelcase
2
3> Convert a dash/dot/underscore/space separated string to camelCase or PascalCase: `foo-bar` → `fooBar`
4
5Correctly handles Unicode strings.
6
7If you use this on untrusted user input, don't forget to limit the length to something reasonable.
8
9## Install
10
11```
12$ npm install camelcase
13```
14
15*If you need to support Firefox < 78, stay on version 5 as version 6 uses regex features not available in Firefox < 78.*
16
17## Usage
18
19```js
20const camelCase = require('camelcase');
21
22camelCase('foo-bar');
23//=> 'fooBar'
24
25camelCase('foo_bar');
26//=> 'fooBar'
27
28camelCase('Foo-Bar');
29//=> 'fooBar'
30
31camelCase('розовый_пушистый_единорог');
32//=> 'розовыйПушистыйЕдинорог'
33
34camelCase('Foo-Bar', {pascalCase: true});
35//=> 'FooBar'
36
37camelCase('--foo.bar', {pascalCase: false});
38//=> 'fooBar'
39
40camelCase('Foo-BAR', {preserveConsecutiveUppercase: true});
41//=> 'fooBAR'
42
43camelCase('fooBAR', {pascalCase: true, preserveConsecutiveUppercase: true}));
44//=> 'FooBAR'
45
46camelCase('foo bar');
47//=> 'fooBar'
48
49console.log(process.argv[3]);
50//=> '--foo-bar'
51camelCase(process.argv[3]);
52//=> 'fooBar'
53
54camelCase(['foo', 'bar']);
55//=> 'fooBar'
56
57camelCase(['__foo__', '--bar'], {pascalCase: true});
58//=> 'FooBar'
59
60camelCase(['foo', 'BAR'], {pascalCase: true, preserveConsecutiveUppercase: true})
61//=> 'FooBAR'
62
63camelCase('lorem-ipsum', {locale: 'en-US'});
64//=> 'loremIpsum'
65```
66
67## API
68
69### camelCase(input, options?)
70
71#### input
72
73Type: `string | string[]`
74
75String to convert to camel case.
76
77#### options
78
79Type: `object`
80
81##### pascalCase
82
83Type: `boolean`\
84Default: `false`
85
86Uppercase the first character: `foo-bar` → `FooBar`
87
88##### preserveConsecutiveUppercase
89
90Type: `boolean`\
91Default: `false`
92
93Preserve the consecutive uppercase characters: `foo-BAR` → `FooBAR`.
94
95##### locale
96
97Type: `false | string | string[]`\
98Default: The host environment’s current locale.
99
100The 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.
101
102```js
103const camelCase = require('camelcase');
104
105camelCase('lorem-ipsum', {locale: 'en-US'});
106//=> 'loremIpsum'
107
108camelCase('lorem-ipsum', {locale: 'tr-TR'});
109//=> 'loremİpsum'
110
111camelCase('lorem-ipsum', {locale: ['en-US', 'en-GB']});
112//=> 'loremIpsum'
113
114camelCase('lorem-ipsum', {locale: ['tr', 'TR', 'tr-TR']});
115//=> 'loremİpsum'
116```
117
118Setting `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:
119
120```js
121const camelCase = require('camelcase');
122
123// On a platform with 'tr-TR'
124
125camelCase('lorem-ipsum');
126//=> 'loremİpsum'
127
128camelCase('lorem-ipsum', {locale: false});
129//=> 'loremIpsum'
130```
131
132## camelcase for enterprise
133
134Available as part of the Tidelift Subscription.
135
136The maintainers of camelcase and thousands of other packages are working with Tidelift to deliver commercial support and maintenance for the open source dependencies you use to build your applications. Save time, reduce risk, and improve code health, while paying the maintainers of the exact dependencies you use. [Learn more.](https://tidelift.com/subscription/pkg/npm-camelcase?utm_source=npm-camelcase&utm_medium=referral&utm_campaign=enterprise&utm_term=repo)
137
138## Related
139
140- [decamelize](https://github.com/sindresorhus/decamelize) - The inverse of this module
141- [uppercamelcase](https://github.com/SamVerschueren/uppercamelcase) - Like this module, but to PascalCase instead of camelCase
142- [titleize](https://github.com/sindresorhus/titleize) - Capitalize every word in string
143- [humanize-string](https://github.com/sindresorhus/humanize-string) - Convert a camelized/dasherized/underscored string into a humanized one
144- [camelcase-keys](https://github.com/sindresorhus/camelcase-keys) - Convert object keys to camel case
Note: See TracBrowser for help on using the repository browser.