@cjser/camelcase__v9_0_0 0.0.0-stage → 9.0.0-cjser.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,155 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+
19
+ // packages/@cjser/camelcase__v9_0_0.tmp-26-1791822181810/index.js
20
+ var index_exports = {};
21
+ __export(index_exports, {
22
+ default: () => camelCase
23
+ });
24
+ module.exports = __toCommonJS(index_exports);
25
+ var UPPERCASE = /[\p{Lu}]/u;
26
+ var LOWERCASE = /[\p{Ll}]/u;
27
+ var LEADING_CAPITAL = /^[\p{Lu}](?![\p{Lu}])/u;
28
+ var SEPARATORS = /[_.\- ]+/;
29
+ var IDENTIFIER = /([\p{Alpha}\p{N}_]|$)/u;
30
+ var LEADING_SEPARATORS = new RegExp("^" + SEPARATORS.source);
31
+ var SEPARATORS_AND_IDENTIFIER = new RegExp(SEPARATORS.source + IDENTIFIER.source, "gu");
32
+ var NUMBERS_AND_IDENTIFIER = new RegExp(String.raw`\d+` + IDENTIFIER.source, "gu");
33
+ var preserveCamelCase = (string, toLowerCase, toUpperCase, preserveConsecutiveUppercase2) => {
34
+ let isLastCharLower = false;
35
+ let isLastCharUpper = false;
36
+ let isLastLastCharUpper = false;
37
+ let isLastLastCharPreserved = false;
38
+ for (let index = 0; index < string.length; index++) {
39
+ const character = string[index];
40
+ isLastLastCharPreserved = index > 2 ? string[index - 3] === "-" : true;
41
+ if (isLastCharLower && UPPERCASE.test(character)) {
42
+ string = string.slice(0, index) + "-" + string.slice(index);
43
+ isLastCharLower = false;
44
+ isLastLastCharUpper = isLastCharUpper;
45
+ isLastCharUpper = true;
46
+ index++;
47
+ } else if (isLastCharUpper && isLastLastCharUpper && LOWERCASE.test(character) && (!isLastLastCharPreserved || preserveConsecutiveUppercase2)) {
48
+ string = string.slice(0, index - 1) + "-" + string.slice(index - 1);
49
+ isLastLastCharUpper = isLastCharUpper;
50
+ isLastCharUpper = false;
51
+ isLastCharLower = true;
52
+ } else {
53
+ isLastCharLower = toLowerCase(character) === character && toUpperCase(character) !== character;
54
+ isLastLastCharUpper = isLastCharUpper;
55
+ isLastCharUpper = toUpperCase(character) === character && toLowerCase(character) !== character;
56
+ }
57
+ }
58
+ return string;
59
+ };
60
+ var preserveConsecutiveUppercase = (input, toLowerCase) => input.replace(LEADING_CAPITAL, (match) => toLowerCase(match));
61
+ var processWithCasePreservation = (input, toLowerCase, preserveConsecutiveUppercase2) => {
62
+ let result = "";
63
+ let previousWasNumber = false;
64
+ let previousWasUppercase = false;
65
+ const characters = [...input];
66
+ for (let index = 0; index < characters.length; index++) {
67
+ const character = characters[index];
68
+ const isUpperCase = UPPERCASE.test(character);
69
+ const nextCharIsUpperCase = index + 1 < characters.length && UPPERCASE.test(characters[index + 1]);
70
+ if (previousWasNumber && /[\p{Alpha}]/u.test(character)) {
71
+ result += character;
72
+ previousWasNumber = false;
73
+ previousWasUppercase = isUpperCase;
74
+ } else if (preserveConsecutiveUppercase2 && isUpperCase && (previousWasUppercase || nextCharIsUpperCase)) {
75
+ result += character;
76
+ previousWasUppercase = true;
77
+ } else if (/\d/.test(character)) {
78
+ result += character;
79
+ previousWasNumber = true;
80
+ previousWasUppercase = false;
81
+ } else if (SEPARATORS.test(character)) {
82
+ result += character;
83
+ previousWasUppercase = false;
84
+ } else {
85
+ result += toLowerCase(character);
86
+ previousWasNumber = false;
87
+ previousWasUppercase = false;
88
+ }
89
+ }
90
+ return result;
91
+ };
92
+ var postProcess = (input, toUpperCase, { capitalizeAfterNumber }) => {
93
+ const transformNumericIdentifier = capitalizeAfterNumber ? (match, identifier, offset, string) => {
94
+ const nextCharacter = string.charAt(offset + match.length);
95
+ if (SEPARATORS.test(nextCharacter)) {
96
+ return match;
97
+ }
98
+ return identifier ? match.slice(0, -identifier.length) + toUpperCase(identifier) : match;
99
+ } : (match) => match;
100
+ return input.replaceAll(NUMBERS_AND_IDENTIFIER, transformNumericIdentifier).replaceAll(
101
+ SEPARATORS_AND_IDENTIFIER,
102
+ (_, identifier) => toUpperCase(identifier)
103
+ );
104
+ };
105
+ function camelCase(input, options) {
106
+ if (!(typeof input === "string" || Array.isArray(input))) {
107
+ throw new TypeError("Expected the input to be `string | string[]`");
108
+ }
109
+ options = {
110
+ pascalCase: false,
111
+ preserveConsecutiveUppercase: false,
112
+ capitalizeAfterNumber: true,
113
+ ...options
114
+ };
115
+ if (Array.isArray(input)) {
116
+ input = input.map((element) => element.trim()).filter((element) => element.length > 0).join("-");
117
+ } else {
118
+ input = input.trim();
119
+ }
120
+ if (input.length === 0) {
121
+ return "";
122
+ }
123
+ const leadingPrefix = input.match(/^[_$]*/)[0];
124
+ input = input.slice(leadingPrefix.length);
125
+ if (input.length === 0) {
126
+ return leadingPrefix;
127
+ }
128
+ const toLowerCase = options.locale === false ? (string) => string.toLowerCase() : (string) => string.toLocaleLowerCase(options.locale);
129
+ const toUpperCase = options.locale === false ? (string) => string.toUpperCase() : (string) => string.toLocaleUpperCase(options.locale);
130
+ if (input.length === 1) {
131
+ if (SEPARATORS.test(input)) {
132
+ return leadingPrefix;
133
+ }
134
+ return leadingPrefix + (options.pascalCase ? toUpperCase(input) : toLowerCase(input));
135
+ }
136
+ const hasUpperCase = input !== toLowerCase(input);
137
+ if (hasUpperCase) {
138
+ input = preserveCamelCase(
139
+ input,
140
+ toLowerCase,
141
+ toUpperCase,
142
+ options.preserveConsecutiveUppercase
143
+ );
144
+ }
145
+ input = input.replace(LEADING_SEPARATORS, "");
146
+ if (options.capitalizeAfterNumber) {
147
+ input = options.preserveConsecutiveUppercase ? preserveConsecutiveUppercase(input, toLowerCase) : toLowerCase(input);
148
+ } else {
149
+ input = processWithCasePreservation(input, toLowerCase, options.preserveConsecutiveUppercase);
150
+ }
151
+ if (options.pascalCase && input.length > 0) {
152
+ input = toUpperCase(input[0]) + input.slice(1);
153
+ }
154
+ return leadingPrefix + postProcess(input, toUpperCase, options);
155
+ }
package/index.d.ts ADDED
@@ -0,0 +1,154 @@
1
+ export type Options = {
2
+ /**
3
+ Uppercase the first character: `foo-bar` → `FooBar`
4
+
5
+ @default false
6
+
7
+ @example
8
+ ```
9
+ import camelCase from '@cjser/camelcase__v9_0_0';
10
+
11
+ camelCase('foo-bar', {pascalCase: true});
12
+ //=> 'FooBar'
13
+
14
+ camelCase('foo-bar', {pascalCase: false});
15
+ //=> 'fooBar'
16
+ ```
17
+ */
18
+ readonly pascalCase?: boolean;
19
+
20
+ /**
21
+ Preserve consecutive uppercase characters: `foo-BAR` → `FooBAR`
22
+
23
+ @default false
24
+
25
+ @example
26
+ ```
27
+ import camelCase from '@cjser/camelcase__v9_0_0';
28
+
29
+ camelCase('foo-BAR', {preserveConsecutiveUppercase: true});
30
+ //=> 'fooBAR'
31
+
32
+ camelCase('foo-BAR', {preserveConsecutiveUppercase: false});
33
+ //=> 'fooBar'
34
+ ````
35
+ */
36
+ readonly preserveConsecutiveUppercase?: boolean;
37
+
38
+ /**
39
+ Controls whether letters immediately following digits are treated as word boundaries.
40
+
41
+ **When `true` (default):**
42
+ Capitalize the first letter immediately following a numeric sequence, unless a separator intervenes. This aligns with most utilities, such as Lodash.
43
+
44
+ **When `false`:**
45
+ Do not treat digits as word boundaries. Preserve the original case of letters immediately following digits. Separators still create word boundaries. This follows the Google Java Style Guide which treats numbers as non-boundary characters.
46
+
47
+ @default true
48
+
49
+ @example
50
+ ```
51
+ import camelCase from '@cjser/camelcase__v9_0_0';
52
+
53
+ camelCase('foo2bar', {capitalizeAfterNumber: true});
54
+ //=> 'foo2Bar' (capitalizes 'b' after digit)
55
+
56
+ camelCase('foo2bar', {capitalizeAfterNumber: false});
57
+ //=> 'foo2bar' (preserves lowercase 'b')
58
+
59
+ // Preserves original case after numbers when false
60
+ camelCase('Textures_3d', {capitalizeAfterNumber: false});
61
+ //=> 'textures3d' (preserves lowercase 'd')
62
+
63
+ camelCase('Textures_3D', {capitalizeAfterNumber: false});
64
+ //=> 'textures3D' (preserves uppercase 'D')
65
+
66
+ // Separators still create boundaries
67
+ camelCase('foo_2_bar', {capitalizeAfterNumber: false});
68
+ //=> 'foo2Bar' ('bar' follows separator, not digit)
69
+ ```
70
+ */
71
+ readonly capitalizeAfterNumber?: boolean;
72
+
73
+ /**
74
+ 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.
75
+
76
+ Default: The host environment’s current locale.
77
+
78
+ @example
79
+ ```
80
+ import camelCase from '@cjser/camelcase__v9_0_0';
81
+
82
+ camelCase('lorem-ipsum', {locale: 'en-US'});
83
+ //=> 'loremIpsum'
84
+
85
+ camelCase('lorem-ipsum', {locale: 'tr-TR'});
86
+ //=> 'loremİpsum'
87
+
88
+ camelCase('lorem-ipsum', {locale: ['en-US', 'en-GB']});
89
+ //=> 'loremIpsum'
90
+
91
+ camelCase('lorem-ipsum', {locale: ['tr', 'TR', 'tr-TR']});
92
+ //=> 'loremİpsum'
93
+ ```
94
+
95
+ 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:
96
+
97
+ @example
98
+ ```
99
+ import camelCase from '@cjser/camelcase__v9_0_0';
100
+
101
+ // On a platform with `tr-TR`.`
102
+
103
+ camelCase('lorem-ipsum');
104
+ //=> 'loremİpsum'
105
+
106
+ camelCase('lorem-ipsum', {locale: false});
107
+ //=> 'loremIpsum'
108
+ ```
109
+ */
110
+ readonly locale?: false | string | readonly string[];
111
+ };
112
+
113
+ /**
114
+ Convert a dash/dot/underscore/space separated string to camelCase or PascalCase: `foo-bar` → `fooBar`.
115
+
116
+ Correctly handles Unicode strings.
117
+
118
+ @param input - The string to convert to camel case.
119
+
120
+ @example
121
+ ```
122
+ import camelCase from '@cjser/camelcase__v9_0_0';
123
+
124
+ camelCase('foo-bar');
125
+ //=> 'fooBar'
126
+
127
+ camelCase('foo_bar');
128
+ //=> 'fooBar'
129
+
130
+ camelCase('Foo-Bar');
131
+ //=> 'fooBar'
132
+
133
+ camelCase('розовый_пушистый_единорог');
134
+ //=> 'розовыйПушистыйЕдинорог'
135
+
136
+ camelCase('foo bar');
137
+ //=> 'fooBar'
138
+
139
+ console.log(process.argv[3]);
140
+ //=> '--foo-bar'
141
+ camelCase(process.argv[3]);
142
+ //=> 'fooBar'
143
+
144
+ camelCase(['foo', 'bar']);
145
+ //=> 'fooBar'
146
+
147
+ camelCase(['__foo__', '--bar']);
148
+ //=> '__fooBar'
149
+ ```
150
+ */
151
+ export default function camelcase(
152
+ input: string | readonly string[],
153
+ options?: Options
154
+ ): string;
package/index.js ADDED
@@ -0,0 +1,224 @@
1
+ const UPPERCASE = /[\p{Lu}]/u;
2
+ const LOWERCASE = /[\p{Ll}]/u;
3
+ const LEADING_CAPITAL = /^[\p{Lu}](?![\p{Lu}])/u;
4
+ const SEPARATORS = /[_.\- ]+/;
5
+
6
+ // The |$ alternative allows matching at end-of-string, capturing empty string
7
+ // This enables NUMBERS_AND_IDENTIFIER to match digits at string end (e.g., "test123")
8
+ const IDENTIFIER = /([\p{Alpha}\p{N}_]|$)/u;
9
+
10
+ const LEADING_SEPARATORS = new RegExp('^' + SEPARATORS.source);
11
+ const SEPARATORS_AND_IDENTIFIER = new RegExp(SEPARATORS.source + IDENTIFIER.source, 'gu');
12
+ const NUMBERS_AND_IDENTIFIER = new RegExp(String.raw`\d+` + IDENTIFIER.source, 'gu');
13
+
14
+ const preserveCamelCase = (string, toLowerCase, toUpperCase, preserveConsecutiveUppercase) => {
15
+ let isLastCharLower = false;
16
+ let isLastCharUpper = false;
17
+ let isLastLastCharUpper = false;
18
+ let isLastLastCharPreserved = false;
19
+
20
+ for (let index = 0; index < string.length; index++) {
21
+ const character = string[index];
22
+
23
+ // Was the character 3 positions back inserted as a separator?
24
+ // Prevents excessive separators by checking if we recently inserted one
25
+ // index - 3 accounts for: current character, inserted separator, previous character
26
+ // Default true for early positions activates the preserveConsecutiveUppercase guard
27
+ isLastLastCharPreserved = index > 2 ? string[index - 3] === '-' : true;
28
+
29
+ if (isLastCharLower && UPPERCASE.test(character)) {
30
+ // FooBar → Foo-Bar (insert separator before uppercase)
31
+ string = string.slice(0, index) + '-' + string.slice(index);
32
+ isLastCharLower = false;
33
+ isLastLastCharUpper = isLastCharUpper;
34
+ isLastCharUpper = true;
35
+ index++;
36
+ } else if (
37
+ isLastCharUpper
38
+ && isLastLastCharUpper
39
+ && LOWERCASE.test(character)
40
+ && (!isLastLastCharPreserved || preserveConsecutiveUppercase)
41
+ ) {
42
+ // FOOBar → FOO-Bar
43
+ string = string.slice(0, index - 1) + '-' + string.slice(index - 1);
44
+ isLastLastCharUpper = isLastCharUpper;
45
+ isLastCharUpper = false;
46
+ isLastCharLower = true;
47
+ } else {
48
+ isLastCharLower
49
+ = toLowerCase(character) === character
50
+ && toUpperCase(character) !== character;
51
+ isLastLastCharUpper = isLastCharUpper;
52
+ isLastCharUpper
53
+ = toUpperCase(character) === character
54
+ && toLowerCase(character) !== character;
55
+ }
56
+ }
57
+
58
+ return string;
59
+ };
60
+
61
+ const preserveConsecutiveUppercase = (input, toLowerCase) => input.replace(LEADING_CAPITAL, match => toLowerCase(match));
62
+
63
+ const processWithCasePreservation = (input, toLowerCase, preserveConsecutiveUppercase) => {
64
+ let result = '';
65
+ let previousWasNumber = false;
66
+ let previousWasUppercase = false;
67
+
68
+ // Convert input to array for lookahead capability
69
+ const characters = [...input];
70
+
71
+ for (let index = 0; index < characters.length; index++) {
72
+ const character = characters[index];
73
+ const isUpperCase = UPPERCASE.test(character);
74
+ const nextCharIsUpperCase = index + 1 < characters.length && UPPERCASE.test(characters[index + 1]);
75
+
76
+ if (previousWasNumber && /[\p{Alpha}]/u.test(character)) {
77
+ // Letter after number - preserve original case
78
+ result += character;
79
+ previousWasNumber = false;
80
+ previousWasUppercase = isUpperCase;
81
+ } else if (preserveConsecutiveUppercase && isUpperCase && (previousWasUppercase || nextCharIsUpperCase)) {
82
+ // Part of consecutive uppercase sequence when preserveConsecutiveUppercase is true - keep it
83
+ result += character;
84
+ previousWasUppercase = true;
85
+ } else if (/\d/.test(character)) {
86
+ // Number - keep as-is and track it
87
+ result += character;
88
+ previousWasNumber = true;
89
+ previousWasUppercase = false;
90
+ } else if (SEPARATORS.test(character)) {
91
+ // Separator - keep as-is and maintain previousWasNumber state
92
+ result += character;
93
+ previousWasUppercase = false;
94
+ } else {
95
+ // Regular character - lowercase it
96
+ result += toLowerCase(character);
97
+ previousWasNumber = false;
98
+ previousWasUppercase = false;
99
+ }
100
+ }
101
+
102
+ return result;
103
+ };
104
+
105
+ /**
106
+ Core post-processing:
107
+ - Collapses separators and uppercases the following identifier character.
108
+ - Optionally uppercases the identifier following a numeric sequence.
109
+
110
+ Two-pass strategy prevents conflicts:
111
+ 1. NUMBERS_AND_IDENTIFIER: handles digit-to-letter transitions
112
+ 2. SEPARATORS_AND_IDENTIFIER: handles separator-to-identifier transitions
113
+
114
+ Example: "b2b_registration" with capitalizeAfterNumber: true
115
+ - Pass 1: "2b" matches, next char is "_" (separator), so don't capitalize → "b2b_registration"
116
+ - Pass 2: "_r" matches, replace with "R" → "b2bRegistration"
117
+ */
118
+ const postProcess = (input, toUpperCase, {capitalizeAfterNumber}) => {
119
+ const transformNumericIdentifier = capitalizeAfterNumber
120
+ ? (match, identifier, offset, string) => {
121
+ const nextCharacter = string.charAt(offset + match.length);
122
+
123
+ // If the numeric+identifier run is immediately followed by a separator,
124
+ // treat it as a continued token and do not force a new word.
125
+ if (SEPARATORS.test(nextCharacter)) {
126
+ return match;
127
+ }
128
+
129
+ // Only uppercase the identifier part (not the digits) for efficiency
130
+ return identifier ? match.slice(0, -identifier.length) + toUpperCase(identifier) : match;
131
+ }
132
+ // When false: numbers do not create a word boundary.
133
+ : match => match;
134
+
135
+ return input
136
+ .replaceAll(NUMBERS_AND_IDENTIFIER, transformNumericIdentifier)
137
+ .replaceAll(
138
+ SEPARATORS_AND_IDENTIFIER,
139
+ (_, identifier) => toUpperCase(identifier),
140
+ );
141
+ };
142
+
143
+ export default function camelCase(input, options) {
144
+ if (!(typeof input === 'string' || Array.isArray(input))) {
145
+ throw new TypeError('Expected the input to be `string | string[]`');
146
+ }
147
+
148
+ options = {
149
+ pascalCase: false,
150
+ preserveConsecutiveUppercase: false,
151
+ capitalizeAfterNumber: true,
152
+ ...options,
153
+ };
154
+
155
+ if (Array.isArray(input)) {
156
+ input = input
157
+ .map(element => element.trim())
158
+ .filter(element => element.length > 0)
159
+ .join('-');
160
+ } else {
161
+ input = input.trim();
162
+ }
163
+
164
+ if (input.length === 0) {
165
+ return '';
166
+ }
167
+
168
+ // Preserve leading _ and $ as they have semantic meaning
169
+ const leadingPrefix = input.match(/^[_$]*/)[0];
170
+ input = input.slice(leadingPrefix.length);
171
+
172
+ if (input.length === 0) {
173
+ return leadingPrefix;
174
+ }
175
+
176
+ const toLowerCase = options.locale === false
177
+ ? string => string.toLowerCase()
178
+ : string => string.toLocaleLowerCase(options.locale);
179
+
180
+ const toUpperCase = options.locale === false
181
+ ? string => string.toUpperCase()
182
+ : string => string.toLocaleUpperCase(options.locale);
183
+
184
+ if (input.length === 1) {
185
+ if (SEPARATORS.test(input)) {
186
+ return leadingPrefix;
187
+ }
188
+
189
+ return leadingPrefix + (options.pascalCase
190
+ ? toUpperCase(input)
191
+ : toLowerCase(input));
192
+ }
193
+
194
+ const hasUpperCase = input !== toLowerCase(input);
195
+
196
+ if (hasUpperCase) {
197
+ input = preserveCamelCase(
198
+ input,
199
+ toLowerCase,
200
+ toUpperCase,
201
+ options.preserveConsecutiveUppercase,
202
+ );
203
+ }
204
+
205
+ // Strip leading separators eagerly so they do not affect word detection
206
+ input = input.replace(LEADING_SEPARATORS, '');
207
+
208
+ // Normalize base casing while preserving intended consecutive uppers
209
+ if (options.capitalizeAfterNumber) {
210
+ // Standard behavior - lowercase everything (or preserve consecutive uppercase)
211
+ input = options.preserveConsecutiveUppercase
212
+ ? preserveConsecutiveUppercase(input, toLowerCase)
213
+ : toLowerCase(input);
214
+ } else {
215
+ // Preserve case after numbers (processWithCasePreservation handles preserveConsecutiveUppercase internally)
216
+ input = processWithCasePreservation(input, toLowerCase, options.preserveConsecutiveUppercase);
217
+ }
218
+
219
+ if (options.pascalCase && input.length > 0) {
220
+ input = toUpperCase(input[0]) + input.slice(1);
221
+ }
222
+
223
+ return leadingPrefix + postProcess(input, toUpperCase, options);
224
+ }
package/license ADDED
@@ -0,0 +1,9 @@
1
+ MIT License
2
+
3
+ Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6
+
7
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8
+
9
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/package.json CHANGED
@@ -1,6 +1,77 @@
1
1
  {
2
2
  "name": "@cjser/camelcase__v9_0_0",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "9.0.0-cjser.2",
4
+ "description": "Convert a dash/dot/underscore/space separated string to camelCase or PascalCase: `foo-bar` → `fooBar`",
5
+ "license": "MIT",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "https://code.moenext.com/3rdeye/cjser.git"
9
+ },
10
+ "funding": "https://github.com/sponsors/sindresorhus",
11
+ "author": {
12
+ "name": "Sindre Sorhus",
13
+ "email": "sindresorhus@gmail.com",
14
+ "url": "https://sindresorhus.com"
15
+ },
16
+ "type": "module",
17
+ "exports": {
18
+ "types": "./index.d.ts",
19
+ "require": "./dist-cjser/index.cjs",
20
+ "default": "./index.js"
21
+ },
22
+ "sideEffects": false,
23
+ "engines": {
24
+ "node": ">=20"
25
+ },
26
+ "scripts": {
27
+ "test": "xo && ava && tsd"
28
+ },
29
+ "files": [
30
+ "index.js",
31
+ "index.d.ts",
32
+ "dist-cjser"
33
+ ],
34
+ "keywords": [
35
+ "camelcase",
36
+ "camel-case",
37
+ "camel",
38
+ "case",
39
+ "dash",
40
+ "hyphen",
41
+ "dot",
42
+ "underscore",
43
+ "separator",
44
+ "string",
45
+ "text",
46
+ "convert",
47
+ "pascalcase",
48
+ "pascal-case"
49
+ ],
50
+ "devDependencies": {
51
+ "ava": "^6.4.1",
52
+ "tsd": "^0.33.0",
53
+ "xo": "^1.2.3"
54
+ },
55
+ "types": "./index.d.ts",
56
+ "main": "./dist-cjser/index.cjs",
57
+ "cjser": {
58
+ "sourceVersion": "9.0.0",
59
+ "cjserVersion": 2,
60
+ "original": {
61
+ "name": "camelcase",
62
+ "version": "9.0.0",
63
+ "exports": {
64
+ "types": "./index.d.ts",
65
+ "default": "./index.js"
66
+ },
67
+ "repository": "sindresorhus/camelcase",
68
+ "files": [
69
+ "index.js",
70
+ "index.d.ts"
71
+ ],
72
+ "scripts": {
73
+ "test": "xo && ava && tsd"
74
+ }
75
+ }
76
+ }
77
+ }
package/readme.md ADDED
@@ -0,0 +1,179 @@
1
+ # camelcase
2
+
3
+ > Convert a dash/dot/underscore/space separated string to camelCase or PascalCase: `foo-bar` → `fooBar`
4
+
5
+ Correctly handles Unicode strings.
6
+
7
+ If you use this on untrusted user input, don't forget to limit the length to something reasonable.
8
+
9
+ ## Install
10
+
11
+ ```sh
12
+ npm install camelcase
13
+ ```
14
+
15
+ ## Usage
16
+
17
+ ```js
18
+ import camelCase from 'camelcase';
19
+
20
+ camelCase('foo-bar');
21
+ //=> 'fooBar'
22
+
23
+ camelCase('foo_bar');
24
+ //=> 'fooBar'
25
+
26
+ camelCase('Foo-Bar');
27
+ //=> 'fooBar'
28
+
29
+ camelCase('розовый_пушистый_единорог');
30
+ //=> 'розовыйПушистыйЕдинорог'
31
+
32
+ camelCase('foo bar');
33
+ //=> 'fooBar'
34
+
35
+ console.log(process.argv[3]);
36
+ //=> '--foo-bar'
37
+ camelCase(process.argv[3]);
38
+ //=> 'fooBar'
39
+
40
+ camelCase(['foo', 'bar']);
41
+ //=> 'fooBar'
42
+
43
+ camelCase(['__foo__', '--bar']);
44
+ //=> '__fooBar'
45
+ ```
46
+
47
+ > [!NOTE]
48
+ > Not idempotent when special characters are present. `camelCase('{ A')` → `'{A}'`, but `camelCase('{A}')` → `'{a}'`.
49
+
50
+ ## API
51
+
52
+ ### camelCase(input, options?)
53
+
54
+ #### input
55
+
56
+ Type: `string | string[]`
57
+
58
+ The string to convert to camel case.
59
+
60
+ #### options
61
+
62
+ Type: `object`
63
+
64
+ ##### pascalCase
65
+
66
+ Type: `boolean`\
67
+ Default: `false`
68
+
69
+ Uppercase the first character: `foo-bar` → `FooBar`
70
+
71
+ ```js
72
+ import camelCase from 'camelcase';
73
+
74
+ camelCase('foo-bar', {pascalCase: true});
75
+ //=> 'FooBar'
76
+
77
+ camelCase('foo-bar', {pascalCase: false});
78
+ //=> 'fooBar'
79
+ ```
80
+
81
+ ##### preserveConsecutiveUppercase
82
+
83
+ Type: `boolean`\
84
+ Default: `false`
85
+
86
+ Preserve consecutive uppercase characters: `foo-BAR` → `FooBAR`
87
+
88
+ ```js
89
+ import camelCase from 'camelcase';
90
+
91
+ camelCase('foo-BAR', {preserveConsecutiveUppercase: true});
92
+ //=> 'fooBAR'
93
+
94
+ camelCase('foo-BAR', {preserveConsecutiveUppercase: false});
95
+ //=> 'fooBar'
96
+ ````
97
+
98
+ ##### capitalizeAfterNumber
99
+
100
+ Type: `boolean`\
101
+ Default: `true`
102
+
103
+ Controls whether letters immediately following digits are treated as word boundaries.
104
+
105
+ **When `true` (default):**
106
+ Capitalize the first letter immediately following a numeric sequence, unless a separator intervenes. This aligns with most utilities, such as Lodash.
107
+
108
+ **When `false`:**
109
+ Do not treat digits as word boundaries. Preserve the original case of letters immediately following digits. Separators still create word boundaries. This follows the Google Java Style Guide which treats numbers as non-boundary characters.
110
+
111
+ ```js
112
+ import camelCase from 'camelcase';
113
+
114
+ camelCase('foo2bar', {capitalizeAfterNumber: true});
115
+ //=> 'foo2Bar' (capitalizes 'b' after digit)
116
+
117
+ camelCase('foo2bar', {capitalizeAfterNumber: false});
118
+ //=> 'foo2bar' (preserves lowercase 'b')
119
+
120
+ // Preserves original case after numbers when false
121
+ camelCase('Textures_3d', {capitalizeAfterNumber: false});
122
+ //=> 'textures3d' (preserves lowercase 'd')
123
+
124
+ camelCase('Textures_3D', {capitalizeAfterNumber: false});
125
+ //=> 'textures3D' (preserves uppercase 'D')
126
+
127
+ // Separators still create boundaries
128
+ camelCase('foo_2_bar', {capitalizeAfterNumber: false});
129
+ //=> 'foo2Bar' ('bar' follows separator, not digit)
130
+ ```
131
+
132
+ ##### locale
133
+
134
+ Type: `false | string | string[]`\
135
+ Default: The host environment’s current locale.
136
+
137
+ 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.
138
+
139
+ ```js
140
+ import camelCase from 'camelcase';
141
+
142
+ camelCase('lorem-ipsum', {locale: 'en-US'});
143
+ //=> 'loremIpsum'
144
+
145
+ camelCase('lorem-ipsum', {locale: 'tr-TR'});
146
+ //=> 'loremİpsum'
147
+
148
+ camelCase('lorem-ipsum', {locale: ['en-US', 'en-GB']});
149
+ //=> 'loremIpsum'
150
+
151
+ camelCase('lorem-ipsum', {locale: ['tr', 'TR', 'tr-TR']});
152
+ //=> 'loremİpsum'
153
+ ```
154
+
155
+ 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:
156
+
157
+ ```js
158
+ import camelCase from 'camelcase';
159
+
160
+ // On a platform with `tr-TR`.
161
+
162
+ camelCase('lorem-ipsum');
163
+ //=> 'loremİpsum'
164
+
165
+ camelCase('lorem-ipsum', {locale: false});
166
+ //=> 'loremIpsum'
167
+ ```
168
+
169
+ ## Related
170
+
171
+ - [decamelize](https://github.com/sindresorhus/decamelize) - The inverse of this module
172
+ - [titleize](https://github.com/sindresorhus/titleize) - Capitalize every word in string
173
+ - [humanize-string](https://github.com/sindresorhus/humanize-string) - Convert a camelized/dasherized/underscored string into a humanized one
174
+ - [camelcase-keys](https://github.com/sindresorhus/camelcase-keys) - Convert object keys to camel case
175
+
176
+ ## cjser
177
+
178
+ This package is a CommonJS-compatible build generated by cjser for projects that still need `require()` support. The source version matches the original npm package version, with a cjser prerelease suffix for this generated build.
179
+ Original repository: https://github.com/sindresorhus/camelcase
package/README.md DELETED
@@ -1,3 +0,0 @@
1
- # Temporary Holding Version
2
-
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.