caseparser 4.3.0 → 5.1.0
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.
- package/README.md +196 -85
- package/dist/index.cjs +125 -143
- package/dist/index.d.cts +373 -44
- package/dist/index.d.ts +373 -44
- package/dist/index.js +119 -142
- package/package.json +15 -3
package/dist/index.d.cts
CHANGED
|
@@ -121,7 +121,7 @@ type Result<T, P> = T extends string ? string : T extends Array<unknown> ? { [K
|
|
|
121
121
|
* camelToDash({ firstName: 'John' }); // { 'first-name': 'John' }
|
|
122
122
|
* ```
|
|
123
123
|
*
|
|
124
|
-
* @deprecated Use `
|
|
124
|
+
* @deprecated Use `toKebab` instead, which converts from any case. It keeps acronyms together,
|
|
125
125
|
* so results differ for keys like `userID` (see the migration notes in the README).
|
|
126
126
|
*/
|
|
127
127
|
export declare function camelToDash<T extends object | string>(input: T): Result<T, "CamelToDash">;
|
|
@@ -173,7 +173,7 @@ export declare function camelToUpperSnake<T extends object | string>(input: T):
|
|
|
173
173
|
* camelToUpperDash({ firstName: 'John' }); // { 'FIRST-NAME': 'John' }
|
|
174
174
|
* ```
|
|
175
175
|
*
|
|
176
|
-
* @deprecated Use `
|
|
176
|
+
* @deprecated Use `toUpperKebab` instead, which converts from any case. It keeps acronyms together,
|
|
177
177
|
* so results differ for keys like `userID` (see the migration notes in the README).
|
|
178
178
|
*/
|
|
179
179
|
export declare function camelToUpperDash<T extends object | string>(input: T): Result<T, "CamelToUpperDash">;
|
|
@@ -292,7 +292,7 @@ export declare function dashToUpperSnake<T extends object | string>(input: T): R
|
|
|
292
292
|
* dashToUpperDash({ 'first-name': 'John' }); // { 'FIRST-NAME': 'John' }
|
|
293
293
|
* ```
|
|
294
294
|
*
|
|
295
|
-
* @deprecated Use `
|
|
295
|
+
* @deprecated Use `toUpperKebab` instead, which converts from any case. It keeps acronyms together,
|
|
296
296
|
* so results differ for keys like `userID` (see the migration notes in the README).
|
|
297
297
|
*/
|
|
298
298
|
export declare function dashToUpperDash<T extends object | string>(input: T): Result<T, "DashToUpperDash">;
|
|
@@ -385,7 +385,7 @@ export declare function pascalToSnake<T extends object | string>(input: T): Resu
|
|
|
385
385
|
* pascalToDash({ FirstName: 'John' }); // { 'first-name': 'John' }
|
|
386
386
|
* ```
|
|
387
387
|
*
|
|
388
|
-
* @deprecated Use `
|
|
388
|
+
* @deprecated Use `toKebab` instead, which converts from any case. It keeps acronyms together,
|
|
389
389
|
* so results differ for keys like `userID` (see the migration notes in the README).
|
|
390
390
|
*/
|
|
391
391
|
export declare function pascalToDash<T extends object | string>(input: T): Result<T, "PascalToDash">;
|
|
@@ -411,7 +411,7 @@ export declare function pascalToUpperSnake<T extends object | string>(input: T):
|
|
|
411
411
|
* pascalToUpperDash({ FirstName: 'John' }); // { 'FIRST-NAME': 'John' }
|
|
412
412
|
* ```
|
|
413
413
|
*
|
|
414
|
-
* @deprecated Use `
|
|
414
|
+
* @deprecated Use `toUpperKebab` instead, which converts from any case. It keeps acronyms together,
|
|
415
415
|
* so results differ for keys like `userID` (see the migration notes in the README).
|
|
416
416
|
*/
|
|
417
417
|
export declare function pascalToUpperDash<T extends object | string>(input: T): Result<T, "PascalToUpperDash">;
|
|
@@ -491,7 +491,7 @@ export declare function snakeToCamel<T extends object | string>(input: T): Resul
|
|
|
491
491
|
* snakeToDash({ first_name: 'John' }); // { 'first-name': 'John' }
|
|
492
492
|
* ```
|
|
493
493
|
*
|
|
494
|
-
* @deprecated Use `
|
|
494
|
+
* @deprecated Use `toKebab` instead, which converts from any case. It keeps acronyms together,
|
|
495
495
|
* so results differ for keys like `userID` (see the migration notes in the README).
|
|
496
496
|
*/
|
|
497
497
|
export declare function snakeToDash<T extends object | string>(input: T): Result<T, "SnakeToDash">;
|
|
@@ -530,7 +530,7 @@ export declare function snakeToUpperSnake<T extends object | string>(input: T):
|
|
|
530
530
|
* snakeToUpperDash({ first_name: 'John' }); // { 'FIRST-NAME': 'John' }
|
|
531
531
|
* ```
|
|
532
532
|
*
|
|
533
|
-
* @deprecated Use `
|
|
533
|
+
* @deprecated Use `toUpperKebab` instead, which converts from any case. It keeps acronyms together,
|
|
534
534
|
* so results differ for keys like `userID` (see the migration notes in the README).
|
|
535
535
|
*/
|
|
536
536
|
export declare function snakeToUpperDash<T extends object | string>(input: T): Result<T, "SnakeToUpperDash">;
|
|
@@ -636,7 +636,7 @@ export declare function trainToSnake<T extends object | string>(input: T): Resul
|
|
|
636
636
|
* trainToDash({ 'First-Name': 'John' }); // { 'first-name': 'John' }
|
|
637
637
|
* ```
|
|
638
638
|
*
|
|
639
|
-
* @deprecated Use `
|
|
639
|
+
* @deprecated Use `toKebab` instead, which converts from any case. It keeps acronyms together,
|
|
640
640
|
* so results differ for keys like `userID` (see the migration notes in the README).
|
|
641
641
|
*/
|
|
642
642
|
export declare function trainToDash<T extends object | string>(input: T): Result<T, "TrainToDash">;
|
|
@@ -662,7 +662,7 @@ export declare function trainToUpperSnake<T extends object | string>(input: T):
|
|
|
662
662
|
* trainToUpperDash({ 'First-Name': 'John' }); // { 'FIRST-NAME': 'John' }
|
|
663
663
|
* ```
|
|
664
664
|
*
|
|
665
|
-
* @deprecated Use `
|
|
665
|
+
* @deprecated Use `toUpperKebab` instead, which converts from any case. It keeps acronyms together,
|
|
666
666
|
* so results differ for keys like `userID` (see the migration notes in the README).
|
|
667
667
|
*/
|
|
668
668
|
export declare function trainToUpperDash<T extends object | string>(input: T): Result<T, "TrainToUpperDash">;
|
|
@@ -755,7 +755,7 @@ export declare function dotToSnake<T extends object | string>(input: T): Result<
|
|
|
755
755
|
* dotToDash({ 'first.name': 'John' }); // { 'first-name': 'John' }
|
|
756
756
|
* ```
|
|
757
757
|
*
|
|
758
|
-
* @deprecated Use `
|
|
758
|
+
* @deprecated Use `toKebab` instead, which converts from any case. It keeps acronyms together,
|
|
759
759
|
* so results differ for keys like `userID` (see the migration notes in the README).
|
|
760
760
|
*/
|
|
761
761
|
export declare function dotToDash<T extends object | string>(input: T): Result<T, "DotToDash">;
|
|
@@ -781,7 +781,7 @@ export declare function dotToUpperSnake<T extends object | string>(input: T): Re
|
|
|
781
781
|
* dotToUpperDash({ 'first.name': 'John' }); // { 'FIRST-NAME': 'John' }
|
|
782
782
|
* ```
|
|
783
783
|
*
|
|
784
|
-
* @deprecated Use `
|
|
784
|
+
* @deprecated Use `toUpperKebab` instead, which converts from any case. It keeps acronyms together,
|
|
785
785
|
* so results differ for keys like `userID` (see the migration notes in the README).
|
|
786
786
|
*/
|
|
787
787
|
export declare function dotToUpperDash<T extends object | string>(input: T): Result<T, "DotToUpperDash">;
|
|
@@ -874,7 +874,7 @@ export declare function titleToSnake<T extends object | string>(input: T): Resul
|
|
|
874
874
|
* titleToDash({ 'First Name': 'John' }); // { 'first-name': 'John' }
|
|
875
875
|
* ```
|
|
876
876
|
*
|
|
877
|
-
* @deprecated Use `
|
|
877
|
+
* @deprecated Use `toKebab` instead, which converts from any case. It keeps acronyms together,
|
|
878
878
|
* so results differ for keys like `userID` (see the migration notes in the README).
|
|
879
879
|
*/
|
|
880
880
|
export declare function titleToDash<T extends object | string>(input: T): Result<T, "TitleToDash">;
|
|
@@ -900,7 +900,7 @@ export declare function titleToUpperSnake<T extends object | string>(input: T):
|
|
|
900
900
|
* titleToUpperDash({ 'First Name': 'John' }); // { 'FIRST-NAME': 'John' }
|
|
901
901
|
* ```
|
|
902
902
|
*
|
|
903
|
-
* @deprecated Use `
|
|
903
|
+
* @deprecated Use `toUpperKebab` instead, which converts from any case. It keeps acronyms together,
|
|
904
904
|
* so results differ for keys like `userID` (see the migration notes in the README).
|
|
905
905
|
*/
|
|
906
906
|
export declare function titleToUpperDash<T extends object | string>(input: T): Result<T, "TitleToUpperDash">;
|
|
@@ -993,7 +993,7 @@ export declare function sentenceToSnake<T extends object | string>(input: T): Re
|
|
|
993
993
|
* sentenceToDash({ 'First name': 'John' }); // { 'first-name': 'John' }
|
|
994
994
|
* ```
|
|
995
995
|
*
|
|
996
|
-
* @deprecated Use `
|
|
996
|
+
* @deprecated Use `toKebab` instead, which converts from any case. It keeps acronyms together,
|
|
997
997
|
* so results differ for keys like `userID` (see the migration notes in the README).
|
|
998
998
|
*/
|
|
999
999
|
export declare function sentenceToDash<T extends object | string>(input: T): Result<T, "SentenceToDash">;
|
|
@@ -1019,7 +1019,7 @@ export declare function sentenceToUpperSnake<T extends object | string>(input: T
|
|
|
1019
1019
|
* sentenceToUpperDash({ 'First name': 'John' }); // { 'FIRST-NAME': 'John' }
|
|
1020
1020
|
* ```
|
|
1021
1021
|
*
|
|
1022
|
-
* @deprecated Use `
|
|
1022
|
+
* @deprecated Use `toUpperKebab` instead, which converts from any case. It keeps acronyms together,
|
|
1023
1023
|
* so results differ for keys like `userID` (see the migration notes in the README).
|
|
1024
1024
|
*/
|
|
1025
1025
|
export declare function sentenceToUpperDash<T extends object | string>(input: T): Result<T, "SentenceToUpperDash">;
|
|
@@ -1099,7 +1099,7 @@ export declare function upperDashToSnake<T extends object | string>(input: T): R
|
|
|
1099
1099
|
* upperDashToDash({ 'FIRST-NAME': 'John' }); // { 'first-name': 'John' }
|
|
1100
1100
|
* ```
|
|
1101
1101
|
*
|
|
1102
|
-
* @deprecated Use `
|
|
1102
|
+
* @deprecated Use `toKebab` instead, which converts from any case. It keeps acronyms together,
|
|
1103
1103
|
* so results differ for keys like `userID` (see the migration notes in the README).
|
|
1104
1104
|
*/
|
|
1105
1105
|
export declare function upperDashToDash<T extends object | string>(input: T): Result<T, "UpperDashToDash">;
|
|
@@ -1218,7 +1218,7 @@ export declare function upperSnakeToSnake<T extends object | string>(input: T):
|
|
|
1218
1218
|
* upperSnakeToDash({ FIRST_NAME: 'John' }); // { 'first-name': 'John' }
|
|
1219
1219
|
* ```
|
|
1220
1220
|
*
|
|
1221
|
-
* @deprecated Use `
|
|
1221
|
+
* @deprecated Use `toKebab` instead, which converts from any case. It keeps acronyms together,
|
|
1222
1222
|
* so results differ for keys like `userID` (see the migration notes in the README).
|
|
1223
1223
|
*/
|
|
1224
1224
|
export declare function upperSnakeToDash<T extends object | string>(input: T): Result<T, "UpperSnakeToDash">;
|
|
@@ -1244,7 +1244,7 @@ export declare function upperSnakeToPascal<T extends object | string>(input: T):
|
|
|
1244
1244
|
* upperSnakeToUpperDash({ FIRST_NAME: 'John' }); // { 'FIRST-NAME': 'John' }
|
|
1245
1245
|
* ```
|
|
1246
1246
|
*
|
|
1247
|
-
* @deprecated Use `
|
|
1247
|
+
* @deprecated Use `toUpperKebab` instead, which converts from any case. It keeps acronyms together,
|
|
1248
1248
|
* so results differ for keys like `userID` (see the migration notes in the README).
|
|
1249
1249
|
*/
|
|
1250
1250
|
export declare function upperSnakeToUpperDash<T extends object | string>(input: T): Result<T, "UpperSnakeToUpperDash">;
|
|
@@ -1303,26 +1303,70 @@ export declare function upperSnakeToSentence<T extends object | string>(input: T
|
|
|
1303
1303
|
//#endregion
|
|
1304
1304
|
//#region src/anyCase/types.d.ts
|
|
1305
1305
|
type Separator = "_" | "-" | "." | " ";
|
|
1306
|
+
/** ASCII punctuation, except the separators `_`, `-` and `.`. */
|
|
1307
|
+
type SymbolChar = "!" | "\"" | "#" | "$" | "%" | "&" | "'" | "(" | ")" | "*" | "+" | "," | "/" | ":" | ";" | "<" | "=" | ">" | "?" | "@" | "[" | "\\" | "]" | "^" | "`" | "{" | "|" | "}" | "~";
|
|
1308
|
+
/**
|
|
1309
|
+
* Which symbols the `toX` functions keep: `true` keeps all of them, `false` (the default)
|
|
1310
|
+
* removes all of them, and an array keeps only the listed ones (e.g. `['$', '@']`).
|
|
1311
|
+
*/
|
|
1312
|
+
type AllowSymbols = boolean | readonly string[];
|
|
1313
|
+
/**
|
|
1314
|
+
* @deprecated Renamed to `AllowSymbols`. It will be removed in the next major version.
|
|
1315
|
+
*/
|
|
1316
|
+
type KeepSymbols = AllowSymbols;
|
|
1317
|
+
/** Changes the case of the whole result: `'lowercase'` or `'uppercase'`. */
|
|
1318
|
+
type Transform = "uppercase" | "lowercase";
|
|
1319
|
+
/** The options of the `toX` functions. `S` is inferred from `allowSymbols`. */
|
|
1320
|
+
interface CaseOptions<S = boolean | string> {
|
|
1321
|
+
/** Symbols are removed by default. `true` keeps all of them, and an array keeps only the listed ones (e.g. `['$']`). */
|
|
1322
|
+
allowSymbols?: S | readonly S[];
|
|
1323
|
+
}
|
|
1324
|
+
/** The options of `toDot` and `toPath`, which also take a `transform`. `X` is inferred from `transform`. */
|
|
1325
|
+
interface TransformCaseOptions<S = boolean | string, X extends Transform | undefined = Transform | undefined> extends CaseOptions<S> {
|
|
1326
|
+
/** The original case of each word is kept by default. `'lowercase'` or `'uppercase'` changes the case of the whole result. */
|
|
1327
|
+
transform?: X;
|
|
1328
|
+
}
|
|
1329
|
+
/** The separator that `toPath` joins the words with: `'/'` (the default) or `'\\'`. */
|
|
1330
|
+
type PathSeparator = "/" | "\\";
|
|
1331
|
+
/** The options of `toPath`, which also take a `separator`. `P` is inferred from `separator`. */
|
|
1332
|
+
interface PathCaseOptions<S = boolean | string, X extends Transform | undefined = Transform | undefined, P extends PathSeparator = PathSeparator> extends TransformCaseOptions<S, X> {
|
|
1333
|
+
/** Joins the words with `'/'` (the default) or `'\\'`. */
|
|
1334
|
+
separator?: P;
|
|
1335
|
+
}
|
|
1306
1336
|
type IsUpper<C extends string> = C extends Lowercase<C> ? false : true;
|
|
1307
1337
|
type IsLower<C extends string> = C extends Uppercase<C> ? false : true;
|
|
1308
|
-
type Push<W extends string[], Word extends string> = Word extends "" ? W : [...W, Lowercase<Word>];
|
|
1338
|
+
type Push<L extends boolean, W extends string[], Word extends string> = Word extends "" ? W : [...W, L extends true ? Lowercase<Word> : Word];
|
|
1339
|
+
type RunText<Run> = Run extends string ? Run : "";
|
|
1309
1340
|
/**
|
|
1310
1341
|
* Splits a string into lowercase words, the same way `words()` does at runtime:
|
|
1311
1342
|
* on `_`, `-`, `.` and spaces, before an uppercase letter that follows a lowercase
|
|
1312
1343
|
* letter or a digit (`helloWorld`), and before the last letter of an acronym (`XMLHttp`).
|
|
1344
|
+
* Symbols also start a new word; the ones in `S` are kept (see `words()`). Words are lowercased
|
|
1345
|
+
* unless `L` is `false`. `Run` holds the kept symbols of the current run of symbols, or `false`
|
|
1346
|
+
* outside of one.
|
|
1313
1347
|
*/
|
|
1314
|
-
type Words<T extends string, W extends string[] = [], Word extends string = "", Prev extends string = ""> = T extends `${infer C}${infer Rest}` ? C extends Separator ? Words<Rest, Push<W, Word
|
|
1348
|
+
type Words<T extends string, S extends string, L extends boolean = true, W extends string[] = [], Word extends string = "", Prev extends string = "", Run extends string | false = false> = T extends `${infer C}${infer Rest}` ? C extends Separator | SymbolChar ? C extends Separator ? Words<Rest, S, L, Push<L, W, `${Word}${RunText<Run>}`>, "", "", false> : Words<Rest, S, L, W, Word, Prev, `${RunText<Run>}${C extends S ? C : ""}`> : Run extends string ? Words<Rest, S, L, Push<L, W, Word>, `${Run}${C}`, C, false> : IsUpper<C> extends true ? Prev extends "" ? Words<Rest, S, L, W, `${Word}${C}`, C> : IsUpper<Prev> extends false ? Words<Rest, S, L, Push<L, W, Word>, C, C> : Rest extends `${infer Next}${string}` ? IsLower<Next> extends true ? Words<Rest, S, L, Push<L, W, Word>, C, C> : Words<Rest, S, L, W, `${Word}${C}`, C> : Words<Rest, S, L, W, `${Word}${C}`, C> : Words<Rest, S, L, W, `${Word}${C}`, C> : Push<L, W, `${Word}${RunText<Run>}`>;
|
|
1349
|
+
/** Uppercases the first character that is not a symbol: `'$id'` → `'$Id'`. */
|
|
1350
|
+
type CapitalizeWord<W> = W extends `${infer C}${infer R}` ? C extends SymbolChar ? `${C}${CapitalizeWord<R>}` : `${Uppercase<C>}${R}` : W;
|
|
1315
1351
|
type Join<W, S extends string> = W extends [infer A] ? A & string : W extends [infer A, ...infer R] ? `${A & string}${S}${Join<R, S>}` : "";
|
|
1316
|
-
type CapitalizeAll<W> = { [K in keyof W]:
|
|
1352
|
+
type CapitalizeAll<W> = { [K in keyof W]: CapitalizeWord<W[K] & string>; };
|
|
1353
|
+
/** In a path, `/` and `\\` also separate words: they are replaced with a space before splitting, like `ToPath` does. */
|
|
1354
|
+
type PathSeparatorsToSpace<T extends string> = T extends `${infer A}/${infer B}` ? PathSeparatorsToSpace<`${A} ${B}`> : T extends `${infer A}\\${infer B}` ? PathSeparatorsToSpace<`${A} ${B}`> : T;
|
|
1317
1355
|
type CamelWords<W> = W extends [infer F, ...infer R] ? `${F & string}${Join<CapitalizeAll<R>, "">}` : "";
|
|
1318
1356
|
/** A case that the `toX` functions (e.g. `toSnake`) convert to. */
|
|
1319
|
-
type Case = "Camel" | "Pascal" | "Snake" | "
|
|
1320
|
-
|
|
1357
|
+
type Case = "Camel" | "Pascal" | "Snake" | "Kebab" | "UpperSnake" | "UpperKebab" | "Train" | "Dot" | "Title" | "Sentence" | "PascalSnake" | "Path" | "Space" | "Lower" | "Upper";
|
|
1358
|
+
/** The symbols kept by an `allowSymbols` argument: `true` → all, `false` → none, `'$' | '@'` → those. */
|
|
1359
|
+
type KeptSymbols<S> = S extends true ? SymbolChar : S extends false ? never : S & string;
|
|
1360
|
+
/** Applies a `transform` to a converted key, or falls back to `string` when it is only known at runtime. */
|
|
1361
|
+
type ApplyTransform<K extends string, X> = [X] extends [undefined] ? K : [X] extends ["lowercase"] ? Lowercase<K> : [X] extends ["uppercase"] ? Uppercase<K> : string;
|
|
1362
|
+
type ConvertKey<K extends string, C extends Case, S extends string, P extends string = "/"> = string extends K ? string : C extends "Camel" ? CamelWords<Words<K, S>> : C extends "Pascal" ? Join<CapitalizeAll<Words<K, S>>, ""> : C extends "Snake" ? Join<Words<K, S>, "_"> : C extends "Kebab" ? Join<Words<K, S>, "-"> : C extends "UpperSnake" ? Uppercase<Join<Words<K, S>, "_">> : C extends "UpperKebab" ? Uppercase<Join<Words<K, S>, "-">> : C extends "Train" ? Join<CapitalizeAll<Words<K, S>>, "-"> : C extends "Dot" ? Join<Words<K, S, false>, "."> : C extends "Title" ? Join<CapitalizeAll<Words<K, S>>, " "> : C extends "Sentence" ? CapitalizeWord<Join<Words<K, S>, " ">> : C extends "PascalSnake" ? Join<CapitalizeAll<Words<K, S>>, "_"> : C extends "Path" ? Join<Words<PathSeparatorsToSpace<K>, S, false>, P> : C extends "Space" ? Join<Words<K, S, false>, " "> : C extends "Lower" ? Join<Words<K, S>, " "> : C extends "Upper" ? Uppercase<Join<Words<K, S>, " ">> : never;
|
|
1321
1363
|
/**
|
|
1322
1364
|
* The type returned by a `toX` function: strings stay `string`, and object keys
|
|
1323
1365
|
* in any case (deeply, including inside arrays) are renamed to the case `C`.
|
|
1366
|
+
* `S` is the `allowSymbols` argument (`false` by default), `X` the `transform` option of `toDot` and `toPath`,
|
|
1367
|
+
* and `P` the `separator` option of `toPath`.
|
|
1324
1368
|
*/
|
|
1325
|
-
type CaseResult<T, C extends Case> = T extends string ? string : T extends Array<unknown> ? { [K in keyof T]: CaseResult<T[K], C>; } : T extends object ? Prettify<{ [K in keyof T as ConvertKey<K & string, C>]: CaseResult<T[K], C>; }> : T;
|
|
1369
|
+
type CaseResult<T, C extends Case, S = false, X = undefined, P extends string = "/"> = T extends string ? string : T extends Array<unknown> ? { [K in keyof T]: CaseResult<T[K], C, S, X, P>; } : T extends object ? Prettify<{ [K in keyof T as boolean extends S ? string : string extends KeptSymbols<S> ? string : ApplyTransform<ConvertKey<K & string, C, KeptSymbols<S>, P>, X>]: CaseResult<T[K], C, S, X, P>; }> : T;
|
|
1326
1370
|
//#endregion
|
|
1327
1371
|
//#region src/anyCase/anyCase.d.ts
|
|
1328
1372
|
/**
|
|
@@ -1332,9 +1376,24 @@ type CaseResult<T, C extends Case> = T extends string ? string : T extends Array
|
|
|
1332
1376
|
* ```ts
|
|
1333
1377
|
* toCamel('hello_world'); // 'helloWorld'
|
|
1334
1378
|
* toCamel({ first_name: 'John', userID: 1 }); // { firstName: 'John', userId: 1 }
|
|
1379
|
+
* toCamel('$hello-world', true); // '$helloWorld'
|
|
1335
1380
|
* ```
|
|
1381
|
+
*
|
|
1382
|
+
* @param allowSymbols Symbols (ASCII punctuation, like `$` or `@`) are removed by default.
|
|
1383
|
+
* Pass `true` to keep all of them, or an array to keep only some (e.g. `['$']`).
|
|
1384
|
+
*/
|
|
1385
|
+
export declare function toCamel<T extends object | string, S extends boolean | string = false>(input: T, allowSymbols?: S | readonly S[]): CaseResult<T, "Camel", S>;
|
|
1386
|
+
/**
|
|
1387
|
+
* Converts a string, or the keys of an object/array (deeply), from any case to camelCase.
|
|
1388
|
+
*
|
|
1389
|
+
* @example
|
|
1390
|
+
* ```ts
|
|
1391
|
+
* toCamel('$hello-world', { allowSymbols: ['$'] }); // '$helloWorld'
|
|
1392
|
+
* ```
|
|
1393
|
+
*
|
|
1394
|
+
* @param options `allowSymbols`: symbols are removed by default; `true` keeps all of them, and an array keeps only some.
|
|
1336
1395
|
*/
|
|
1337
|
-
export declare function toCamel<T extends object | string>(input: T): CaseResult<T, "Camel">;
|
|
1396
|
+
export declare function toCamel<T extends object | string, S extends boolean | string = false>(input: T, options: CaseOptions<S>): CaseResult<T, "Camel", S>;
|
|
1338
1397
|
/**
|
|
1339
1398
|
* Converts a string, or the keys of an object/array (deeply), from any case to PascalCase.
|
|
1340
1399
|
*
|
|
@@ -1342,9 +1401,24 @@ export declare function toCamel<T extends object | string>(input: T): CaseResult
|
|
|
1342
1401
|
* ```ts
|
|
1343
1402
|
* toPascal('hello-world'); // 'HelloWorld'
|
|
1344
1403
|
* toPascal({ 'first-name': 'John', userID: 1 }); // { FirstName: 'John', UserId: 1 }
|
|
1404
|
+
* toPascal('$hello-world', true); // '$HelloWorld'
|
|
1405
|
+
* ```
|
|
1406
|
+
*
|
|
1407
|
+
* @param allowSymbols Symbols (ASCII punctuation, like `$` or `@`) are removed by default.
|
|
1408
|
+
* Pass `true` to keep all of them, or an array to keep only some (e.g. `['$']`).
|
|
1409
|
+
*/
|
|
1410
|
+
export declare function toPascal<T extends object | string, S extends boolean | string = false>(input: T, allowSymbols?: S | readonly S[]): CaseResult<T, "Pascal", S>;
|
|
1411
|
+
/**
|
|
1412
|
+
* Converts a string, or the keys of an object/array (deeply), from any case to PascalCase.
|
|
1413
|
+
*
|
|
1414
|
+
* @example
|
|
1415
|
+
* ```ts
|
|
1416
|
+
* toPascal('$hello-world', { allowSymbols: ['$'] }); // '$HelloWorld'
|
|
1345
1417
|
* ```
|
|
1418
|
+
*
|
|
1419
|
+
* @param options `allowSymbols`: symbols are removed by default; `true` keeps all of them, and an array keeps only some.
|
|
1346
1420
|
*/
|
|
1347
|
-
export declare function toPascal<T extends object | string>(input: T): CaseResult<T, "Pascal">;
|
|
1421
|
+
export declare function toPascal<T extends object | string, S extends boolean | string = false>(input: T, options: CaseOptions<S>): CaseResult<T, "Pascal", S>;
|
|
1348
1422
|
/**
|
|
1349
1423
|
* Converts a string, or the keys of an object/array (deeply), from any case to snake_case.
|
|
1350
1424
|
*
|
|
@@ -1352,19 +1426,49 @@ export declare function toPascal<T extends object | string>(input: T): CaseResul
|
|
|
1352
1426
|
* ```ts
|
|
1353
1427
|
* toSnake('helloWorld'); // 'hello_world'
|
|
1354
1428
|
* toSnake({ firstName: 'John', userID: 1 }); // { first_name: 'John', user_id: 1 }
|
|
1429
|
+
* toSnake('$hello-world', true); // '$hello_world'
|
|
1430
|
+
* ```
|
|
1431
|
+
*
|
|
1432
|
+
* @param allowSymbols Symbols (ASCII punctuation, like `$` or `@`) are removed by default.
|
|
1433
|
+
* Pass `true` to keep all of them, or an array to keep only some (e.g. `['$']`).
|
|
1434
|
+
*/
|
|
1435
|
+
export declare function toSnake<T extends object | string, S extends boolean | string = false>(input: T, allowSymbols?: S | readonly S[]): CaseResult<T, "Snake", S>;
|
|
1436
|
+
/**
|
|
1437
|
+
* Converts a string, or the keys of an object/array (deeply), from any case to snake_case.
|
|
1438
|
+
*
|
|
1439
|
+
* @example
|
|
1440
|
+
* ```ts
|
|
1441
|
+
* toSnake('$hello-world', { allowSymbols: ['$'] }); // '$hello_world'
|
|
1442
|
+
* ```
|
|
1443
|
+
*
|
|
1444
|
+
* @param options `allowSymbols`: symbols are removed by default; `true` keeps all of them, and an array keeps only some.
|
|
1445
|
+
*/
|
|
1446
|
+
export declare function toSnake<T extends object | string, S extends boolean | string = false>(input: T, options: CaseOptions<S>): CaseResult<T, "Snake", S>;
|
|
1447
|
+
/**
|
|
1448
|
+
* Converts a string, or the keys of an object/array (deeply), from any case to kebab-case.
|
|
1449
|
+
*
|
|
1450
|
+
* @example
|
|
1451
|
+
* ```ts
|
|
1452
|
+
* toKebab('HELLO_WORLD'); // 'hello-world'
|
|
1453
|
+
* toKebab({ FIRST_NAME: 'John', userID: 1 }); // { 'first-name': 'John', 'user-id': 1 }
|
|
1454
|
+
* toKebab('$hello-world', true); // '$hello-world'
|
|
1355
1455
|
* ```
|
|
1456
|
+
*
|
|
1457
|
+
* @param allowSymbols Symbols (ASCII punctuation, like `$` or `@`) are removed by default.
|
|
1458
|
+
* Pass `true` to keep all of them, or an array to keep only some (e.g. `['$']`).
|
|
1356
1459
|
*/
|
|
1357
|
-
export declare function
|
|
1460
|
+
export declare function toKebab<T extends object | string, S extends boolean | string = false>(input: T, allowSymbols?: S | readonly S[]): CaseResult<T, "Kebab", S>;
|
|
1358
1461
|
/**
|
|
1359
|
-
* Converts a string, or the keys of an object/array (deeply), from any case to
|
|
1462
|
+
* Converts a string, or the keys of an object/array (deeply), from any case to kebab-case.
|
|
1360
1463
|
*
|
|
1361
1464
|
* @example
|
|
1362
1465
|
* ```ts
|
|
1363
|
-
*
|
|
1364
|
-
* toDash({ FIRST_NAME: 'John', userID: 1 }); // { 'first-name': 'John', 'user-id': 1 }
|
|
1466
|
+
* toKebab('$hello-world', { allowSymbols: ['$'] }); // '$hello-world'
|
|
1365
1467
|
* ```
|
|
1468
|
+
*
|
|
1469
|
+
* @param options `allowSymbols`: symbols are removed by default; `true` keeps all of them, and an array keeps only some.
|
|
1366
1470
|
*/
|
|
1367
|
-
export declare function
|
|
1471
|
+
export declare function toKebab<T extends object | string, S extends boolean | string = false>(input: T, options: CaseOptions<S>): CaseResult<T, "Kebab", S>;
|
|
1368
1472
|
/**
|
|
1369
1473
|
* Converts a string, or the keys of an object/array (deeply), from any case to UPPER_SNAKE_CASE.
|
|
1370
1474
|
*
|
|
@@ -1372,19 +1476,49 @@ export declare function toDash<T extends object | string>(input: T): CaseResult<
|
|
|
1372
1476
|
* ```ts
|
|
1373
1477
|
* toUpperSnake('hello-world'); // 'HELLO_WORLD'
|
|
1374
1478
|
* toUpperSnake({ 'first-name': 'John', userID: 1 }); // { FIRST_NAME: 'John', USER_ID: 1 }
|
|
1479
|
+
* toUpperSnake('$hello-world', true); // '$HELLO_WORLD'
|
|
1375
1480
|
* ```
|
|
1481
|
+
*
|
|
1482
|
+
* @param allowSymbols Symbols (ASCII punctuation, like `$` or `@`) are removed by default.
|
|
1483
|
+
* Pass `true` to keep all of them, or an array to keep only some (e.g. `['$']`).
|
|
1376
1484
|
*/
|
|
1377
|
-
export declare function toUpperSnake<T extends object | string>(input: T): CaseResult<T, "UpperSnake">;
|
|
1485
|
+
export declare function toUpperSnake<T extends object | string, S extends boolean | string = false>(input: T, allowSymbols?: S | readonly S[]): CaseResult<T, "UpperSnake", S>;
|
|
1378
1486
|
/**
|
|
1379
|
-
* Converts a string, or the keys of an object/array (deeply), from any case to
|
|
1487
|
+
* Converts a string, or the keys of an object/array (deeply), from any case to UPPER_SNAKE_CASE.
|
|
1380
1488
|
*
|
|
1381
1489
|
* @example
|
|
1382
1490
|
* ```ts
|
|
1383
|
-
*
|
|
1384
|
-
* toUpperDash({ firstName: 'John', userID: 1 }); // { 'FIRST-NAME': 'John', 'USER-ID': 1 }
|
|
1491
|
+
* toUpperSnake('$hello-world', { allowSymbols: ['$'] }); // '$HELLO_WORLD'
|
|
1385
1492
|
* ```
|
|
1493
|
+
*
|
|
1494
|
+
* @param options `allowSymbols`: symbols are removed by default; `true` keeps all of them, and an array keeps only some.
|
|
1386
1495
|
*/
|
|
1387
|
-
export declare function
|
|
1496
|
+
export declare function toUpperSnake<T extends object | string, S extends boolean | string = false>(input: T, options: CaseOptions<S>): CaseResult<T, "UpperSnake", S>;
|
|
1497
|
+
/**
|
|
1498
|
+
* Converts a string, or the keys of an object/array (deeply), from any case to UPPER-KEBAB-CASE.
|
|
1499
|
+
*
|
|
1500
|
+
* @example
|
|
1501
|
+
* ```ts
|
|
1502
|
+
* toUpperKebab('helloWorld'); // 'HELLO-WORLD'
|
|
1503
|
+
* toUpperKebab({ firstName: 'John', userID: 1 }); // { 'FIRST-NAME': 'John', 'USER-ID': 1 }
|
|
1504
|
+
* toUpperKebab('$hello-world', true); // '$HELLO-WORLD'
|
|
1505
|
+
* ```
|
|
1506
|
+
*
|
|
1507
|
+
* @param allowSymbols Symbols (ASCII punctuation, like `$` or `@`) are removed by default.
|
|
1508
|
+
* Pass `true` to keep all of them, or an array to keep only some (e.g. `['$']`).
|
|
1509
|
+
*/
|
|
1510
|
+
export declare function toUpperKebab<T extends object | string, S extends boolean | string = false>(input: T, allowSymbols?: S | readonly S[]): CaseResult<T, "UpperKebab", S>;
|
|
1511
|
+
/**
|
|
1512
|
+
* Converts a string, or the keys of an object/array (deeply), from any case to UPPER-KEBAB-CASE.
|
|
1513
|
+
*
|
|
1514
|
+
* @example
|
|
1515
|
+
* ```ts
|
|
1516
|
+
* toUpperKebab('$hello-world', { allowSymbols: ['$'] }); // '$HELLO-WORLD'
|
|
1517
|
+
* ```
|
|
1518
|
+
*
|
|
1519
|
+
* @param options `allowSymbols`: symbols are removed by default; `true` keeps all of them, and an array keeps only some.
|
|
1520
|
+
*/
|
|
1521
|
+
export declare function toUpperKebab<T extends object | string, S extends boolean | string = false>(input: T, options: CaseOptions<S>): CaseResult<T, "UpperKebab", S>;
|
|
1388
1522
|
/**
|
|
1389
1523
|
* Converts a string, or the keys of an object/array (deeply), from any case to Train-Case.
|
|
1390
1524
|
*
|
|
@@ -1392,19 +1526,52 @@ export declare function toUpperDash<T extends object | string>(input: T): CaseRe
|
|
|
1392
1526
|
* ```ts
|
|
1393
1527
|
* toTrain('hello_world'); // 'Hello-World'
|
|
1394
1528
|
* toTrain({ first_name: 'John', userID: 1 }); // { 'First-Name': 'John', 'User-Id': 1 }
|
|
1529
|
+
* toTrain('$hello-world', true); // '$Hello-World'
|
|
1395
1530
|
* ```
|
|
1531
|
+
*
|
|
1532
|
+
* @param allowSymbols Symbols (ASCII punctuation, like `$` or `@`) are removed by default.
|
|
1533
|
+
* Pass `true` to keep all of them, or an array to keep only some (e.g. `['$']`).
|
|
1396
1534
|
*/
|
|
1397
|
-
export declare function toTrain<T extends object | string>(input: T): CaseResult<T, "Train">;
|
|
1535
|
+
export declare function toTrain<T extends object | string, S extends boolean | string = false>(input: T, allowSymbols?: S | readonly S[]): CaseResult<T, "Train", S>;
|
|
1398
1536
|
/**
|
|
1399
|
-
* Converts a string, or the keys of an object/array (deeply), from any case to
|
|
1537
|
+
* Converts a string, or the keys of an object/array (deeply), from any case to Train-Case.
|
|
1400
1538
|
*
|
|
1401
1539
|
* @example
|
|
1402
1540
|
* ```ts
|
|
1403
|
-
*
|
|
1404
|
-
* toDot({ FirstName: 'John', userID: 1 }); // { 'first.name': 'John', 'user.id': 1 }
|
|
1541
|
+
* toTrain('$hello-world', { allowSymbols: ['$'] }); // '$Hello-World'
|
|
1405
1542
|
* ```
|
|
1543
|
+
*
|
|
1544
|
+
* @param options `allowSymbols`: symbols are removed by default; `true` keeps all of them, and an array keeps only some.
|
|
1406
1545
|
*/
|
|
1407
|
-
export declare function
|
|
1546
|
+
export declare function toTrain<T extends object | string, S extends boolean | string = false>(input: T, options: CaseOptions<S>): CaseResult<T, "Train", S>;
|
|
1547
|
+
/**
|
|
1548
|
+
* Converts a string, or the keys of an object/array (deeply), from any case to dot.case, keeping the original case of each word.
|
|
1549
|
+
*
|
|
1550
|
+
* @example
|
|
1551
|
+
* ```ts
|
|
1552
|
+
* toDot('$hello-World', { allowSymbols: ['$'] }); // '$hello.World'
|
|
1553
|
+
* toDot('helloWorld', { transform: 'lowercase' }); // 'hello.world'
|
|
1554
|
+
* toDot('helloWorld', { transform: 'uppercase' }); // 'HELLO.WORLD'
|
|
1555
|
+
* ```
|
|
1556
|
+
*
|
|
1557
|
+
* @param options `allowSymbols`: symbols are removed by default; `true` keeps all of them, and an array keeps only some.
|
|
1558
|
+
* `transform`: the original case of each word is kept by default; `'lowercase'` or `'uppercase'` changes the case of the whole result.
|
|
1559
|
+
*/
|
|
1560
|
+
export declare function toDot<T extends object | string, S extends boolean | string = false, X extends Transform | undefined = undefined>(input: T, options: TransformCaseOptions<S, X>): CaseResult<T, "Dot", S, X>;
|
|
1561
|
+
/**
|
|
1562
|
+
* Converts a string, or the keys of an object/array (deeply), from any case to dot.case, keeping the original case of each word.
|
|
1563
|
+
*
|
|
1564
|
+
* @example
|
|
1565
|
+
* ```ts
|
|
1566
|
+
* toDot('HelloWorld'); // 'Hello.World'
|
|
1567
|
+
* toDot({ FirstName: 'John', userID: 1 }); // { 'First.Name': 'John', 'user.ID': 1 }
|
|
1568
|
+
* toDot('$hello-world', true); // '$hello.world'
|
|
1569
|
+
* ```
|
|
1570
|
+
*
|
|
1571
|
+
* @param allowSymbols Symbols (ASCII punctuation, like `$` or `@`) are removed by default.
|
|
1572
|
+
* Pass `true` to keep all of them, or an array to keep only some (e.g. `['$']`).
|
|
1573
|
+
*/
|
|
1574
|
+
export declare function toDot<T extends object | string, S extends boolean | string = false>(input: T, allowSymbols?: S | readonly S[]): CaseResult<T, "Dot", S>;
|
|
1408
1575
|
/**
|
|
1409
1576
|
* Converts a string, or the keys of an object/array (deeply), from any case to Title Case.
|
|
1410
1577
|
*
|
|
@@ -1412,9 +1579,24 @@ export declare function toDot<T extends object | string>(input: T): CaseResult<T
|
|
|
1412
1579
|
* ```ts
|
|
1413
1580
|
* toTitle('hello_world'); // 'Hello World'
|
|
1414
1581
|
* toTitle({ first_name: 'John', userID: 1 }); // { 'First Name': 'John', 'User Id': 1 }
|
|
1582
|
+
* toTitle('$hello-world', true); // '$Hello World'
|
|
1415
1583
|
* ```
|
|
1584
|
+
*
|
|
1585
|
+
* @param allowSymbols Symbols (ASCII punctuation, like `$` or `@`) are removed by default.
|
|
1586
|
+
* Pass `true` to keep all of them, or an array to keep only some (e.g. `['$']`).
|
|
1416
1587
|
*/
|
|
1417
|
-
export declare function toTitle<T extends object | string>(input: T): CaseResult<T, "Title">;
|
|
1588
|
+
export declare function toTitle<T extends object | string, S extends boolean | string = false>(input: T, allowSymbols?: S | readonly S[]): CaseResult<T, "Title", S>;
|
|
1589
|
+
/**
|
|
1590
|
+
* Converts a string, or the keys of an object/array (deeply), from any case to Title Case.
|
|
1591
|
+
*
|
|
1592
|
+
* @example
|
|
1593
|
+
* ```ts
|
|
1594
|
+
* toTitle('$hello-world', { allowSymbols: ['$'] }); // '$Hello World'
|
|
1595
|
+
* ```
|
|
1596
|
+
*
|
|
1597
|
+
* @param options `allowSymbols`: symbols are removed by default; `true` keeps all of them, and an array keeps only some.
|
|
1598
|
+
*/
|
|
1599
|
+
export declare function toTitle<T extends object | string, S extends boolean | string = false>(input: T, options: CaseOptions<S>): CaseResult<T, "Title", S>;
|
|
1418
1600
|
/**
|
|
1419
1601
|
* Converts a string, or the keys of an object/array (deeply), from any case to Sentence case.
|
|
1420
1602
|
*
|
|
@@ -1422,8 +1604,155 @@ export declare function toTitle<T extends object | string>(input: T): CaseResult
|
|
|
1422
1604
|
* ```ts
|
|
1423
1605
|
* toSentence('helloWorld'); // 'Hello world'
|
|
1424
1606
|
* toSentence({ firstName: 'John', userID: 1 }); // { 'First name': 'John', 'User id': 1 }
|
|
1607
|
+
* toSentence('$hello-world', true); // '$Hello world'
|
|
1425
1608
|
* ```
|
|
1609
|
+
*
|
|
1610
|
+
* @param allowSymbols Symbols (ASCII punctuation, like `$` or `@`) are removed by default.
|
|
1611
|
+
* Pass `true` to keep all of them, or an array to keep only some (e.g. `['$']`).
|
|
1612
|
+
*/
|
|
1613
|
+
export declare function toSentence<T extends object | string, S extends boolean | string = false>(input: T, allowSymbols?: S | readonly S[]): CaseResult<T, "Sentence", S>;
|
|
1614
|
+
/**
|
|
1615
|
+
* Converts a string, or the keys of an object/array (deeply), from any case to Sentence case.
|
|
1616
|
+
*
|
|
1617
|
+
* @example
|
|
1618
|
+
* ```ts
|
|
1619
|
+
* toSentence('$hello-world', { allowSymbols: ['$'] }); // '$Hello world'
|
|
1620
|
+
* ```
|
|
1621
|
+
*
|
|
1622
|
+
* @param options `allowSymbols`: symbols are removed by default; `true` keeps all of them, and an array keeps only some.
|
|
1623
|
+
*/
|
|
1624
|
+
export declare function toSentence<T extends object | string, S extends boolean | string = false>(input: T, options: CaseOptions<S>): CaseResult<T, "Sentence", S>;
|
|
1625
|
+
/**
|
|
1626
|
+
* Converts a string, or the keys of an object/array (deeply), from any case to Pascal_Snake_Case (also known as Ada_Case).
|
|
1627
|
+
*
|
|
1628
|
+
* @example
|
|
1629
|
+
* ```ts
|
|
1630
|
+
* toPascalSnake('helloWorld'); // 'Hello_World'
|
|
1631
|
+
* toPascalSnake({ first_name: 'John', userID: 1 }); // { First_Name: 'John', User_Id: 1 }
|
|
1632
|
+
* toPascalSnake('$hello-world', true); // '$Hello_World'
|
|
1633
|
+
* ```
|
|
1634
|
+
*
|
|
1635
|
+
* @param allowSymbols Symbols (ASCII punctuation, like `$` or `@`) are removed by default.
|
|
1636
|
+
* Pass `true` to keep all of them, or an array to keep only some (e.g. `['$']`).
|
|
1637
|
+
*/
|
|
1638
|
+
export declare function toPascalSnake<T extends object | string, S extends boolean | string = false>(input: T, allowSymbols?: S | readonly S[]): CaseResult<T, "PascalSnake", S>;
|
|
1639
|
+
/**
|
|
1640
|
+
* Converts a string, or the keys of an object/array (deeply), from any case to Pascal_Snake_Case (also known as Ada_Case).
|
|
1641
|
+
*
|
|
1642
|
+
* @example
|
|
1643
|
+
* ```ts
|
|
1644
|
+
* toPascalSnake('$hello-world', { allowSymbols: ['$'] }); // '$Hello_World'
|
|
1645
|
+
* ```
|
|
1646
|
+
*
|
|
1647
|
+
* @param options `allowSymbols`: symbols are removed by default; `true` keeps all of them, and an array keeps only some.
|
|
1648
|
+
*/
|
|
1649
|
+
export declare function toPascalSnake<T extends object | string, S extends boolean | string = false>(input: T, options: CaseOptions<S>): CaseResult<T, "PascalSnake", S>;
|
|
1650
|
+
/**
|
|
1651
|
+
* Converts a string, or the keys of an object/array (deeply), from any case to path/case, keeping the original case of each word.
|
|
1652
|
+
* `/` and `\\` in the input also separate words.
|
|
1653
|
+
*
|
|
1654
|
+
* @example
|
|
1655
|
+
* ```ts
|
|
1656
|
+
* toPath('$hello-World', { allowSymbols: ['$'] }); // '$hello/World'
|
|
1657
|
+
* toPath('helloWorld', { transform: 'lowercase' }); // 'hello/world'
|
|
1658
|
+
* toPath('helloWorld', { transform: 'uppercase' }); // 'HELLO/WORLD'
|
|
1659
|
+
* toPath('users/profilePicture', { separator: '\\' }); // 'users\\profile\\Picture'
|
|
1660
|
+
* ```
|
|
1661
|
+
*
|
|
1662
|
+
* @param options `allowSymbols`: symbols are removed by default; `true` keeps all of them, and an array keeps only some.
|
|
1663
|
+
* `transform`: the original case of each word is kept by default; `'lowercase'` or `'uppercase'` changes the case of the whole result.
|
|
1664
|
+
* `separator`: `'/'` (the default) or `'\\'`.
|
|
1665
|
+
*/
|
|
1666
|
+
export declare function toPath<T extends object | string, S extends boolean | string = false, X extends Transform | undefined = undefined, P extends PathSeparator = "/">(input: T, options: PathCaseOptions<S, X, P>): CaseResult<T, "Path", S, X, P>;
|
|
1667
|
+
/**
|
|
1668
|
+
* Converts a string, or the keys of an object/array (deeply), from any case to path/case, keeping the original case of each word.
|
|
1669
|
+
* `/` and `\\` in the input also separate words.
|
|
1670
|
+
*
|
|
1671
|
+
* @example
|
|
1672
|
+
* ```ts
|
|
1673
|
+
* toPath('helloWorld'); // 'hello/World'
|
|
1674
|
+
* toPath({ first_name: 'John', userID: 1 }); // { 'first/name': 'John', 'user/ID': 1 }
|
|
1675
|
+
* toPath('$hello-world', true); // '$hello/world'
|
|
1676
|
+
* ```
|
|
1677
|
+
*
|
|
1678
|
+
* @param allowSymbols Symbols (ASCII punctuation, like `$` or `@`) are removed by default.
|
|
1679
|
+
* Pass `true` to keep all of them, or an array to keep only some (e.g. `['$']`).
|
|
1680
|
+
*/
|
|
1681
|
+
export declare function toPath<T extends object | string, S extends boolean | string = false>(input: T, allowSymbols?: S | readonly S[]): CaseResult<T, "Path", S>;
|
|
1682
|
+
/**
|
|
1683
|
+
* Converts a string, or the keys of an object/array (deeply), from any case to space case, keeping the original case of each word.
|
|
1684
|
+
*
|
|
1685
|
+
* @example
|
|
1686
|
+
* ```ts
|
|
1687
|
+
* toSpace('helloWorld'); // 'hello World'
|
|
1688
|
+
* toSpace({ first_name: 'John', userID: 1 }); // { 'first name': 'John', 'user ID': 1 }
|
|
1689
|
+
* toSpace('$hello-world', true); // '$hello world'
|
|
1690
|
+
* ```
|
|
1691
|
+
*
|
|
1692
|
+
* @param allowSymbols Symbols (ASCII punctuation, like `$` or `@`) are removed by default.
|
|
1693
|
+
* Pass `true` to keep all of them, or an array to keep only some (e.g. `['$']`).
|
|
1694
|
+
*/
|
|
1695
|
+
export declare function toSpace<T extends object | string, S extends boolean | string = false>(input: T, allowSymbols?: S | readonly S[]): CaseResult<T, "Space", S>;
|
|
1696
|
+
/**
|
|
1697
|
+
* Converts a string, or the keys of an object/array (deeply), from any case to space case, keeping the original case of each word.
|
|
1698
|
+
*
|
|
1699
|
+
* @example
|
|
1700
|
+
* ```ts
|
|
1701
|
+
* toSpace('$hello-world', { allowSymbols: ['$'] }); // '$hello world'
|
|
1702
|
+
* ```
|
|
1703
|
+
*
|
|
1704
|
+
* @param options `allowSymbols`: symbols are removed by default; `true` keeps all of them, and an array keeps only some.
|
|
1705
|
+
*/
|
|
1706
|
+
export declare function toSpace<T extends object | string, S extends boolean | string = false>(input: T, options: CaseOptions<S>): CaseResult<T, "Space", S>;
|
|
1707
|
+
/**
|
|
1708
|
+
* Converts a string, or the keys of an object/array (deeply), from any case to lower case (space separated).
|
|
1709
|
+
*
|
|
1710
|
+
* @example
|
|
1711
|
+
* ```ts
|
|
1712
|
+
* toLower('helloWorld'); // 'hello world'
|
|
1713
|
+
* toLower({ first_name: 'John', userID: 1 }); // { 'first name': 'John', 'user id': 1 }
|
|
1714
|
+
* toLower('$hello-world', true); // '$hello world'
|
|
1715
|
+
* ```
|
|
1716
|
+
*
|
|
1717
|
+
* @param allowSymbols Symbols (ASCII punctuation, like `$` or `@`) are removed by default.
|
|
1718
|
+
* Pass `true` to keep all of them, or an array to keep only some (e.g. `['$']`).
|
|
1719
|
+
*/
|
|
1720
|
+
export declare function toLower<T extends object | string, S extends boolean | string = false>(input: T, allowSymbols?: S | readonly S[]): CaseResult<T, "Lower", S>;
|
|
1721
|
+
/**
|
|
1722
|
+
* Converts a string, or the keys of an object/array (deeply), from any case to lower case (space separated).
|
|
1723
|
+
*
|
|
1724
|
+
* @example
|
|
1725
|
+
* ```ts
|
|
1726
|
+
* toLower('$hello-world', { allowSymbols: ['$'] }); // '$hello world'
|
|
1727
|
+
* ```
|
|
1728
|
+
*
|
|
1729
|
+
* @param options `allowSymbols`: symbols are removed by default; `true` keeps all of them, and an array keeps only some.
|
|
1730
|
+
*/
|
|
1731
|
+
export declare function toLower<T extends object | string, S extends boolean | string = false>(input: T, options: CaseOptions<S>): CaseResult<T, "Lower", S>;
|
|
1732
|
+
/**
|
|
1733
|
+
* Converts a string, or the keys of an object/array (deeply), from any case to UPPER CASE (space separated).
|
|
1734
|
+
*
|
|
1735
|
+
* @example
|
|
1736
|
+
* ```ts
|
|
1737
|
+
* toUpper('helloWorld'); // 'HELLO WORLD'
|
|
1738
|
+
* toUpper({ first_name: 'John', userID: 1 }); // { 'FIRST NAME': 'John', 'USER ID': 1 }
|
|
1739
|
+
* toUpper('$hello-world', true); // '$HELLO WORLD'
|
|
1740
|
+
* ```
|
|
1741
|
+
*
|
|
1742
|
+
* @param allowSymbols Symbols (ASCII punctuation, like `$` or `@`) are removed by default.
|
|
1743
|
+
* Pass `true` to keep all of them, or an array to keep only some (e.g. `['$']`).
|
|
1744
|
+
*/
|
|
1745
|
+
export declare function toUpper<T extends object | string, S extends boolean | string = false>(input: T, allowSymbols?: S | readonly S[]): CaseResult<T, "Upper", S>;
|
|
1746
|
+
/**
|
|
1747
|
+
* Converts a string, or the keys of an object/array (deeply), from any case to UPPER CASE (space separated).
|
|
1748
|
+
*
|
|
1749
|
+
* @example
|
|
1750
|
+
* ```ts
|
|
1751
|
+
* toUpper('$hello-world', { allowSymbols: ['$'] }); // '$HELLO WORLD'
|
|
1752
|
+
* ```
|
|
1753
|
+
*
|
|
1754
|
+
* @param options `allowSymbols`: symbols are removed by default; `true` keeps all of them, and an array keeps only some.
|
|
1426
1755
|
*/
|
|
1427
|
-
export declare function
|
|
1756
|
+
export declare function toUpper<T extends object | string, S extends boolean | string = false>(input: T, options: CaseOptions<S>): CaseResult<T, "Upper", S>;
|
|
1428
1757
|
//#endregion
|
|
1429
|
-
export type { Case, CaseResult, ParserType, Prettify, Result };
|
|
1758
|
+
export type { AllowSymbols, Case, CaseOptions, CaseResult, KeepSymbols, ParserType, PathCaseOptions, PathSeparator, Prettify, Result, Transform, TransformCaseOptions };
|