0
# UpperCamelCase
1
2
UpperCamelCase is a lightweight JavaScript utility for converting dash, dot, underscore, or space separated strings to UpperCamelCase format. It transforms strings like 'foo-bar' into 'FooBar' by building upon the popular camelcase library and capitalizing the first letter.
3
4
## Package Information
5
6
- **Package Name**: uppercamelcase
7
- **Package Type**: npm
8
- **Language**: JavaScript
9
- **Installation**: `npm install uppercamelcase`
10
11
## Core Imports
12
13
```javascript
14
const upperCamelCase = require('uppercamelcase');
15
```
16
17
## Basic Usage
18
19
```javascript
20
const upperCamelCase = require('uppercamelcase');
21
22
// Convert dash-separated strings
23
upperCamelCase('foo-bar');
24
//=> 'FooBar'
25
26
// Convert underscore-separated strings
27
upperCamelCase('foo_bar');
28
//=> 'FooBar'
29
30
// Convert dot-separated strings
31
upperCamelCase('foo.bar');
32
//=> 'FooBar'
33
34
// Convert space-separated strings
35
upperCamelCase('foo bar');
36
//=> 'FooBar'
37
38
// Handle multiple arguments
39
upperCamelCase('foo', 'bar', 'baz');
40
//=> 'FooBarBaz'
41
```
42
43
## Capabilities
44
45
### String Conversion
46
47
Converts strings with various separators to UpperCamelCase format.
48
49
```javascript { .api }
50
/**
51
* Convert strings to UpperCamelCase format
52
* @param {...string} arguments - Variable number of strings to convert
53
* @returns {string} The converted UpperCamelCase string
54
*/
55
function upperCamelCase(...arguments): string;
56
```
57
58
**Parameters:**
59
- `...arguments` (string): Variable number of string arguments
60
- Each string may contain dash (`-`), dot (`.`), underscore (`_`), or space (` `) separators
61
- Multiple consecutive separators are handled gracefully
62
- Leading and trailing separators are processed correctly
63
- Empty strings and separator-only strings are supported
64
65
**Returns:**
66
- `string`: The input string(s) converted to UpperCamelCase format
67
- First character is always uppercase
68
- Each word boundary (after separators) is capitalized
69
- Separators are removed from the output
70
- Multiple arguments are concatenated and processed together
71
72
**Behavior Details:**
73
- Uses the `camelcase` library internally for initial conversion
74
- Capitalizes the first character of the camelCase result
75
- Supports various separator combinations: `--foo--bar--` → `'FooBar'`
76
- Handles mixed casing input: `'FOO-BAR'` → `'FooBar'`
77
- Preserves single separator characters: `'-'` → `'-'`
78
- Returns empty string for separator-only inputs: `'--'` → `''`
79
80
**Usage Examples:**
81
82
```javascript
83
// Single string conversions
84
upperCamelCase('foo-bar-baz'); // 'FooBarBaz'
85
upperCamelCase('__foo__bar__'); // 'FooBar'
86
upperCamelCase('--foo.bar'); // 'FooBar'
87
upperCamelCase(' foo bar '); // 'FooBar'
88
89
// Multiple argument conversion
90
upperCamelCase('foo', 'bar'); // 'FooBar'
91
upperCamelCase('foo', '-bar', 'baz'); // 'FooBarBaz'
92
93
// Edge cases
94
upperCamelCase(''); // ''
95
upperCamelCase('-'); // '-'
96
upperCamelCase('--'); // ''
97
upperCamelCase('FOO'); // 'Foo'
98
upperCamelCase('fooBar'); // 'FooBar'
99
100
// Complex separator patterns
101
upperCamelCase('--foo--bar--'); // 'FooBar'
102
upperCamelCase('__foo__bar__'); // 'FooBar'
103
upperCamelCase('..foo..bar..'); // 'FooBar'
104
```