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/dist/index.js CHANGED
@@ -257,7 +257,7 @@ function converter(input, type) {
257
257
  * camelToDash({ firstName: 'John' }); // { 'first-name': 'John' }
258
258
  * ```
259
259
  *
260
- * @deprecated Use `toDash` instead, which converts from any case. It keeps acronyms together,
260
+ * @deprecated Use `toKebab` instead, which converts from any case. It keeps acronyms together,
261
261
  * so results differ for keys like `userID` (see the migration notes in the README).
262
262
  */
263
263
  function camelToDash(input) {
@@ -317,7 +317,7 @@ function camelToUpperSnake(input) {
317
317
  * camelToUpperDash({ firstName: 'John' }); // { 'FIRST-NAME': 'John' }
318
318
  * ```
319
319
  *
320
- * @deprecated Use `toUpperDash` instead, which converts from any case. It keeps acronyms together,
320
+ * @deprecated Use `toUpperKebab` instead, which converts from any case. It keeps acronyms together,
321
321
  * so results differ for keys like `userID` (see the migration notes in the README).
322
322
  */
323
323
  function camelToUpperDash(input) {
@@ -454,7 +454,7 @@ function dashToUpperSnake(input) {
454
454
  * dashToUpperDash({ 'first-name': 'John' }); // { 'FIRST-NAME': 'John' }
455
455
  * ```
456
456
  *
457
- * @deprecated Use `toUpperDash` instead, which converts from any case. It keeps acronyms together,
457
+ * @deprecated Use `toUpperKebab` instead, which converts from any case. It keeps acronyms together,
458
458
  * so results differ for keys like `userID` (see the migration notes in the README).
459
459
  */
460
460
  function dashToUpperDash(input) {
@@ -561,7 +561,7 @@ function pascalToSnake(input) {
561
561
  * pascalToDash({ FirstName: 'John' }); // { 'first-name': 'John' }
562
562
  * ```
563
563
  *
564
- * @deprecated Use `toDash` instead, which converts from any case. It keeps acronyms together,
564
+ * @deprecated Use `toKebab` instead, which converts from any case. It keeps acronyms together,
565
565
  * so results differ for keys like `userID` (see the migration notes in the README).
566
566
  */
567
567
  function pascalToDash(input) {
@@ -591,7 +591,7 @@ function pascalToUpperSnake(input) {
591
591
  * pascalToUpperDash({ FirstName: 'John' }); // { 'FIRST-NAME': 'John' }
592
592
  * ```
593
593
  *
594
- * @deprecated Use `toUpperDash` instead, which converts from any case. It keeps acronyms together,
594
+ * @deprecated Use `toUpperKebab` instead, which converts from any case. It keeps acronyms together,
595
595
  * so results differ for keys like `userID` (see the migration notes in the README).
596
596
  */
597
597
  function pascalToUpperDash(input) {
@@ -683,7 +683,7 @@ function snakeToCamel(input) {
683
683
  * snakeToDash({ first_name: 'John' }); // { 'first-name': 'John' }
684
684
  * ```
685
685
  *
686
- * @deprecated Use `toDash` instead, which converts from any case. It keeps acronyms together,
686
+ * @deprecated Use `toKebab` instead, which converts from any case. It keeps acronyms together,
687
687
  * so results differ for keys like `userID` (see the migration notes in the README).
688
688
  */
689
689
  function snakeToDash(input) {
@@ -728,7 +728,7 @@ function snakeToUpperSnake(input) {
728
728
  * snakeToUpperDash({ first_name: 'John' }); // { 'FIRST-NAME': 'John' }
729
729
  * ```
730
730
  *
731
- * @deprecated Use `toUpperDash` instead, which converts from any case. It keeps acronyms together,
731
+ * @deprecated Use `toUpperKebab` instead, which converts from any case. It keeps acronyms together,
732
732
  * so results differ for keys like `userID` (see the migration notes in the README).
733
733
  */
734
734
  function snakeToUpperDash(input) {
@@ -850,7 +850,7 @@ function trainToSnake(input) {
850
850
  * trainToDash({ 'First-Name': 'John' }); // { 'first-name': 'John' }
851
851
  * ```
852
852
  *
853
- * @deprecated Use `toDash` instead, which converts from any case. It keeps acronyms together,
853
+ * @deprecated Use `toKebab` instead, which converts from any case. It keeps acronyms together,
854
854
  * so results differ for keys like `userID` (see the migration notes in the README).
855
855
  */
856
856
  function trainToDash(input) {
@@ -880,7 +880,7 @@ function trainToUpperSnake(input) {
880
880
  * trainToUpperDash({ 'First-Name': 'John' }); // { 'FIRST-NAME': 'John' }
881
881
  * ```
882
882
  *
883
- * @deprecated Use `toUpperDash` instead, which converts from any case. It keeps acronyms together,
883
+ * @deprecated Use `toUpperKebab` instead, which converts from any case. It keeps acronyms together,
884
884
  * so results differ for keys like `userID` (see the migration notes in the README).
885
885
  */
886
886
  function trainToUpperDash(input) {
@@ -987,7 +987,7 @@ function dotToSnake(input) {
987
987
  * dotToDash({ 'first.name': 'John' }); // { 'first-name': 'John' }
988
988
  * ```
989
989
  *
990
- * @deprecated Use `toDash` instead, which converts from any case. It keeps acronyms together,
990
+ * @deprecated Use `toKebab` instead, which converts from any case. It keeps acronyms together,
991
991
  * so results differ for keys like `userID` (see the migration notes in the README).
992
992
  */
993
993
  function dotToDash(input) {
@@ -1017,7 +1017,7 @@ function dotToUpperSnake(input) {
1017
1017
  * dotToUpperDash({ 'first.name': 'John' }); // { 'FIRST-NAME': 'John' }
1018
1018
  * ```
1019
1019
  *
1020
- * @deprecated Use `toUpperDash` instead, which converts from any case. It keeps acronyms together,
1020
+ * @deprecated Use `toUpperKebab` instead, which converts from any case. It keeps acronyms together,
1021
1021
  * so results differ for keys like `userID` (see the migration notes in the README).
1022
1022
  */
1023
1023
  function dotToUpperDash(input) {
@@ -1124,7 +1124,7 @@ function titleToSnake(input) {
1124
1124
  * titleToDash({ 'First Name': 'John' }); // { 'first-name': 'John' }
1125
1125
  * ```
1126
1126
  *
1127
- * @deprecated Use `toDash` instead, which converts from any case. It keeps acronyms together,
1127
+ * @deprecated Use `toKebab` instead, which converts from any case. It keeps acronyms together,
1128
1128
  * so results differ for keys like `userID` (see the migration notes in the README).
1129
1129
  */
1130
1130
  function titleToDash(input) {
@@ -1154,7 +1154,7 @@ function titleToUpperSnake(input) {
1154
1154
  * titleToUpperDash({ 'First Name': 'John' }); // { 'FIRST-NAME': 'John' }
1155
1155
  * ```
1156
1156
  *
1157
- * @deprecated Use `toUpperDash` instead, which converts from any case. It keeps acronyms together,
1157
+ * @deprecated Use `toUpperKebab` instead, which converts from any case. It keeps acronyms together,
1158
1158
  * so results differ for keys like `userID` (see the migration notes in the README).
1159
1159
  */
1160
1160
  function titleToUpperDash(input) {
@@ -1261,7 +1261,7 @@ function sentenceToSnake(input) {
1261
1261
  * sentenceToDash({ 'First name': 'John' }); // { 'first-name': 'John' }
1262
1262
  * ```
1263
1263
  *
1264
- * @deprecated Use `toDash` instead, which converts from any case. It keeps acronyms together,
1264
+ * @deprecated Use `toKebab` instead, which converts from any case. It keeps acronyms together,
1265
1265
  * so results differ for keys like `userID` (see the migration notes in the README).
1266
1266
  */
1267
1267
  function sentenceToDash(input) {
@@ -1291,7 +1291,7 @@ function sentenceToUpperSnake(input) {
1291
1291
  * sentenceToUpperDash({ 'First name': 'John' }); // { 'FIRST-NAME': 'John' }
1292
1292
  * ```
1293
1293
  *
1294
- * @deprecated Use `toUpperDash` instead, which converts from any case. It keeps acronyms together,
1294
+ * @deprecated Use `toUpperKebab` instead, which converts from any case. It keeps acronyms together,
1295
1295
  * so results differ for keys like `userID` (see the migration notes in the README).
1296
1296
  */
1297
1297
  function sentenceToUpperDash(input) {
@@ -1383,7 +1383,7 @@ function upperDashToSnake(input) {
1383
1383
  * upperDashToDash({ 'FIRST-NAME': 'John' }); // { 'first-name': 'John' }
1384
1384
  * ```
1385
1385
  *
1386
- * @deprecated Use `toDash` instead, which converts from any case. It keeps acronyms together,
1386
+ * @deprecated Use `toKebab` instead, which converts from any case. It keeps acronyms together,
1387
1387
  * so results differ for keys like `userID` (see the migration notes in the README).
1388
1388
  */
1389
1389
  function upperDashToDash(input) {
@@ -1520,7 +1520,7 @@ function upperSnakeToSnake(input) {
1520
1520
  * upperSnakeToDash({ FIRST_NAME: 'John' }); // { 'first-name': 'John' }
1521
1521
  * ```
1522
1522
  *
1523
- * @deprecated Use `toDash` instead, which converts from any case. It keeps acronyms together,
1523
+ * @deprecated Use `toKebab` instead, which converts from any case. It keeps acronyms together,
1524
1524
  * so results differ for keys like `userID` (see the migration notes in the README).
1525
1525
  */
1526
1526
  function upperSnakeToDash(input) {
@@ -1550,7 +1550,7 @@ function upperSnakeToPascal(input) {
1550
1550
  * upperSnakeToUpperDash({ FIRST_NAME: 'John' }); // { 'FIRST-NAME': 'John' }
1551
1551
  * ```
1552
1552
  *
1553
- * @deprecated Use `toUpperDash` instead, which converts from any case. It keeps acronyms together,
1553
+ * @deprecated Use `toUpperKebab` instead, which converts from any case. It keeps acronyms together,
1554
1554
  * so results differ for keys like `userID` (see the migration notes in the README).
1555
1555
  */
1556
1556
  function upperSnakeToUpperDash(input) {
@@ -1618,20 +1618,28 @@ function upperSnakeToSentence(input) {
1618
1618
  }
1619
1619
  //#endregion
1620
1620
  //#region src/anyCase/words.ts
1621
+ const SYMBOLS = "!\"#$%&'()*+,/:;<=>?@[\\]^`{|}~";
1621
1622
  const isSeparator = (c) => c === "_" || c === "-" || c === "." || c === " ";
1623
+ const isSymbol = (c) => SYMBOLS.indexOf(c) !== -1;
1622
1624
  const isUpper = (c) => c !== c.toLowerCase();
1623
1625
  const isLower = (c) => c !== c.toUpperCase();
1626
+ const isKept = (c, keep) => keep === true || typeof keep !== "boolean" && keep !== void 0 && keep !== null && keep.indexOf(c) !== -1;
1624
1627
  /**
1625
1628
  * Splits a string in any case into lowercase words: on `_`, `-`, `.` and spaces,
1626
1629
  * before an uppercase letter that follows a lowercase letter or a digit (`helloWorld`),
1627
1630
  * and before the last letter of an acronym (`XMLHttp`). Mirrors the `Words` type.
1631
+ *
1632
+ * Symbols (ASCII punctuation) also start a new word. They are removed, unless `keep` is
1633
+ * `true` or lists them: a kept symbol sticks to the start of the next word (`hello$World`
1634
+ * → `hello`, `$world`), or to the end of the previous one when no word follows (`total%`).
1635
+ * Words keep their original case when `lowercase` is `false`.
1628
1636
  */
1629
- function words(str) {
1637
+ function words(str, keep = false, lowercase = true) {
1630
1638
  const result = [];
1631
1639
  let word = "";
1632
1640
  let prev = "";
1633
1641
  const push = () => {
1634
- if (word) result.push(word.toLowerCase());
1642
+ if (word) result.push(lowercase ? word.toLowerCase() : word);
1635
1643
  word = "";
1636
1644
  };
1637
1645
  for (let i = 0; i < str.length; i++) {
@@ -1641,145 +1649,114 @@ function words(str) {
1641
1649
  prev = "";
1642
1650
  continue;
1643
1651
  }
1652
+ if (isSymbol(c)) {
1653
+ let kept = "";
1654
+ let j = i;
1655
+ for (; j < str.length && isSymbol(str[j]); j++) if (isKept(str[j], keep)) kept += str[j];
1656
+ const next = str.charAt(j);
1657
+ if (next && !isSeparator(next)) {
1658
+ push();
1659
+ prev = "";
1660
+ }
1661
+ word += kept;
1662
+ i = j - 1;
1663
+ continue;
1664
+ }
1644
1665
  const next = str.charAt(i + 1);
1645
- if (isUpper(c) && word && (!isUpper(prev) || next && isLower(next))) push();
1666
+ if (isUpper(c) && prev && (!isUpper(prev) || next && isLower(next))) push();
1646
1667
  word += c;
1647
1668
  prev = c;
1648
1669
  }
1649
1670
  push();
1650
1671
  return result;
1651
1672
  }
1652
- const ToCamel = (str) => words(str).map((w, i) => i ? Capitalize(w) : w).join("");
1653
- const ToPascal = (str) => words(str).map(Capitalize).join("");
1654
- const ToSnake = (str) => words(str).join("_");
1655
- const ToDash = (str) => words(str).join("-");
1656
- const ToUpperSnake = (str) => words(str).join("_").toUpperCase();
1657
- const ToUpperDash = (str) => words(str).join("-").toUpperCase();
1658
- const ToTrain = (str) => words(str).map(Capitalize).join("-");
1659
- const ToDot = (str) => words(str).join(".");
1660
- const ToTitle = (str) => words(str).map(Capitalize).join(" ");
1661
- const ToSentence = (str) => Capitalize(words(str).join(" "));
1673
+ /** Uppercases the first character that is not a symbol: `'$id'` → `'$Id'`. */
1674
+ function capitalize(word) {
1675
+ let i = 0;
1676
+ while (i < word.length && isSymbol(word[i])) i++;
1677
+ return word.slice(0, i) + word.charAt(i).toUpperCase() + word.slice(i + 1);
1678
+ }
1679
+ /** Changes the case of the whole string, or keeps it when `transform` is `undefined`. */
1680
+ function applyTransform(str, transform) {
1681
+ if (transform === "lowercase") return str.toLowerCase();
1682
+ if (transform === "uppercase") return str.toUpperCase();
1683
+ return str;
1684
+ }
1685
+ const ToCamel = (str, keep) => words(str, keep).map((w, i) => i ? capitalize(w) : w).join("");
1686
+ const ToPascal = (str, keep) => words(str, keep).map(capitalize).join("");
1687
+ const ToSnake = (str, keep) => words(str, keep).join("_");
1688
+ const ToKebab = (str, keep) => words(str, keep).join("-");
1689
+ const ToUpperSnake = (str, keep) => words(str, keep).join("_").toUpperCase();
1690
+ const ToUpperKebab = (str, keep) => words(str, keep).join("-").toUpperCase();
1691
+ const ToTrain = (str, keep) => words(str, keep).map(capitalize).join("-");
1692
+ const ToDot = (str, keep, transform) => applyTransform(words(str, keep, false).join("."), transform);
1693
+ const ToTitle = (str, keep) => words(str, keep).map(capitalize).join(" ");
1694
+ const ToSentence = (str, keep) => capitalize(words(str, keep).join(" "));
1695
+ const ToPascalSnake = (str, keep) => words(str, keep).map(capitalize).join("_");
1696
+ const ToPath = (str, keep, transform, separator = "/") => applyTransform(words(str.replace(/[/\\]/g, " "), keep, false).join(separator), transform);
1697
+ const ToSpace = (str, keep) => words(str, keep, false).join(" ");
1698
+ const ToLower = (str, keep) => words(str, keep).join(" ");
1699
+ const ToUpper = (str, keep) => words(str, keep).join(" ").toUpperCase();
1662
1700
  //#endregion
1663
1701
  //#region src/anyCase/anyCase.ts
1664
- /**
1665
- * Converts a string, or the keys of an object/array (deeply), from any case to camelCase.
1666
- *
1667
- * @example
1668
- * ```ts
1669
- * toCamel('hello_world'); // 'helloWorld'
1670
- * toCamel({ first_name: 'John', userID: 1 }); // { firstName: 'John', userId: 1 }
1671
- * ```
1672
- */
1673
- function toCamel(input) {
1674
- return convert(input, ToCamel);
1702
+ /** Reads the second argument of a `toX` function: the `allowSymbols` shorthand, or an options object. */
1703
+ function parseOptions(options) {
1704
+ if (typeof options === "object" && options !== null && !Array.isArray(options)) {
1705
+ const { allowSymbols, transform, separator } = options;
1706
+ return {
1707
+ allowSymbols,
1708
+ transform,
1709
+ separator
1710
+ };
1711
+ }
1712
+ return { allowSymbols: options };
1675
1713
  }
1676
- /**
1677
- * Converts a string, or the keys of an object/array (deeply), from any case to PascalCase.
1678
- *
1679
- * @example
1680
- * ```ts
1681
- * toPascal('hello-world'); // 'HelloWorld'
1682
- * toPascal({ 'first-name': 'John', userID: 1 }); // { FirstName: 'John', UserId: 1 }
1683
- * ```
1684
- */
1685
- function toPascal(input) {
1686
- return convert(input, ToPascal);
1714
+ function toCamel(input, options) {
1715
+ return convert(input, (key) => ToCamel(key, parseOptions(options).allowSymbols));
1687
1716
  }
1688
- /**
1689
- * Converts a string, or the keys of an object/array (deeply), from any case to snake_case.
1690
- *
1691
- * @example
1692
- * ```ts
1693
- * toSnake('helloWorld'); // 'hello_world'
1694
- * toSnake({ firstName: 'John', userID: 1 }); // { first_name: 'John', user_id: 1 }
1695
- * ```
1696
- */
1697
- function toSnake(input) {
1698
- return convert(input, ToSnake);
1717
+ function toPascal(input, options) {
1718
+ return convert(input, (key) => ToPascal(key, parseOptions(options).allowSymbols));
1699
1719
  }
1700
- /**
1701
- * Converts a string, or the keys of an object/array (deeply), from any case to dash-case.
1702
- *
1703
- * @example
1704
- * ```ts
1705
- * toDash('HELLO_WORLD'); // 'hello-world'
1706
- * toDash({ FIRST_NAME: 'John', userID: 1 }); // { 'first-name': 'John', 'user-id': 1 }
1707
- * ```
1708
- */
1709
- function toDash(input) {
1710
- return convert(input, ToDash);
1720
+ function toSnake(input, options) {
1721
+ return convert(input, (key) => ToSnake(key, parseOptions(options).allowSymbols));
1711
1722
  }
1712
- /**
1713
- * Converts a string, or the keys of an object/array (deeply), from any case to UPPER_SNAKE_CASE.
1714
- *
1715
- * @example
1716
- * ```ts
1717
- * toUpperSnake('hello-world'); // 'HELLO_WORLD'
1718
- * toUpperSnake({ 'first-name': 'John', userID: 1 }); // { FIRST_NAME: 'John', USER_ID: 1 }
1719
- * ```
1720
- */
1721
- function toUpperSnake(input) {
1722
- return convert(input, ToUpperSnake);
1723
+ function toKebab(input, options) {
1724
+ return convert(input, (key) => ToKebab(key, parseOptions(options).allowSymbols));
1723
1725
  }
1724
- /**
1725
- * Converts a string, or the keys of an object/array (deeply), from any case to UPPER-DASH-CASE.
1726
- *
1727
- * @example
1728
- * ```ts
1729
- * toUpperDash('helloWorld'); // 'HELLO-WORLD'
1730
- * toUpperDash({ firstName: 'John', userID: 1 }); // { 'FIRST-NAME': 'John', 'USER-ID': 1 }
1731
- * ```
1732
- */
1733
- function toUpperDash(input) {
1734
- return convert(input, ToUpperDash);
1726
+ function toUpperSnake(input, options) {
1727
+ return convert(input, (key) => ToUpperSnake(key, parseOptions(options).allowSymbols));
1735
1728
  }
1736
- /**
1737
- * Converts a string, or the keys of an object/array (deeply), from any case to Train-Case.
1738
- *
1739
- * @example
1740
- * ```ts
1741
- * toTrain('hello_world'); // 'Hello-World'
1742
- * toTrain({ first_name: 'John', userID: 1 }); // { 'First-Name': 'John', 'User-Id': 1 }
1743
- * ```
1744
- */
1745
- function toTrain(input) {
1746
- return convert(input, ToTrain);
1729
+ function toUpperKebab(input, options) {
1730
+ return convert(input, (key) => ToUpperKebab(key, parseOptions(options).allowSymbols));
1747
1731
  }
1748
- /**
1749
- * Converts a string, or the keys of an object/array (deeply), from any case to dot.case.
1750
- *
1751
- * @example
1752
- * ```ts
1753
- * toDot('HelloWorld'); // 'hello.world'
1754
- * toDot({ FirstName: 'John', userID: 1 }); // { 'first.name': 'John', 'user.id': 1 }
1755
- * ```
1756
- */
1757
- function toDot(input) {
1758
- return convert(input, ToDot);
1732
+ function toTrain(input, options) {
1733
+ return convert(input, (key) => ToTrain(key, parseOptions(options).allowSymbols));
1759
1734
  }
1760
- /**
1761
- * Converts a string, or the keys of an object/array (deeply), from any case to Title Case.
1762
- *
1763
- * @example
1764
- * ```ts
1765
- * toTitle('hello_world'); // 'Hello World'
1766
- * toTitle({ first_name: 'John', userID: 1 }); // { 'First Name': 'John', 'User Id': 1 }
1767
- * ```
1768
- */
1769
- function toTitle(input) {
1770
- return convert(input, ToTitle);
1735
+ function toDot(input, options) {
1736
+ const { allowSymbols, transform } = parseOptions(options);
1737
+ return convert(input, (key) => ToDot(key, allowSymbols, transform));
1771
1738
  }
1772
- /**
1773
- * Converts a string, or the keys of an object/array (deeply), from any case to Sentence case.
1774
- *
1775
- * @example
1776
- * ```ts
1777
- * toSentence('helloWorld'); // 'Hello world'
1778
- * toSentence({ firstName: 'John', userID: 1 }); // { 'First name': 'John', 'User id': 1 }
1779
- * ```
1780
- */
1781
- function toSentence(input) {
1782
- return convert(input, ToSentence);
1739
+ function toTitle(input, options) {
1740
+ return convert(input, (key) => ToTitle(key, parseOptions(options).allowSymbols));
1741
+ }
1742
+ function toSentence(input, options) {
1743
+ return convert(input, (key) => ToSentence(key, parseOptions(options).allowSymbols));
1744
+ }
1745
+ function toPascalSnake(input, options) {
1746
+ return convert(input, (key) => ToPascalSnake(key, parseOptions(options).allowSymbols));
1747
+ }
1748
+ function toPath(input, options) {
1749
+ const { allowSymbols, transform, separator } = parseOptions(options);
1750
+ return convert(input, (key) => ToPath(key, allowSymbols, transform, separator === "\\" ? "\\" : "/"));
1751
+ }
1752
+ function toSpace(input, options) {
1753
+ return convert(input, (key) => ToSpace(key, parseOptions(options).allowSymbols));
1754
+ }
1755
+ function toLower(input, options) {
1756
+ return convert(input, (key) => ToLower(key, parseOptions(options).allowSymbols));
1757
+ }
1758
+ function toUpper(input, options) {
1759
+ return convert(input, (key) => ToUpper(key, parseOptions(options).allowSymbols));
1783
1760
  }
1784
1761
  //#endregion
1785
- export { camelToDash, camelToDot, camelToPascal, camelToSentence, camelToSnake, camelToTitle, camelToTrain, camelToUpperDash, camelToUpperSnake, dashToCamel, dashToDot, dashToPascal, dashToSentence, dashToSnake, dashToTitle, dashToTrain, dashToUpperDash, dashToUpperSnake, dotToCamel, dotToDash, dotToPascal, dotToSentence, dotToSnake, dotToTitle, dotToTrain, dotToUpperDash, dotToUpperSnake, pascalToCamel, pascalToDash, pascalToDot, pascalToSentence, pascalToSnake, pascalToTitle, pascalToTrain, pascalToUpperDash, pascalToUpperSnake, sentenceToCamel, sentenceToDash, sentenceToDot, sentenceToPascal, sentenceToSnake, sentenceToTitle, sentenceToTrain, sentenceToUpperDash, sentenceToUpperSnake, snakeToCamel, snakeToDash, snakeToDot, snakeToPascal, snakeToSentence, snakeToTitle, snakeToTrain, snakeToUpperDash, snakeToUpperSnake, titleToCamel, titleToDash, titleToDot, titleToPascal, titleToSentence, titleToSnake, titleToTrain, titleToUpperDash, titleToUpperSnake, toCamel, toDash, toDot, toPascal, toSentence, toSnake, toTitle, toTrain, toUpperDash, toUpperSnake, trainToCamel, trainToDash, trainToDot, trainToPascal, trainToSentence, trainToSnake, trainToTitle, trainToUpperDash, trainToUpperSnake, upperDashToCamel, upperDashToDash, upperDashToDot, upperDashToPascal, upperDashToSentence, upperDashToSnake, upperDashToTitle, upperDashToTrain, upperDashToUpperSnake, upperSnakeToCamel, upperSnakeToDash, upperSnakeToDot, upperSnakeToPascal, upperSnakeToSentence, upperSnakeToSnake, upperSnakeToTitle, upperSnakeToTrain, upperSnakeToUpperDash };
1762
+ export { camelToDash, camelToDot, camelToPascal, camelToSentence, camelToSnake, camelToTitle, camelToTrain, camelToUpperDash, camelToUpperSnake, dashToCamel, dashToDot, dashToPascal, dashToSentence, dashToSnake, dashToTitle, dashToTrain, dashToUpperDash, dashToUpperSnake, dotToCamel, dotToDash, dotToPascal, dotToSentence, dotToSnake, dotToTitle, dotToTrain, dotToUpperDash, dotToUpperSnake, pascalToCamel, pascalToDash, pascalToDot, pascalToSentence, pascalToSnake, pascalToTitle, pascalToTrain, pascalToUpperDash, pascalToUpperSnake, sentenceToCamel, sentenceToDash, sentenceToDot, sentenceToPascal, sentenceToSnake, sentenceToTitle, sentenceToTrain, sentenceToUpperDash, sentenceToUpperSnake, snakeToCamel, snakeToDash, snakeToDot, snakeToPascal, snakeToSentence, snakeToTitle, snakeToTrain, snakeToUpperDash, snakeToUpperSnake, titleToCamel, titleToDash, titleToDot, titleToPascal, titleToSentence, titleToSnake, titleToTrain, titleToUpperDash, titleToUpperSnake, toCamel, toDot, toKebab, toLower, toPascal, toPascalSnake, toPath, toSentence, toSnake, toSpace, toTitle, toTrain, toUpper, toUpperKebab, toUpperSnake, trainToCamel, trainToDash, trainToDot, trainToPascal, trainToSentence, trainToSnake, trainToTitle, trainToUpperDash, trainToUpperSnake, upperDashToCamel, upperDashToDash, upperDashToDot, upperDashToPascal, upperDashToSentence, upperDashToSnake, upperDashToTitle, upperDashToTrain, upperDashToUpperSnake, upperSnakeToCamel, upperSnakeToDash, upperSnakeToDot, upperSnakeToPascal, upperSnakeToSentence, upperSnakeToSnake, upperSnakeToTitle, upperSnakeToTrain, upperSnakeToUpperDash };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "caseparser",
3
- "version": "4.3.0",
3
+ "version": "5.1.0",
4
4
  "description": "Convert Strings/Arrays/Objects from a type of case to another one.",
5
5
  "author": "Fernando Machado Bernardino <fernandombernardino@gmail.com>",
6
6
  "homepage": "https://github.com/NandoMB/caseparser#readme",
@@ -44,20 +44,28 @@
44
44
  "coverage": "vitest run --project node --coverage",
45
45
  "build": "tsdown",
46
46
  "lint": "tsc",
47
- "ci": "pnpm run lint && pnpm run test && pnpm run build",
47
+ "ci": "pnpm run lint && pnpm run test && pnpm run build && pnpm run lint:package",
48
48
  "release": "node scripts/release.js",
49
49
  "changeset:version": "changeset version && node scripts/sync-jsr-version.js",
50
+ "lint:package": "publint && attw --pack .",
50
51
  "test:browser": "vitest run --project browser",
51
- "test:examples": "node scripts/test-examples.js"
52
+ "test:bun": "bunx --bun vitest run --project node",
53
+ "test:deno": "deno run -A node_modules/vitest/vitest.mjs run --project node",
54
+ "test:ts-legacy": "node node_modules/typescript-4.1/bin/tsc -p test/typescript-4.1",
55
+ "lint:jsr": "deno publish --dry-run --allow-dirty",
56
+ "test:ci": "pnpm run ci && pnpm run test:ts-legacy && pnpm run test:browser && pnpm run test:bun && pnpm run test:deno && pnpm run lint:jsr"
52
57
  },
53
58
  "devDependencies": {
59
+ "@arethetypeswrong/cli": "^0.18.5",
54
60
  "@changesets/cli": "^3.0.3",
55
61
  "@types/node": "^26.6.2",
56
62
  "@vitest/browser-playwright": "^5.0.1",
57
63
  "@vitest/coverage-istanbul": "^5.0.1",
58
64
  "playwright": "^1.63.0",
65
+ "publint": "^0.3.24",
59
66
  "tsdown": "^0.23.0",
60
67
  "typescript": "^7.0.2",
68
+ "typescript-4.1": "npm:typescript@4.1.6",
61
69
  "vitest": "^5.0.1"
62
70
  },
63
71
  "keywords": [
@@ -68,6 +76,9 @@
68
76
  "camel case",
69
77
  "snake case",
70
78
  "dash case",
79
+ "kebab case",
80
+ "constant case",
81
+ "header case",
71
82
  "pascal case",
72
83
  "upper snake case",
73
84
  "upper dash case",
@@ -78,6 +89,7 @@
78
89
  "camelCase",
79
90
  "snake_case",
80
91
  "dash-case",
92
+ "kebab-case",
81
93
  "PascalCase",
82
94
  "UPPER_SNAKE_CASE",
83
95
  "UPPER-DASH-CASE",