@ls-stack/utils 3.54.0 → 3.55.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.
@@ -3,7 +3,7 @@ import {
3
3
  } from "./chunk-IATIXMCE.js";
4
4
  import {
5
5
  truncateString
6
- } from "./chunk-B3KFV2MH.js";
6
+ } from "./chunk-BM4PYVOX.js";
7
7
  import {
8
8
  isObject,
9
9
  isPlainObject
@@ -22,6 +22,33 @@ function formatNum(num, maxDecimalsOrOptions = 2) {
22
22
  function isSnakeCase(str) {
23
23
  return /^[a-z0-9_]+$/.test(str);
24
24
  }
25
+ function isKebabCase(str) {
26
+ return /^[a-z0-9]+(-[a-z0-9]+)*$/.test(str);
27
+ }
28
+ function isPascalCase(str) {
29
+ return /^[A-Z][a-zA-Z0-9]*$/.test(str);
30
+ }
31
+ function isCamelCase(str) {
32
+ return /^[a-z][a-zA-Z0-9]*$/.test(str);
33
+ }
34
+ function isTitleCase(str) {
35
+ return /^[A-Z][a-z0-9]*( ([A-Z][a-z0-9]*|[0-9]+))*$/.test(str);
36
+ }
37
+ function isSentenceCase(str) {
38
+ return /^[A-Z][a-z0-9]*( [a-z0-9]+)*$/.test(str);
39
+ }
40
+ function isConstantCase(str) {
41
+ return /^[A-Z_][A-Z0-9_]*$/.test(str);
42
+ }
43
+ function isDotCase(str) {
44
+ return /^[a-z0-9]+(\.[a-z0-9]+)*$/.test(str);
45
+ }
46
+ function isPathCase(str) {
47
+ return /^[a-z0-9]+(\/[a-z0-9]+)*$/.test(str);
48
+ }
49
+ function convertToKebabCase(str) {
50
+ return convertToSnakeCase(str).replace(/_/g, "-");
51
+ }
25
52
  function convertToSnakeCase(str) {
26
53
  return str.replace(/[\s\-.]+/g, "_").replace(/([a-z0-9])([A-Z])/g, "$1_$2").replace(/([A-Z])([A-Z][a-z])/g, "$1_$2").toLowerCase().replace(/[^a-z0-9_]/g, "").replace(/^_+|_+$/g, "").replace(/_+/g, "_");
27
54
  }
@@ -38,6 +65,15 @@ function convertToSentenceCase(str) {
38
65
  function convertToTitleCase(str) {
39
66
  return str.replace(/[\s\-.]+/g, " ").replace(/([a-z0-9])([A-Z])/g, "$1 $2").replace(/([A-Z])([A-Z][a-z])/g, "$1 $2").split(/[\s_-]+/).map((word) => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase()).join(" ");
40
67
  }
68
+ function convertToConstantCase(str) {
69
+ return convertToSnakeCase(str).toUpperCase();
70
+ }
71
+ function convertToDotCase(str) {
72
+ return convertToSnakeCase(str).replace(/_/g, ".");
73
+ }
74
+ function convertToPathCase(str) {
75
+ return convertToSnakeCase(str).replace(/_/g, "/");
76
+ }
41
77
  function truncateString(str, length, ellipsis = "\u2026") {
42
78
  if (str.length <= length) return str;
43
79
  return str.slice(0, length - 1) + ellipsis;
@@ -51,11 +87,23 @@ export {
51
87
  joinStrings,
52
88
  formatNum,
53
89
  isSnakeCase,
90
+ isKebabCase,
91
+ isPascalCase,
92
+ isCamelCase,
93
+ isTitleCase,
94
+ isSentenceCase,
95
+ isConstantCase,
96
+ isDotCase,
97
+ isPathCase,
98
+ convertToKebabCase,
54
99
  convertToSnakeCase,
55
100
  convertToPascalCase,
56
101
  convertToCamelCase,
57
102
  convertToSentenceCase,
58
103
  convertToTitleCase,
104
+ convertToConstantCase,
105
+ convertToDotCase,
106
+ convertToPathCase,
59
107
  truncateString,
60
108
  removeANSIColors
61
109
  };
@@ -3,7 +3,7 @@ import {
3
3
  } from "./chunk-VAAMRG4K.js";
4
4
  import {
5
5
  truncateString
6
- } from "./chunk-B3KFV2MH.js";
6
+ } from "./chunk-BM4PYVOX.js";
7
7
  import {
8
8
  sleep
9
9
  } from "./chunk-5DZT3Z5Z.js";
@@ -22,12 +22,24 @@ var stringUtils_exports = {};
22
22
  __export(stringUtils_exports, {
23
23
  concatStrings: () => concatStrings,
24
24
  convertToCamelCase: () => convertToCamelCase,
25
+ convertToConstantCase: () => convertToConstantCase,
26
+ convertToDotCase: () => convertToDotCase,
27
+ convertToKebabCase: () => convertToKebabCase,
25
28
  convertToPascalCase: () => convertToPascalCase,
29
+ convertToPathCase: () => convertToPathCase,
26
30
  convertToSentenceCase: () => convertToSentenceCase,
27
31
  convertToSnakeCase: () => convertToSnakeCase,
28
32
  convertToTitleCase: () => convertToTitleCase,
29
33
  formatNum: () => formatNum,
34
+ isCamelCase: () => isCamelCase,
35
+ isConstantCase: () => isConstantCase,
36
+ isDotCase: () => isDotCase,
37
+ isKebabCase: () => isKebabCase,
38
+ isPascalCase: () => isPascalCase,
39
+ isPathCase: () => isPathCase,
40
+ isSentenceCase: () => isSentenceCase,
30
41
  isSnakeCase: () => isSnakeCase,
42
+ isTitleCase: () => isTitleCase,
31
43
  joinStrings: () => joinStrings,
32
44
  removeANSIColors: () => removeANSIColors,
33
45
  truncateString: () => truncateString
@@ -56,6 +68,33 @@ function formatNum(num, maxDecimalsOrOptions = 2) {
56
68
  function isSnakeCase(str) {
57
69
  return /^[a-z0-9_]+$/.test(str);
58
70
  }
71
+ function isKebabCase(str) {
72
+ return /^[a-z0-9]+(-[a-z0-9]+)*$/.test(str);
73
+ }
74
+ function isPascalCase(str) {
75
+ return /^[A-Z][a-zA-Z0-9]*$/.test(str);
76
+ }
77
+ function isCamelCase(str) {
78
+ return /^[a-z][a-zA-Z0-9]*$/.test(str);
79
+ }
80
+ function isTitleCase(str) {
81
+ return /^[A-Z][a-z0-9]*( ([A-Z][a-z0-9]*|[0-9]+))*$/.test(str);
82
+ }
83
+ function isSentenceCase(str) {
84
+ return /^[A-Z][a-z0-9]*( [a-z0-9]+)*$/.test(str);
85
+ }
86
+ function isConstantCase(str) {
87
+ return /^[A-Z_][A-Z0-9_]*$/.test(str);
88
+ }
89
+ function isDotCase(str) {
90
+ return /^[a-z0-9]+(\.[a-z0-9]+)*$/.test(str);
91
+ }
92
+ function isPathCase(str) {
93
+ return /^[a-z0-9]+(\/[a-z0-9]+)*$/.test(str);
94
+ }
95
+ function convertToKebabCase(str) {
96
+ return convertToSnakeCase(str).replace(/_/g, "-");
97
+ }
59
98
  function convertToSnakeCase(str) {
60
99
  return str.replace(/[\s\-.]+/g, "_").replace(/([a-z0-9])([A-Z])/g, "$1_$2").replace(/([A-Z])([A-Z][a-z])/g, "$1_$2").toLowerCase().replace(/[^a-z0-9_]/g, "").replace(/^_+|_+$/g, "").replace(/_+/g, "_");
61
100
  }
@@ -72,6 +111,15 @@ function convertToSentenceCase(str) {
72
111
  function convertToTitleCase(str) {
73
112
  return str.replace(/[\s\-.]+/g, " ").replace(/([a-z0-9])([A-Z])/g, "$1 $2").replace(/([A-Z])([A-Z][a-z])/g, "$1 $2").split(/[\s_-]+/).map((word) => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase()).join(" ");
74
113
  }
114
+ function convertToConstantCase(str) {
115
+ return convertToSnakeCase(str).toUpperCase();
116
+ }
117
+ function convertToDotCase(str) {
118
+ return convertToSnakeCase(str).replace(/_/g, ".");
119
+ }
120
+ function convertToPathCase(str) {
121
+ return convertToSnakeCase(str).replace(/_/g, "/");
122
+ }
75
123
  function truncateString(str, length, ellipsis = "\u2026") {
76
124
  if (str.length <= length) return str;
77
125
  return str.slice(0, length - 1) + ellipsis;
@@ -83,12 +131,24 @@ function removeANSIColors(str) {
83
131
  0 && (module.exports = {
84
132
  concatStrings,
85
133
  convertToCamelCase,
134
+ convertToConstantCase,
135
+ convertToDotCase,
136
+ convertToKebabCase,
86
137
  convertToPascalCase,
138
+ convertToPathCase,
87
139
  convertToSentenceCase,
88
140
  convertToSnakeCase,
89
141
  convertToTitleCase,
90
142
  formatNum,
143
+ isCamelCase,
144
+ isConstantCase,
145
+ isDotCase,
146
+ isKebabCase,
147
+ isPascalCase,
148
+ isPathCase,
149
+ isSentenceCase,
91
150
  isSnakeCase,
151
+ isTitleCase,
92
152
  joinStrings,
93
153
  removeANSIColors,
94
154
  truncateString
@@ -14,12 +14,24 @@ declare function concatStrings(...args: (Arg | Arg[])[]): string;
14
14
  declare const joinStrings: typeof concatStrings;
15
15
  declare function formatNum(num: number, maxDecimalsOrOptions?: number | Intl.NumberFormatOptions): string;
16
16
  declare function isSnakeCase(str: string): boolean;
17
+ declare function isKebabCase(str: string): boolean;
18
+ declare function isPascalCase(str: string): boolean;
19
+ declare function isCamelCase(str: string): boolean;
20
+ declare function isTitleCase(str: string): boolean;
21
+ declare function isSentenceCase(str: string): boolean;
22
+ declare function isConstantCase(str: string): boolean;
23
+ declare function isDotCase(str: string): boolean;
24
+ declare function isPathCase(str: string): boolean;
25
+ declare function convertToKebabCase(str: string): string;
17
26
  declare function convertToSnakeCase(str: string): string;
18
27
  declare function convertToPascalCase(str: string): string;
19
28
  declare function convertToCamelCase(str: string): string;
20
29
  declare function convertToSentenceCase(str: string): string;
21
30
  declare function convertToTitleCase(str: string): string;
31
+ declare function convertToConstantCase(str: string): string;
32
+ declare function convertToDotCase(str: string): string;
33
+ declare function convertToPathCase(str: string): string;
22
34
  declare function truncateString(str: string, length: number, ellipsis?: string): string;
23
35
  declare function removeANSIColors(str: string): string;
24
36
 
25
- export { concatStrings, convertToCamelCase, convertToPascalCase, convertToSentenceCase, convertToSnakeCase, convertToTitleCase, formatNum, isSnakeCase, joinStrings, removeANSIColors, truncateString };
37
+ export { concatStrings, convertToCamelCase, convertToConstantCase, convertToDotCase, convertToKebabCase, convertToPascalCase, convertToPathCase, convertToSentenceCase, convertToSnakeCase, convertToTitleCase, formatNum, isCamelCase, isConstantCase, isDotCase, isKebabCase, isPascalCase, isPathCase, isSentenceCase, isSnakeCase, isTitleCase, joinStrings, removeANSIColors, truncateString };
@@ -14,12 +14,24 @@ declare function concatStrings(...args: (Arg | Arg[])[]): string;
14
14
  declare const joinStrings: typeof concatStrings;
15
15
  declare function formatNum(num: number, maxDecimalsOrOptions?: number | Intl.NumberFormatOptions): string;
16
16
  declare function isSnakeCase(str: string): boolean;
17
+ declare function isKebabCase(str: string): boolean;
18
+ declare function isPascalCase(str: string): boolean;
19
+ declare function isCamelCase(str: string): boolean;
20
+ declare function isTitleCase(str: string): boolean;
21
+ declare function isSentenceCase(str: string): boolean;
22
+ declare function isConstantCase(str: string): boolean;
23
+ declare function isDotCase(str: string): boolean;
24
+ declare function isPathCase(str: string): boolean;
25
+ declare function convertToKebabCase(str: string): string;
17
26
  declare function convertToSnakeCase(str: string): string;
18
27
  declare function convertToPascalCase(str: string): string;
19
28
  declare function convertToCamelCase(str: string): string;
20
29
  declare function convertToSentenceCase(str: string): string;
21
30
  declare function convertToTitleCase(str: string): string;
31
+ declare function convertToConstantCase(str: string): string;
32
+ declare function convertToDotCase(str: string): string;
33
+ declare function convertToPathCase(str: string): string;
22
34
  declare function truncateString(str: string, length: number, ellipsis?: string): string;
23
35
  declare function removeANSIColors(str: string): string;
24
36
 
25
- export { concatStrings, convertToCamelCase, convertToPascalCase, convertToSentenceCase, convertToSnakeCase, convertToTitleCase, formatNum, isSnakeCase, joinStrings, removeANSIColors, truncateString };
37
+ export { concatStrings, convertToCamelCase, convertToConstantCase, convertToDotCase, convertToKebabCase, convertToPascalCase, convertToPathCase, convertToSentenceCase, convertToSnakeCase, convertToTitleCase, formatNum, isCamelCase, isConstantCase, isDotCase, isKebabCase, isPascalCase, isPathCase, isSentenceCase, isSnakeCase, isTitleCase, joinStrings, removeANSIColors, truncateString };
@@ -1,25 +1,49 @@
1
1
  import {
2
2
  concatStrings,
3
3
  convertToCamelCase,
4
+ convertToConstantCase,
5
+ convertToDotCase,
6
+ convertToKebabCase,
4
7
  convertToPascalCase,
8
+ convertToPathCase,
5
9
  convertToSentenceCase,
6
10
  convertToSnakeCase,
7
11
  convertToTitleCase,
8
12
  formatNum,
13
+ isCamelCase,
14
+ isConstantCase,
15
+ isDotCase,
16
+ isKebabCase,
17
+ isPascalCase,
18
+ isPathCase,
19
+ isSentenceCase,
9
20
  isSnakeCase,
21
+ isTitleCase,
10
22
  joinStrings,
11
23
  removeANSIColors,
12
24
  truncateString
13
- } from "./chunk-B3KFV2MH.js";
25
+ } from "./chunk-BM4PYVOX.js";
14
26
  export {
15
27
  concatStrings,
16
28
  convertToCamelCase,
29
+ convertToConstantCase,
30
+ convertToDotCase,
31
+ convertToKebabCase,
17
32
  convertToPascalCase,
33
+ convertToPathCase,
18
34
  convertToSentenceCase,
19
35
  convertToSnakeCase,
20
36
  convertToTitleCase,
21
37
  formatNum,
38
+ isCamelCase,
39
+ isConstantCase,
40
+ isDotCase,
41
+ isKebabCase,
42
+ isPascalCase,
43
+ isPathCase,
44
+ isSentenceCase,
22
45
  isSnakeCase,
46
+ isTitleCase,
23
47
  joinStrings,
24
48
  removeANSIColors,
25
49
  truncateString
package/dist/testUtils.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  yamlStringify
3
- } from "./chunk-7L4KCZJJ.js";
3
+ } from "./chunk-B6DNOZCP.js";
4
4
  import {
5
5
  omit,
6
6
  pick
@@ -22,7 +22,7 @@ import {
22
22
  import {
23
23
  clampMin
24
24
  } from "./chunk-HTCYUMDR.js";
25
- import "./chunk-B3KFV2MH.js";
25
+ import "./chunk-BM4PYVOX.js";
26
26
  import {
27
27
  arrayWithPrevAndIndex,
28
28
  filterAndMap
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  yamlStringify
3
- } from "./chunk-7L4KCZJJ.js";
3
+ } from "./chunk-B6DNOZCP.js";
4
4
  import "./chunk-IATIXMCE.js";
5
- import "./chunk-B3KFV2MH.js";
5
+ import "./chunk-BM4PYVOX.js";
6
6
  import "./chunk-JF2MDHOJ.js";
7
7
  export {
8
8
  yamlStringify
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@ls-stack/utils",
3
3
  "description": "Universal TypeScript utilities for browser and Node.js",
4
- "version": "3.54.0",
4
+ "version": "3.55.0",
5
5
  "license": "MIT",
6
6
  "files": [
7
7
  "dist",