@zairakai/js-utils 1.0.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.
Files changed (93) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +270 -0
  3. package/dist/arrays.cjs +210 -0
  4. package/dist/arrays.d.cts +119 -0
  5. package/dist/arrays.d.ts +119 -0
  6. package/dist/arrays.js +32 -0
  7. package/dist/chunk-27YHP2CK.js +407 -0
  8. package/dist/chunk-3WNRYKPG.js +37 -0
  9. package/dist/chunk-42CHLXT7.js +214 -0
  10. package/dist/chunk-6F4PWJZI.js +0 -0
  11. package/dist/chunk-7SXRFZBB.js +173 -0
  12. package/dist/chunk-F6RSTW65.js +156 -0
  13. package/dist/chunk-G7ZJ23DW.js +253 -0
  14. package/dist/chunk-IPP7PA6H.js +136 -0
  15. package/dist/chunk-LDSWHSRX.js +96 -0
  16. package/dist/chunk-TY75OOIQ.js +700 -0
  17. package/dist/chunk-W6JEMFAF.js +54 -0
  18. package/dist/chunk-XEJLBAXE.js +164 -0
  19. package/dist/chunk-Z7G3SIQH.js +270 -0
  20. package/dist/chunk-ZJPKS2MQ.js +101 -0
  21. package/dist/collections.cjs +797 -0
  22. package/dist/collections.d.cts +353 -0
  23. package/dist/collections.d.ts +353 -0
  24. package/dist/collections.js +17 -0
  25. package/dist/datetime.cjs +80 -0
  26. package/dist/datetime.d.cts +75 -0
  27. package/dist/datetime.d.ts +75 -0
  28. package/dist/datetime.js +24 -0
  29. package/dist/equals.cjs +121 -0
  30. package/dist/equals.d.cts +24 -0
  31. package/dist/equals.d.ts +24 -0
  32. package/dist/equals.js +8 -0
  33. package/dist/formatters.cjs +201 -0
  34. package/dist/formatters.d.cts +180 -0
  35. package/dist/formatters.d.ts +180 -0
  36. package/dist/formatters.js +48 -0
  37. package/dist/index.cjs +2906 -0
  38. package/dist/index.d.cts +120 -0
  39. package/dist/index.d.ts +120 -0
  40. package/dist/index.js +348 -0
  41. package/dist/number.cjs +279 -0
  42. package/dist/number.d.cts +177 -0
  43. package/dist/number.d.ts +177 -0
  44. package/dist/number.js +10 -0
  45. package/dist/obj.cjs +427 -0
  46. package/dist/obj.d.cts +177 -0
  47. package/dist/obj.d.ts +177 -0
  48. package/dist/obj.js +12 -0
  49. package/dist/php-arrays.cjs +954 -0
  50. package/dist/php-arrays.d.cts +256 -0
  51. package/dist/php-arrays.d.ts +256 -0
  52. package/dist/php-arrays.js +70 -0
  53. package/dist/runtime.cjs +134 -0
  54. package/dist/runtime.d.cts +90 -0
  55. package/dist/runtime.d.ts +90 -0
  56. package/dist/runtime.js +24 -0
  57. package/dist/schemas.cjs +86 -0
  58. package/dist/schemas.d.cts +108 -0
  59. package/dist/schemas.d.ts +108 -0
  60. package/dist/schemas.js +22 -0
  61. package/dist/str.cjs +499 -0
  62. package/dist/str.d.cts +282 -0
  63. package/dist/str.d.ts +282 -0
  64. package/dist/str.js +11 -0
  65. package/dist/types.cjs +18 -0
  66. package/dist/types.d.cts +13 -0
  67. package/dist/types.d.ts +13 -0
  68. package/dist/types.js +1 -0
  69. package/dist/validator.cjs +251 -0
  70. package/dist/validator.d.cts +99 -0
  71. package/dist/validator.d.ts +99 -0
  72. package/dist/validator.js +11 -0
  73. package/dist/validators.cjs +217 -0
  74. package/dist/validators.d.cts +216 -0
  75. package/dist/validators.d.ts +216 -0
  76. package/dist/validators.js +64 -0
  77. package/package.json +180 -0
  78. package/src/arrays.ts +316 -0
  79. package/src/collections.ts +866 -0
  80. package/src/datetime.ts +103 -0
  81. package/src/equals.ts +134 -0
  82. package/src/formatters.ts +342 -0
  83. package/src/index.ts +36 -0
  84. package/src/number.ts +281 -0
  85. package/src/obj.ts +303 -0
  86. package/src/php-arrays.ts +445 -0
  87. package/src/pipe.ts +29 -0
  88. package/src/runtime.ts +194 -0
  89. package/src/schemas.ts +136 -0
  90. package/src/str.ts +438 -0
  91. package/src/types.ts +13 -0
  92. package/src/validator.ts +157 -0
  93. package/src/validators.ts +359 -0
@@ -0,0 +1,180 @@
1
+ /**
2
+ * String manipulation and formatting utilities
3
+ */
4
+ /**
5
+ * Capitalize the first letter of a string and lowercase the rest.
6
+ *
7
+ * @param {unknown} value The value to capitalize
8
+ * @returns {string} The capitalized string
9
+ */
10
+ declare const capitalize: (value: unknown) => string;
11
+ /**
12
+ * Convert a string into a URL-friendly "slug".
13
+ *
14
+ * @param {unknown} text The text to slugify
15
+ * @returns {string} The slugified string
16
+ */
17
+ declare const slugify: (text: unknown) => string;
18
+ /**
19
+ * Limit the number of characters in a string.
20
+ *
21
+ * @param {unknown} value The string to limit
22
+ * @param {number} size The maximum number of characters
23
+ * @returns {string} The limited string
24
+ */
25
+ declare const strLimit: (value: unknown, size: number) => string;
26
+ /**
27
+ * Normalize a string by trimming, lowercasing, and removing accents.
28
+ *
29
+ * @param {string | null | undefined} value The string to normalize
30
+ * @returns {string | null | undefined} The normalized string
31
+ */
32
+ declare const normalizeString: (value: string | null | undefined) => string | null | undefined;
33
+ /**
34
+ * Determine if a string contains all of the given values.
35
+ *
36
+ * @param {string} haystack The string to search in
37
+ * @param {string[]} needles The values to search for
38
+ * @returns {boolean} True if all values are found
39
+ */
40
+ declare const strContainsAll: (haystack: string, needles: string[]) => boolean;
41
+ /**
42
+ * Determine if a string contains any of the given values.
43
+ *
44
+ * @param {string} haystack The string to search in
45
+ * @param {string[]} needles The values to search for
46
+ * @returns {boolean} True if any value is found
47
+ */
48
+ declare const strContainsAny: (haystack: string, needles: string[]) => boolean;
49
+ /**
50
+ * Cap a string with a single instance of a given value.
51
+ *
52
+ * @param {string} value The source string
53
+ * @param {string} cap The value to append if not present
54
+ * @returns {string} The capped string
55
+ */
56
+ declare const strFinish: (value: string, cap: string) => string;
57
+ /**
58
+ * Begin a string with a single instance of a given value.
59
+ *
60
+ * @param {string} value The source string
61
+ * @param {string} prefix The value to prepend if not present
62
+ * @returns {string} The prefixed string
63
+ */
64
+ declare const strStart: (value: string, prefix: string) => string;
65
+ /**
66
+ * Pad both sides of a string with another.
67
+ *
68
+ * @param {string} str The source string
69
+ * @param {number} length The desired length
70
+ * @param {string} [pad=' '] The value to pad with
71
+ * @returns {string} The padded string
72
+ */
73
+ declare const strPadBoth: (str: string, length: number, pad?: string) => string;
74
+ /**
75
+ * Pad the left side of a string with another.
76
+ *
77
+ * @param {string} str The source string
78
+ * @param {number} length The desired length
79
+ * @param {string} [pad=' '] The value to pad with
80
+ * @returns {string} The padded string
81
+ */
82
+ declare const strPadLeft: (str: string, length: number, pad?: string) => string;
83
+ /**
84
+ * Pad the right side of a string with another.
85
+ *
86
+ * @param {string} str The source string
87
+ * @param {number} length The desired length
88
+ * @param {string} [pad=' '] The value to pad with
89
+ * @returns {string} The padded string
90
+ */
91
+ declare const strPadRight: (str: string, length: number, pad?: string) => string;
92
+ /**
93
+ * Reverse the given string.
94
+ *
95
+ * @param {string} value The string to reverse
96
+ * @returns {string} The reversed string
97
+ */
98
+ declare const strReverse: (value: string) => string;
99
+ /**
100
+ * Remove any occurrence of the given string in the subject.
101
+ *
102
+ * @param {string} search The string to remove
103
+ * @param {string} subject The source string
104
+ * @param {boolean} [caseSensitive=true] Whether to perform case-sensitive removal
105
+ * @returns {string} The resulting string
106
+ */
107
+ declare const strRemove: (search: string, subject: string, caseSensitive?: boolean) => string;
108
+ /**
109
+ * Mask a portion of a string with a repeated character.
110
+ *
111
+ * @param {string} str The source string
112
+ * @param {string} character The character to use for masking
113
+ * @param {number} index The starting index
114
+ * @param {number} [length] The number of characters to mask
115
+ * @returns {string} The masked string
116
+ */
117
+ declare const strMask: (str: string, character: string, index: number, length?: number) => string;
118
+ /**
119
+ * Count the number of words in a string.
120
+ *
121
+ * @param {string} str The string to count words in
122
+ * @param {string} [characters] Optional characters to treat as word boundaries
123
+ * @returns {number} The word count
124
+ */
125
+ declare const strWordCount: (str: string, characters?: string) => number;
126
+ /**
127
+ * Limit the number of words in a string.
128
+ *
129
+ * @param {string} value The string to limit
130
+ * @param {number} [words=100] The maximum number of words
131
+ * @param {string} [end='...'] The string to append if truncated
132
+ * @returns {string} The limited string
133
+ */
134
+ declare const strWords: (value: string, words?: number, end?: string) => string;
135
+ /**
136
+ * Convert a string to camelCase.
137
+ *
138
+ * @param {string} value The string to convert
139
+ * @returns {string} The camelCased string
140
+ */
141
+ declare const camelCase: (value: string) => string;
142
+ /**
143
+ * Convert a string to snake_case.
144
+ *
145
+ * @param {string} value The string to convert
146
+ * @returns {string} The snake_cased string
147
+ */
148
+ declare const snakeCase: (value: string) => string;
149
+ /**
150
+ * Convert a string to kebab-case.
151
+ *
152
+ * @param {string} value The string to convert
153
+ * @returns {string} The kebab-cased string
154
+ */
155
+ declare const kebabCase: (value: string) => string;
156
+ /**
157
+ * Convert a string to StudlyCase.
158
+ *
159
+ * @param {string} value The string to convert
160
+ * @returns {string} The studlyCased string
161
+ */
162
+ declare const studlyCase: (value: string) => string;
163
+ /**
164
+ * Convert a string to Title Case.
165
+ *
166
+ * @param {string} value The string to convert
167
+ * @returns {string} The titleCased string
168
+ */
169
+ declare const titleCase: (value: string) => string;
170
+ /**
171
+ * Format a number with grouped thousands and decimal point.
172
+ *
173
+ * @param {number} value The number to format
174
+ * @param {number} [decimals=2] The number of decimal points
175
+ * @param {string} [locale='en-US'] The locale to use for formatting
176
+ * @returns {string} The formatted number
177
+ */
178
+ declare const numberFormat: (value: number, decimals?: number, locale?: string) => string;
179
+
180
+ export { camelCase, capitalize, kebabCase, normalizeString, numberFormat, slugify, snakeCase, strContainsAll, strContainsAny, strFinish, strLimit, strMask, strPadBoth, strPadLeft, strPadRight, strRemove, strReverse, strStart, strWordCount, strWords, studlyCase, titleCase };
@@ -0,0 +1,180 @@
1
+ /**
2
+ * String manipulation and formatting utilities
3
+ */
4
+ /**
5
+ * Capitalize the first letter of a string and lowercase the rest.
6
+ *
7
+ * @param {unknown} value The value to capitalize
8
+ * @returns {string} The capitalized string
9
+ */
10
+ declare const capitalize: (value: unknown) => string;
11
+ /**
12
+ * Convert a string into a URL-friendly "slug".
13
+ *
14
+ * @param {unknown} text The text to slugify
15
+ * @returns {string} The slugified string
16
+ */
17
+ declare const slugify: (text: unknown) => string;
18
+ /**
19
+ * Limit the number of characters in a string.
20
+ *
21
+ * @param {unknown} value The string to limit
22
+ * @param {number} size The maximum number of characters
23
+ * @returns {string} The limited string
24
+ */
25
+ declare const strLimit: (value: unknown, size: number) => string;
26
+ /**
27
+ * Normalize a string by trimming, lowercasing, and removing accents.
28
+ *
29
+ * @param {string | null | undefined} value The string to normalize
30
+ * @returns {string | null | undefined} The normalized string
31
+ */
32
+ declare const normalizeString: (value: string | null | undefined) => string | null | undefined;
33
+ /**
34
+ * Determine if a string contains all of the given values.
35
+ *
36
+ * @param {string} haystack The string to search in
37
+ * @param {string[]} needles The values to search for
38
+ * @returns {boolean} True if all values are found
39
+ */
40
+ declare const strContainsAll: (haystack: string, needles: string[]) => boolean;
41
+ /**
42
+ * Determine if a string contains any of the given values.
43
+ *
44
+ * @param {string} haystack The string to search in
45
+ * @param {string[]} needles The values to search for
46
+ * @returns {boolean} True if any value is found
47
+ */
48
+ declare const strContainsAny: (haystack: string, needles: string[]) => boolean;
49
+ /**
50
+ * Cap a string with a single instance of a given value.
51
+ *
52
+ * @param {string} value The source string
53
+ * @param {string} cap The value to append if not present
54
+ * @returns {string} The capped string
55
+ */
56
+ declare const strFinish: (value: string, cap: string) => string;
57
+ /**
58
+ * Begin a string with a single instance of a given value.
59
+ *
60
+ * @param {string} value The source string
61
+ * @param {string} prefix The value to prepend if not present
62
+ * @returns {string} The prefixed string
63
+ */
64
+ declare const strStart: (value: string, prefix: string) => string;
65
+ /**
66
+ * Pad both sides of a string with another.
67
+ *
68
+ * @param {string} str The source string
69
+ * @param {number} length The desired length
70
+ * @param {string} [pad=' '] The value to pad with
71
+ * @returns {string} The padded string
72
+ */
73
+ declare const strPadBoth: (str: string, length: number, pad?: string) => string;
74
+ /**
75
+ * Pad the left side of a string with another.
76
+ *
77
+ * @param {string} str The source string
78
+ * @param {number} length The desired length
79
+ * @param {string} [pad=' '] The value to pad with
80
+ * @returns {string} The padded string
81
+ */
82
+ declare const strPadLeft: (str: string, length: number, pad?: string) => string;
83
+ /**
84
+ * Pad the right side of a string with another.
85
+ *
86
+ * @param {string} str The source string
87
+ * @param {number} length The desired length
88
+ * @param {string} [pad=' '] The value to pad with
89
+ * @returns {string} The padded string
90
+ */
91
+ declare const strPadRight: (str: string, length: number, pad?: string) => string;
92
+ /**
93
+ * Reverse the given string.
94
+ *
95
+ * @param {string} value The string to reverse
96
+ * @returns {string} The reversed string
97
+ */
98
+ declare const strReverse: (value: string) => string;
99
+ /**
100
+ * Remove any occurrence of the given string in the subject.
101
+ *
102
+ * @param {string} search The string to remove
103
+ * @param {string} subject The source string
104
+ * @param {boolean} [caseSensitive=true] Whether to perform case-sensitive removal
105
+ * @returns {string} The resulting string
106
+ */
107
+ declare const strRemove: (search: string, subject: string, caseSensitive?: boolean) => string;
108
+ /**
109
+ * Mask a portion of a string with a repeated character.
110
+ *
111
+ * @param {string} str The source string
112
+ * @param {string} character The character to use for masking
113
+ * @param {number} index The starting index
114
+ * @param {number} [length] The number of characters to mask
115
+ * @returns {string} The masked string
116
+ */
117
+ declare const strMask: (str: string, character: string, index: number, length?: number) => string;
118
+ /**
119
+ * Count the number of words in a string.
120
+ *
121
+ * @param {string} str The string to count words in
122
+ * @param {string} [characters] Optional characters to treat as word boundaries
123
+ * @returns {number} The word count
124
+ */
125
+ declare const strWordCount: (str: string, characters?: string) => number;
126
+ /**
127
+ * Limit the number of words in a string.
128
+ *
129
+ * @param {string} value The string to limit
130
+ * @param {number} [words=100] The maximum number of words
131
+ * @param {string} [end='...'] The string to append if truncated
132
+ * @returns {string} The limited string
133
+ */
134
+ declare const strWords: (value: string, words?: number, end?: string) => string;
135
+ /**
136
+ * Convert a string to camelCase.
137
+ *
138
+ * @param {string} value The string to convert
139
+ * @returns {string} The camelCased string
140
+ */
141
+ declare const camelCase: (value: string) => string;
142
+ /**
143
+ * Convert a string to snake_case.
144
+ *
145
+ * @param {string} value The string to convert
146
+ * @returns {string} The snake_cased string
147
+ */
148
+ declare const snakeCase: (value: string) => string;
149
+ /**
150
+ * Convert a string to kebab-case.
151
+ *
152
+ * @param {string} value The string to convert
153
+ * @returns {string} The kebab-cased string
154
+ */
155
+ declare const kebabCase: (value: string) => string;
156
+ /**
157
+ * Convert a string to StudlyCase.
158
+ *
159
+ * @param {string} value The string to convert
160
+ * @returns {string} The studlyCased string
161
+ */
162
+ declare const studlyCase: (value: string) => string;
163
+ /**
164
+ * Convert a string to Title Case.
165
+ *
166
+ * @param {string} value The string to convert
167
+ * @returns {string} The titleCased string
168
+ */
169
+ declare const titleCase: (value: string) => string;
170
+ /**
171
+ * Format a number with grouped thousands and decimal point.
172
+ *
173
+ * @param {number} value The number to format
174
+ * @param {number} [decimals=2] The number of decimal points
175
+ * @param {string} [locale='en-US'] The locale to use for formatting
176
+ * @returns {string} The formatted number
177
+ */
178
+ declare const numberFormat: (value: number, decimals?: number, locale?: string) => string;
179
+
180
+ export { camelCase, capitalize, kebabCase, normalizeString, numberFormat, slugify, snakeCase, strContainsAll, strContainsAny, strFinish, strLimit, strMask, strPadBoth, strPadLeft, strPadRight, strRemove, strReverse, strStart, strWordCount, strWords, studlyCase, titleCase };
@@ -0,0 +1,48 @@
1
+ import {
2
+ camelCase,
3
+ capitalize,
4
+ kebabCase,
5
+ normalizeString,
6
+ numberFormat,
7
+ slugify,
8
+ snakeCase,
9
+ strContainsAll,
10
+ strContainsAny,
11
+ strFinish,
12
+ strLimit,
13
+ strMask,
14
+ strPadBoth,
15
+ strPadLeft,
16
+ strPadRight,
17
+ strRemove,
18
+ strReverse,
19
+ strStart,
20
+ strWordCount,
21
+ strWords,
22
+ studlyCase,
23
+ titleCase
24
+ } from "./chunk-F6RSTW65.js";
25
+ export {
26
+ camelCase,
27
+ capitalize,
28
+ kebabCase,
29
+ normalizeString,
30
+ numberFormat,
31
+ slugify,
32
+ snakeCase,
33
+ strContainsAll,
34
+ strContainsAny,
35
+ strFinish,
36
+ strLimit,
37
+ strMask,
38
+ strPadBoth,
39
+ strPadLeft,
40
+ strPadRight,
41
+ strRemove,
42
+ strReverse,
43
+ strStart,
44
+ strWordCount,
45
+ strWords,
46
+ studlyCase,
47
+ titleCase
48
+ };