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.cjs
CHANGED
|
@@ -258,7 +258,7 @@ function converter(input, type) {
|
|
|
258
258
|
* camelToDash({ firstName: 'John' }); // { 'first-name': 'John' }
|
|
259
259
|
* ```
|
|
260
260
|
*
|
|
261
|
-
* @deprecated Use `
|
|
261
|
+
* @deprecated Use `toKebab` instead, which converts from any case. It keeps acronyms together,
|
|
262
262
|
* so results differ for keys like `userID` (see the migration notes in the README).
|
|
263
263
|
*/
|
|
264
264
|
function camelToDash(input) {
|
|
@@ -318,7 +318,7 @@ function camelToUpperSnake(input) {
|
|
|
318
318
|
* camelToUpperDash({ firstName: 'John' }); // { 'FIRST-NAME': 'John' }
|
|
319
319
|
* ```
|
|
320
320
|
*
|
|
321
|
-
* @deprecated Use `
|
|
321
|
+
* @deprecated Use `toUpperKebab` instead, which converts from any case. It keeps acronyms together,
|
|
322
322
|
* so results differ for keys like `userID` (see the migration notes in the README).
|
|
323
323
|
*/
|
|
324
324
|
function camelToUpperDash(input) {
|
|
@@ -455,7 +455,7 @@ function dashToUpperSnake(input) {
|
|
|
455
455
|
* dashToUpperDash({ 'first-name': 'John' }); // { 'FIRST-NAME': 'John' }
|
|
456
456
|
* ```
|
|
457
457
|
*
|
|
458
|
-
* @deprecated Use `
|
|
458
|
+
* @deprecated Use `toUpperKebab` instead, which converts from any case. It keeps acronyms together,
|
|
459
459
|
* so results differ for keys like `userID` (see the migration notes in the README).
|
|
460
460
|
*/
|
|
461
461
|
function dashToUpperDash(input) {
|
|
@@ -562,7 +562,7 @@ function pascalToSnake(input) {
|
|
|
562
562
|
* pascalToDash({ FirstName: 'John' }); // { 'first-name': 'John' }
|
|
563
563
|
* ```
|
|
564
564
|
*
|
|
565
|
-
* @deprecated Use `
|
|
565
|
+
* @deprecated Use `toKebab` instead, which converts from any case. It keeps acronyms together,
|
|
566
566
|
* so results differ for keys like `userID` (see the migration notes in the README).
|
|
567
567
|
*/
|
|
568
568
|
function pascalToDash(input) {
|
|
@@ -592,7 +592,7 @@ function pascalToUpperSnake(input) {
|
|
|
592
592
|
* pascalToUpperDash({ FirstName: 'John' }); // { 'FIRST-NAME': 'John' }
|
|
593
593
|
* ```
|
|
594
594
|
*
|
|
595
|
-
* @deprecated Use `
|
|
595
|
+
* @deprecated Use `toUpperKebab` instead, which converts from any case. It keeps acronyms together,
|
|
596
596
|
* so results differ for keys like `userID` (see the migration notes in the README).
|
|
597
597
|
*/
|
|
598
598
|
function pascalToUpperDash(input) {
|
|
@@ -684,7 +684,7 @@ function snakeToCamel(input) {
|
|
|
684
684
|
* snakeToDash({ first_name: 'John' }); // { 'first-name': 'John' }
|
|
685
685
|
* ```
|
|
686
686
|
*
|
|
687
|
-
* @deprecated Use `
|
|
687
|
+
* @deprecated Use `toKebab` instead, which converts from any case. It keeps acronyms together,
|
|
688
688
|
* so results differ for keys like `userID` (see the migration notes in the README).
|
|
689
689
|
*/
|
|
690
690
|
function snakeToDash(input) {
|
|
@@ -729,7 +729,7 @@ function snakeToUpperSnake(input) {
|
|
|
729
729
|
* snakeToUpperDash({ first_name: 'John' }); // { 'FIRST-NAME': 'John' }
|
|
730
730
|
* ```
|
|
731
731
|
*
|
|
732
|
-
* @deprecated Use `
|
|
732
|
+
* @deprecated Use `toUpperKebab` instead, which converts from any case. It keeps acronyms together,
|
|
733
733
|
* so results differ for keys like `userID` (see the migration notes in the README).
|
|
734
734
|
*/
|
|
735
735
|
function snakeToUpperDash(input) {
|
|
@@ -851,7 +851,7 @@ function trainToSnake(input) {
|
|
|
851
851
|
* trainToDash({ 'First-Name': 'John' }); // { 'first-name': 'John' }
|
|
852
852
|
* ```
|
|
853
853
|
*
|
|
854
|
-
* @deprecated Use `
|
|
854
|
+
* @deprecated Use `toKebab` instead, which converts from any case. It keeps acronyms together,
|
|
855
855
|
* so results differ for keys like `userID` (see the migration notes in the README).
|
|
856
856
|
*/
|
|
857
857
|
function trainToDash(input) {
|
|
@@ -881,7 +881,7 @@ function trainToUpperSnake(input) {
|
|
|
881
881
|
* trainToUpperDash({ 'First-Name': 'John' }); // { 'FIRST-NAME': 'John' }
|
|
882
882
|
* ```
|
|
883
883
|
*
|
|
884
|
-
* @deprecated Use `
|
|
884
|
+
* @deprecated Use `toUpperKebab` instead, which converts from any case. It keeps acronyms together,
|
|
885
885
|
* so results differ for keys like `userID` (see the migration notes in the README).
|
|
886
886
|
*/
|
|
887
887
|
function trainToUpperDash(input) {
|
|
@@ -988,7 +988,7 @@ function dotToSnake(input) {
|
|
|
988
988
|
* dotToDash({ 'first.name': 'John' }); // { 'first-name': 'John' }
|
|
989
989
|
* ```
|
|
990
990
|
*
|
|
991
|
-
* @deprecated Use `
|
|
991
|
+
* @deprecated Use `toKebab` instead, which converts from any case. It keeps acronyms together,
|
|
992
992
|
* so results differ for keys like `userID` (see the migration notes in the README).
|
|
993
993
|
*/
|
|
994
994
|
function dotToDash(input) {
|
|
@@ -1018,7 +1018,7 @@ function dotToUpperSnake(input) {
|
|
|
1018
1018
|
* dotToUpperDash({ 'first.name': 'John' }); // { 'FIRST-NAME': 'John' }
|
|
1019
1019
|
* ```
|
|
1020
1020
|
*
|
|
1021
|
-
* @deprecated Use `
|
|
1021
|
+
* @deprecated Use `toUpperKebab` instead, which converts from any case. It keeps acronyms together,
|
|
1022
1022
|
* so results differ for keys like `userID` (see the migration notes in the README).
|
|
1023
1023
|
*/
|
|
1024
1024
|
function dotToUpperDash(input) {
|
|
@@ -1125,7 +1125,7 @@ function titleToSnake(input) {
|
|
|
1125
1125
|
* titleToDash({ 'First Name': 'John' }); // { 'first-name': 'John' }
|
|
1126
1126
|
* ```
|
|
1127
1127
|
*
|
|
1128
|
-
* @deprecated Use `
|
|
1128
|
+
* @deprecated Use `toKebab` instead, which converts from any case. It keeps acronyms together,
|
|
1129
1129
|
* so results differ for keys like `userID` (see the migration notes in the README).
|
|
1130
1130
|
*/
|
|
1131
1131
|
function titleToDash(input) {
|
|
@@ -1155,7 +1155,7 @@ function titleToUpperSnake(input) {
|
|
|
1155
1155
|
* titleToUpperDash({ 'First Name': 'John' }); // { 'FIRST-NAME': 'John' }
|
|
1156
1156
|
* ```
|
|
1157
1157
|
*
|
|
1158
|
-
* @deprecated Use `
|
|
1158
|
+
* @deprecated Use `toUpperKebab` instead, which converts from any case. It keeps acronyms together,
|
|
1159
1159
|
* so results differ for keys like `userID` (see the migration notes in the README).
|
|
1160
1160
|
*/
|
|
1161
1161
|
function titleToUpperDash(input) {
|
|
@@ -1262,7 +1262,7 @@ function sentenceToSnake(input) {
|
|
|
1262
1262
|
* sentenceToDash({ 'First name': 'John' }); // { 'first-name': 'John' }
|
|
1263
1263
|
* ```
|
|
1264
1264
|
*
|
|
1265
|
-
* @deprecated Use `
|
|
1265
|
+
* @deprecated Use `toKebab` instead, which converts from any case. It keeps acronyms together,
|
|
1266
1266
|
* so results differ for keys like `userID` (see the migration notes in the README).
|
|
1267
1267
|
*/
|
|
1268
1268
|
function sentenceToDash(input) {
|
|
@@ -1292,7 +1292,7 @@ function sentenceToUpperSnake(input) {
|
|
|
1292
1292
|
* sentenceToUpperDash({ 'First name': 'John' }); // { 'FIRST-NAME': 'John' }
|
|
1293
1293
|
* ```
|
|
1294
1294
|
*
|
|
1295
|
-
* @deprecated Use `
|
|
1295
|
+
* @deprecated Use `toUpperKebab` instead, which converts from any case. It keeps acronyms together,
|
|
1296
1296
|
* so results differ for keys like `userID` (see the migration notes in the README).
|
|
1297
1297
|
*/
|
|
1298
1298
|
function sentenceToUpperDash(input) {
|
|
@@ -1384,7 +1384,7 @@ function upperDashToSnake(input) {
|
|
|
1384
1384
|
* upperDashToDash({ 'FIRST-NAME': 'John' }); // { 'first-name': 'John' }
|
|
1385
1385
|
* ```
|
|
1386
1386
|
*
|
|
1387
|
-
* @deprecated Use `
|
|
1387
|
+
* @deprecated Use `toKebab` instead, which converts from any case. It keeps acronyms together,
|
|
1388
1388
|
* so results differ for keys like `userID` (see the migration notes in the README).
|
|
1389
1389
|
*/
|
|
1390
1390
|
function upperDashToDash(input) {
|
|
@@ -1521,7 +1521,7 @@ function upperSnakeToSnake(input) {
|
|
|
1521
1521
|
* upperSnakeToDash({ FIRST_NAME: 'John' }); // { 'first-name': 'John' }
|
|
1522
1522
|
* ```
|
|
1523
1523
|
*
|
|
1524
|
-
* @deprecated Use `
|
|
1524
|
+
* @deprecated Use `toKebab` instead, which converts from any case. It keeps acronyms together,
|
|
1525
1525
|
* so results differ for keys like `userID` (see the migration notes in the README).
|
|
1526
1526
|
*/
|
|
1527
1527
|
function upperSnakeToDash(input) {
|
|
@@ -1551,7 +1551,7 @@ function upperSnakeToPascal(input) {
|
|
|
1551
1551
|
* upperSnakeToUpperDash({ FIRST_NAME: 'John' }); // { 'FIRST-NAME': 'John' }
|
|
1552
1552
|
* ```
|
|
1553
1553
|
*
|
|
1554
|
-
* @deprecated Use `
|
|
1554
|
+
* @deprecated Use `toUpperKebab` instead, which converts from any case. It keeps acronyms together,
|
|
1555
1555
|
* so results differ for keys like `userID` (see the migration notes in the README).
|
|
1556
1556
|
*/
|
|
1557
1557
|
function upperSnakeToUpperDash(input) {
|
|
@@ -1619,20 +1619,28 @@ function upperSnakeToSentence(input) {
|
|
|
1619
1619
|
}
|
|
1620
1620
|
//#endregion
|
|
1621
1621
|
//#region src/anyCase/words.ts
|
|
1622
|
+
const SYMBOLS = "!\"#$%&'()*+,/:;<=>?@[\\]^`{|}~";
|
|
1622
1623
|
const isSeparator = (c) => c === "_" || c === "-" || c === "." || c === " ";
|
|
1624
|
+
const isSymbol = (c) => SYMBOLS.indexOf(c) !== -1;
|
|
1623
1625
|
const isUpper = (c) => c !== c.toLowerCase();
|
|
1624
1626
|
const isLower = (c) => c !== c.toUpperCase();
|
|
1627
|
+
const isKept = (c, keep) => keep === true || typeof keep !== "boolean" && keep !== void 0 && keep !== null && keep.indexOf(c) !== -1;
|
|
1625
1628
|
/**
|
|
1626
1629
|
* Splits a string in any case into lowercase words: on `_`, `-`, `.` and spaces,
|
|
1627
1630
|
* before an uppercase letter that follows a lowercase letter or a digit (`helloWorld`),
|
|
1628
1631
|
* and before the last letter of an acronym (`XMLHttp`). Mirrors the `Words` type.
|
|
1632
|
+
*
|
|
1633
|
+
* Symbols (ASCII punctuation) also start a new word. They are removed, unless `keep` is
|
|
1634
|
+
* `true` or lists them: a kept symbol sticks to the start of the next word (`hello$World`
|
|
1635
|
+
* → `hello`, `$world`), or to the end of the previous one when no word follows (`total%`).
|
|
1636
|
+
* Words keep their original case when `lowercase` is `false`.
|
|
1629
1637
|
*/
|
|
1630
|
-
function words(str) {
|
|
1638
|
+
function words(str, keep = false, lowercase = true) {
|
|
1631
1639
|
const result = [];
|
|
1632
1640
|
let word = "";
|
|
1633
1641
|
let prev = "";
|
|
1634
1642
|
const push = () => {
|
|
1635
|
-
if (word) result.push(word.toLowerCase());
|
|
1643
|
+
if (word) result.push(lowercase ? word.toLowerCase() : word);
|
|
1636
1644
|
word = "";
|
|
1637
1645
|
};
|
|
1638
1646
|
for (let i = 0; i < str.length; i++) {
|
|
@@ -1642,145 +1650,114 @@ function words(str) {
|
|
|
1642
1650
|
prev = "";
|
|
1643
1651
|
continue;
|
|
1644
1652
|
}
|
|
1653
|
+
if (isSymbol(c)) {
|
|
1654
|
+
let kept = "";
|
|
1655
|
+
let j = i;
|
|
1656
|
+
for (; j < str.length && isSymbol(str[j]); j++) if (isKept(str[j], keep)) kept += str[j];
|
|
1657
|
+
const next = str.charAt(j);
|
|
1658
|
+
if (next && !isSeparator(next)) {
|
|
1659
|
+
push();
|
|
1660
|
+
prev = "";
|
|
1661
|
+
}
|
|
1662
|
+
word += kept;
|
|
1663
|
+
i = j - 1;
|
|
1664
|
+
continue;
|
|
1665
|
+
}
|
|
1645
1666
|
const next = str.charAt(i + 1);
|
|
1646
|
-
if (isUpper(c) &&
|
|
1667
|
+
if (isUpper(c) && prev && (!isUpper(prev) || next && isLower(next))) push();
|
|
1647
1668
|
word += c;
|
|
1648
1669
|
prev = c;
|
|
1649
1670
|
}
|
|
1650
1671
|
push();
|
|
1651
1672
|
return result;
|
|
1652
1673
|
}
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1674
|
+
/** Uppercases the first character that is not a symbol: `'$id'` → `'$Id'`. */
|
|
1675
|
+
function capitalize(word) {
|
|
1676
|
+
let i = 0;
|
|
1677
|
+
while (i < word.length && isSymbol(word[i])) i++;
|
|
1678
|
+
return word.slice(0, i) + word.charAt(i).toUpperCase() + word.slice(i + 1);
|
|
1679
|
+
}
|
|
1680
|
+
/** Changes the case of the whole string, or keeps it when `transform` is `undefined`. */
|
|
1681
|
+
function applyTransform(str, transform) {
|
|
1682
|
+
if (transform === "lowercase") return str.toLowerCase();
|
|
1683
|
+
if (transform === "uppercase") return str.toUpperCase();
|
|
1684
|
+
return str;
|
|
1685
|
+
}
|
|
1686
|
+
const ToCamel = (str, keep) => words(str, keep).map((w, i) => i ? capitalize(w) : w).join("");
|
|
1687
|
+
const ToPascal = (str, keep) => words(str, keep).map(capitalize).join("");
|
|
1688
|
+
const ToSnake = (str, keep) => words(str, keep).join("_");
|
|
1689
|
+
const ToKebab = (str, keep) => words(str, keep).join("-");
|
|
1690
|
+
const ToUpperSnake = (str, keep) => words(str, keep).join("_").toUpperCase();
|
|
1691
|
+
const ToUpperKebab = (str, keep) => words(str, keep).join("-").toUpperCase();
|
|
1692
|
+
const ToTrain = (str, keep) => words(str, keep).map(capitalize).join("-");
|
|
1693
|
+
const ToDot = (str, keep, transform) => applyTransform(words(str, keep, false).join("."), transform);
|
|
1694
|
+
const ToTitle = (str, keep) => words(str, keep).map(capitalize).join(" ");
|
|
1695
|
+
const ToSentence = (str, keep) => capitalize(words(str, keep).join(" "));
|
|
1696
|
+
const ToPascalSnake = (str, keep) => words(str, keep).map(capitalize).join("_");
|
|
1697
|
+
const ToPath = (str, keep, transform, separator = "/") => applyTransform(words(str.replace(/[/\\]/g, " "), keep, false).join(separator), transform);
|
|
1698
|
+
const ToSpace = (str, keep) => words(str, keep, false).join(" ");
|
|
1699
|
+
const ToLower = (str, keep) => words(str, keep).join(" ");
|
|
1700
|
+
const ToUpper = (str, keep) => words(str, keep).join(" ").toUpperCase();
|
|
1663
1701
|
//#endregion
|
|
1664
1702
|
//#region src/anyCase/anyCase.ts
|
|
1665
|
-
/**
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
return
|
|
1703
|
+
/** Reads the second argument of a `toX` function: the `allowSymbols` shorthand, or an options object. */
|
|
1704
|
+
function parseOptions(options) {
|
|
1705
|
+
if (typeof options === "object" && options !== null && !Array.isArray(options)) {
|
|
1706
|
+
const { allowSymbols, transform, separator } = options;
|
|
1707
|
+
return {
|
|
1708
|
+
allowSymbols,
|
|
1709
|
+
transform,
|
|
1710
|
+
separator
|
|
1711
|
+
};
|
|
1712
|
+
}
|
|
1713
|
+
return { allowSymbols: options };
|
|
1676
1714
|
}
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
*
|
|
1680
|
-
* @example
|
|
1681
|
-
* ```ts
|
|
1682
|
-
* toPascal('hello-world'); // 'HelloWorld'
|
|
1683
|
-
* toPascal({ 'first-name': 'John', userID: 1 }); // { FirstName: 'John', UserId: 1 }
|
|
1684
|
-
* ```
|
|
1685
|
-
*/
|
|
1686
|
-
function toPascal(input) {
|
|
1687
|
-
return convert(input, ToPascal);
|
|
1715
|
+
function toCamel(input, options) {
|
|
1716
|
+
return convert(input, (key) => ToCamel(key, parseOptions(options).allowSymbols));
|
|
1688
1717
|
}
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
*
|
|
1692
|
-
* @example
|
|
1693
|
-
* ```ts
|
|
1694
|
-
* toSnake('helloWorld'); // 'hello_world'
|
|
1695
|
-
* toSnake({ firstName: 'John', userID: 1 }); // { first_name: 'John', user_id: 1 }
|
|
1696
|
-
* ```
|
|
1697
|
-
*/
|
|
1698
|
-
function toSnake(input) {
|
|
1699
|
-
return convert(input, ToSnake);
|
|
1718
|
+
function toPascal(input, options) {
|
|
1719
|
+
return convert(input, (key) => ToPascal(key, parseOptions(options).allowSymbols));
|
|
1700
1720
|
}
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
*
|
|
1704
|
-
* @example
|
|
1705
|
-
* ```ts
|
|
1706
|
-
* toDash('HELLO_WORLD'); // 'hello-world'
|
|
1707
|
-
* toDash({ FIRST_NAME: 'John', userID: 1 }); // { 'first-name': 'John', 'user-id': 1 }
|
|
1708
|
-
* ```
|
|
1709
|
-
*/
|
|
1710
|
-
function toDash(input) {
|
|
1711
|
-
return convert(input, ToDash);
|
|
1721
|
+
function toSnake(input, options) {
|
|
1722
|
+
return convert(input, (key) => ToSnake(key, parseOptions(options).allowSymbols));
|
|
1712
1723
|
}
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
*
|
|
1716
|
-
* @example
|
|
1717
|
-
* ```ts
|
|
1718
|
-
* toUpperSnake('hello-world'); // 'HELLO_WORLD'
|
|
1719
|
-
* toUpperSnake({ 'first-name': 'John', userID: 1 }); // { FIRST_NAME: 'John', USER_ID: 1 }
|
|
1720
|
-
* ```
|
|
1721
|
-
*/
|
|
1722
|
-
function toUpperSnake(input) {
|
|
1723
|
-
return convert(input, ToUpperSnake);
|
|
1724
|
+
function toKebab(input, options) {
|
|
1725
|
+
return convert(input, (key) => ToKebab(key, parseOptions(options).allowSymbols));
|
|
1724
1726
|
}
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
*
|
|
1728
|
-
* @example
|
|
1729
|
-
* ```ts
|
|
1730
|
-
* toUpperDash('helloWorld'); // 'HELLO-WORLD'
|
|
1731
|
-
* toUpperDash({ firstName: 'John', userID: 1 }); // { 'FIRST-NAME': 'John', 'USER-ID': 1 }
|
|
1732
|
-
* ```
|
|
1733
|
-
*/
|
|
1734
|
-
function toUpperDash(input) {
|
|
1735
|
-
return convert(input, ToUpperDash);
|
|
1727
|
+
function toUpperSnake(input, options) {
|
|
1728
|
+
return convert(input, (key) => ToUpperSnake(key, parseOptions(options).allowSymbols));
|
|
1736
1729
|
}
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
*
|
|
1740
|
-
* @example
|
|
1741
|
-
* ```ts
|
|
1742
|
-
* toTrain('hello_world'); // 'Hello-World'
|
|
1743
|
-
* toTrain({ first_name: 'John', userID: 1 }); // { 'First-Name': 'John', 'User-Id': 1 }
|
|
1744
|
-
* ```
|
|
1745
|
-
*/
|
|
1746
|
-
function toTrain(input) {
|
|
1747
|
-
return convert(input, ToTrain);
|
|
1730
|
+
function toUpperKebab(input, options) {
|
|
1731
|
+
return convert(input, (key) => ToUpperKebab(key, parseOptions(options).allowSymbols));
|
|
1748
1732
|
}
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
*
|
|
1752
|
-
* @example
|
|
1753
|
-
* ```ts
|
|
1754
|
-
* toDot('HelloWorld'); // 'hello.world'
|
|
1755
|
-
* toDot({ FirstName: 'John', userID: 1 }); // { 'first.name': 'John', 'user.id': 1 }
|
|
1756
|
-
* ```
|
|
1757
|
-
*/
|
|
1758
|
-
function toDot(input) {
|
|
1759
|
-
return convert(input, ToDot);
|
|
1733
|
+
function toTrain(input, options) {
|
|
1734
|
+
return convert(input, (key) => ToTrain(key, parseOptions(options).allowSymbols));
|
|
1760
1735
|
}
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
* @example
|
|
1765
|
-
* ```ts
|
|
1766
|
-
* toTitle('hello_world'); // 'Hello World'
|
|
1767
|
-
* toTitle({ first_name: 'John', userID: 1 }); // { 'First Name': 'John', 'User Id': 1 }
|
|
1768
|
-
* ```
|
|
1769
|
-
*/
|
|
1770
|
-
function toTitle(input) {
|
|
1771
|
-
return convert(input, ToTitle);
|
|
1736
|
+
function toDot(input, options) {
|
|
1737
|
+
const { allowSymbols, transform } = parseOptions(options);
|
|
1738
|
+
return convert(input, (key) => ToDot(key, allowSymbols, transform));
|
|
1772
1739
|
}
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
function
|
|
1783
|
-
|
|
1740
|
+
function toTitle(input, options) {
|
|
1741
|
+
return convert(input, (key) => ToTitle(key, parseOptions(options).allowSymbols));
|
|
1742
|
+
}
|
|
1743
|
+
function toSentence(input, options) {
|
|
1744
|
+
return convert(input, (key) => ToSentence(key, parseOptions(options).allowSymbols));
|
|
1745
|
+
}
|
|
1746
|
+
function toPascalSnake(input, options) {
|
|
1747
|
+
return convert(input, (key) => ToPascalSnake(key, parseOptions(options).allowSymbols));
|
|
1748
|
+
}
|
|
1749
|
+
function toPath(input, options) {
|
|
1750
|
+
const { allowSymbols, transform, separator } = parseOptions(options);
|
|
1751
|
+
return convert(input, (key) => ToPath(key, allowSymbols, transform, separator === "\\" ? "\\" : "/"));
|
|
1752
|
+
}
|
|
1753
|
+
function toSpace(input, options) {
|
|
1754
|
+
return convert(input, (key) => ToSpace(key, parseOptions(options).allowSymbols));
|
|
1755
|
+
}
|
|
1756
|
+
function toLower(input, options) {
|
|
1757
|
+
return convert(input, (key) => ToLower(key, parseOptions(options).allowSymbols));
|
|
1758
|
+
}
|
|
1759
|
+
function toUpper(input, options) {
|
|
1760
|
+
return convert(input, (key) => ToUpper(key, parseOptions(options).allowSymbols));
|
|
1784
1761
|
}
|
|
1785
1762
|
//#endregion
|
|
1786
1763
|
exports.camelToDash = camelToDash;
|
|
@@ -1847,14 +1824,19 @@ exports.titleToTrain = titleToTrain;
|
|
|
1847
1824
|
exports.titleToUpperDash = titleToUpperDash;
|
|
1848
1825
|
exports.titleToUpperSnake = titleToUpperSnake;
|
|
1849
1826
|
exports.toCamel = toCamel;
|
|
1850
|
-
exports.toDash = toDash;
|
|
1851
1827
|
exports.toDot = toDot;
|
|
1828
|
+
exports.toKebab = toKebab;
|
|
1829
|
+
exports.toLower = toLower;
|
|
1852
1830
|
exports.toPascal = toPascal;
|
|
1831
|
+
exports.toPascalSnake = toPascalSnake;
|
|
1832
|
+
exports.toPath = toPath;
|
|
1853
1833
|
exports.toSentence = toSentence;
|
|
1854
1834
|
exports.toSnake = toSnake;
|
|
1835
|
+
exports.toSpace = toSpace;
|
|
1855
1836
|
exports.toTitle = toTitle;
|
|
1856
1837
|
exports.toTrain = toTrain;
|
|
1857
|
-
exports.
|
|
1838
|
+
exports.toUpper = toUpper;
|
|
1839
|
+
exports.toUpperKebab = toUpperKebab;
|
|
1858
1840
|
exports.toUpperSnake = toUpperSnake;
|
|
1859
1841
|
exports.trainToCamel = trainToCamel;
|
|
1860
1842
|
exports.trainToDash = trainToDash;
|