@entrolytics/utilities 2.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Entrolytics
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,115 @@
1
+ # @entrolytics/utilities
2
+
3
+ Common utilities and helper functions for Entrolytics projects.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @entrolytics/utilities
9
+ # or
10
+ pnpm add @entrolytics/utilities
11
+ # or
12
+ yarn add @entrolytics/utilities
13
+ ```
14
+
15
+ ## Features
16
+
17
+ - ๐Ÿงต String utilities (truncate, capitalize, slugify, case conversion)
18
+ - ๐Ÿ“… Date utilities (formatting, ranges, comparisons)
19
+ - ๐Ÿ”— URL utilities (parsing, validation, building)
20
+ - ๐Ÿ” Hash utilities (simple hashing, ID generation)
21
+ - ๐Ÿ”„ Retry with exponential backoff
22
+ - โฑ๏ธ Debounce and throttle functions
23
+ - ๐Ÿ’พ Safe localStorage/sessionStorage wrappers
24
+ - ๐ŸŒฒ Tree-shakeable exports
25
+ - ๐Ÿ“ฆ Zero dependencies
26
+
27
+ ## Usage
28
+
29
+ ### String Utilities
30
+
31
+ ```typescript
32
+ import { truncate, slugify, toKebabCase } from '@entrolytics/utilities';
33
+
34
+ truncate('Long text here', 10); // 'Long te...'
35
+ slugify('Hello World!'); // 'hello-world'
36
+ toKebabCase('camelCaseString'); // 'camel-case-string'
37
+ ```
38
+
39
+ ### Date Utilities
40
+
41
+ ```typescript
42
+ import { getLastNDays, toDateString, addDays } from '@entrolytics/utilities';
43
+
44
+ const { startDate, endDate } = getLastNDays(7);
45
+ toDateString(new Date()); // '2025-12-26'
46
+ addDays(new Date(), 5); // Date 5 days from now
47
+ ```
48
+
49
+ ### URL Utilities
50
+
51
+ ```typescript
52
+ import { parseQueryParams, getDomain, combineUrl } from '@entrolytics/utilities';
53
+
54
+ parseQueryParams('https://example.com?foo=bar'); // { foo: 'bar' }
55
+ getDomain('https://example.com/path'); // 'example.com'
56
+ combineUrl('https://api.com', 'v1', 'users'); // 'https://api.com/v1/users'
57
+ ```
58
+
59
+ ### Retry with Backoff
60
+
61
+ ```typescript
62
+ import { retry } from '@entrolytics/utilities';
63
+
64
+ await retry(
65
+ async () => {
66
+ const response = await fetch('https://api.example.com/data');
67
+ return response.json();
68
+ },
69
+ {
70
+ maxAttempts: 3,
71
+ delayMs: 1000,
72
+ backoffMultiplier: 2,
73
+ onRetry: (error, attempt) => {
74
+ console.log(`Retry attempt ${attempt}:`, error.message);
75
+ },
76
+ }
77
+ );
78
+ ```
79
+
80
+ ### Debounce & Throttle
81
+
82
+ ```typescript
83
+ import { debounce, throttle } from '@entrolytics/utilities';
84
+
85
+ const debouncedSearch = debounce((query: string) => {
86
+ console.log('Searching for:', query);
87
+ }, 300);
88
+
89
+ const throttledScroll = throttle(() => {
90
+ console.log('Scrolling...');
91
+ }, 100);
92
+ ```
93
+
94
+ ### Storage Utilities
95
+
96
+ ```typescript
97
+ import { storage, sessionStorage } from '@entrolytics/utilities';
98
+
99
+ // localStorage
100
+ storage.set('user', { name: 'John', id: 123 });
101
+ const user = storage.get('user'); // { name: 'John', id: 123 }
102
+ storage.remove('user');
103
+
104
+ // sessionStorage
105
+ sessionStorage.set('tempData', { value: 42 });
106
+ const data = sessionStorage.get('tempData');
107
+ ```
108
+
109
+ ## API Reference
110
+
111
+ See [source code](./src) for full API documentation with TypeScript types.
112
+
113
+ ## License
114
+
115
+ MIT ยฉ Entrolytics
package/dist/index.cjs ADDED
@@ -0,0 +1,330 @@
1
+ 'use strict';
2
+
3
+ // src/string.ts
4
+ function truncate(str, maxLength, suffix = "...") {
5
+ if (str.length <= maxLength) return str;
6
+ return str.slice(0, maxLength - suffix.length) + suffix;
7
+ }
8
+ function capitalize(str) {
9
+ return str.charAt(0).toUpperCase() + str.slice(1).toLowerCase();
10
+ }
11
+ function toKebabCase(str) {
12
+ return str.replace(/([a-z])([A-Z])/g, "$1-$2").replace(/[\s_]+/g, "-").toLowerCase();
13
+ }
14
+ function toCamelCase(str) {
15
+ return str.toLowerCase().replace(/[^a-zA-Z0-9]+(.)/g, (_, chr) => chr.toUpperCase());
16
+ }
17
+ function toSnakeCase(str) {
18
+ return str.replace(/([a-z])([A-Z])/g, "$1_$2").replace(/[\s-]+/g, "_").toLowerCase();
19
+ }
20
+ function randomString(length) {
21
+ const chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
22
+ let result = "";
23
+ for (let i = 0; i < length; i++) {
24
+ result += chars.charAt(Math.floor(Math.random() * chars.length));
25
+ }
26
+ return result;
27
+ }
28
+ function slugify(str) {
29
+ return str.toLowerCase().trim().replace(/[^\w\s-]/g, "").replace(/[\s_-]+/g, "-").replace(/^-+|-+$/g, "");
30
+ }
31
+
32
+ // src/date.ts
33
+ function toISOString(date) {
34
+ return new Date(date).toISOString();
35
+ }
36
+ function toDateString(date) {
37
+ const d = new Date(date);
38
+ const year = d.getFullYear();
39
+ const month = String(d.getMonth() + 1).padStart(2, "0");
40
+ const day = String(d.getDate()).padStart(2, "0");
41
+ return `${year}-${month}-${day}`;
42
+ }
43
+ function getLastNDays(n) {
44
+ const endDate = /* @__PURE__ */ new Date();
45
+ const startDate = /* @__PURE__ */ new Date();
46
+ startDate.setDate(startDate.getDate() - n);
47
+ return { startDate, endDate };
48
+ }
49
+ function isToday(date) {
50
+ const d = new Date(date);
51
+ const today = /* @__PURE__ */ new Date();
52
+ return d.toDateString() === today.toDateString();
53
+ }
54
+ function addDays(date, days) {
55
+ const result = new Date(date);
56
+ result.setDate(result.getDate() + days);
57
+ return result;
58
+ }
59
+ function startOfDay(date) {
60
+ const result = new Date(date);
61
+ result.setHours(0, 0, 0, 0);
62
+ return result;
63
+ }
64
+ function endOfDay(date) {
65
+ const result = new Date(date);
66
+ result.setHours(23, 59, 59, 999);
67
+ return result;
68
+ }
69
+ function daysDifference(date1, date2) {
70
+ const oneDay = 24 * 60 * 60 * 1e3;
71
+ return Math.round(Math.abs((date1.getTime() - date2.getTime()) / oneDay));
72
+ }
73
+
74
+ // src/url.ts
75
+ function parseQueryParams(url) {
76
+ const params = {};
77
+ const urlObj = new URL(url);
78
+ urlObj.searchParams.forEach((value, key) => {
79
+ params[key] = value;
80
+ });
81
+ return params;
82
+ }
83
+ function buildQueryString(params) {
84
+ const searchParams = new URLSearchParams();
85
+ Object.entries(params).forEach(([key, value]) => {
86
+ if (value !== null && value !== void 0) {
87
+ searchParams.append(key, String(value));
88
+ }
89
+ });
90
+ return searchParams.toString();
91
+ }
92
+ function getDomain(url) {
93
+ try {
94
+ const urlObj = new URL(url);
95
+ return urlObj.hostname;
96
+ } catch {
97
+ return "";
98
+ }
99
+ }
100
+ function getPathname(url) {
101
+ try {
102
+ const urlObj = new URL(url);
103
+ return urlObj.pathname;
104
+ } catch {
105
+ return "";
106
+ }
107
+ }
108
+ function isValidUrl(url) {
109
+ try {
110
+ new URL(url);
111
+ return true;
112
+ } catch {
113
+ return false;
114
+ }
115
+ }
116
+ function combineUrl(base, ...paths) {
117
+ let url = base.replace(/\/+$/, "");
118
+ for (const path of paths) {
119
+ url += "/" + path.replace(/^\/+/, "");
120
+ }
121
+ return url;
122
+ }
123
+
124
+ // src/hash.ts
125
+ function simpleHash(str) {
126
+ let hash = 0;
127
+ for (let i = 0; i < str.length; i++) {
128
+ const char = str.charCodeAt(i);
129
+ hash = (hash << 5) - hash + char;
130
+ hash |= 0;
131
+ }
132
+ return Math.abs(hash);
133
+ }
134
+ function hashString(str) {
135
+ return simpleHash(str).toString(36);
136
+ }
137
+ function generateId(...values) {
138
+ const combined = values.join("|");
139
+ return hashString(combined);
140
+ }
141
+
142
+ // src/retry.ts
143
+ async function retry(fn, options = {}) {
144
+ const {
145
+ maxAttempts = 3,
146
+ delayMs = 1e3,
147
+ backoffMultiplier = 2,
148
+ maxDelayMs = 3e4,
149
+ onRetry
150
+ } = options;
151
+ let lastError;
152
+ for (let attempt = 1; attempt <= maxAttempts; attempt++) {
153
+ try {
154
+ return await fn();
155
+ } catch (error) {
156
+ lastError = error;
157
+ if (attempt === maxAttempts) {
158
+ throw lastError;
159
+ }
160
+ const delay = Math.min(delayMs * Math.pow(backoffMultiplier, attempt - 1), maxDelayMs);
161
+ if (onRetry) {
162
+ onRetry(lastError, attempt);
163
+ }
164
+ await new Promise((resolve) => setTimeout(resolve, delay));
165
+ }
166
+ }
167
+ throw lastError;
168
+ }
169
+
170
+ // src/debounce.ts
171
+ function debounce(func, waitMs) {
172
+ let timeoutId = null;
173
+ return function debounced(...args) {
174
+ if (timeoutId !== null) {
175
+ clearTimeout(timeoutId);
176
+ }
177
+ timeoutId = setTimeout(() => {
178
+ func(...args);
179
+ }, waitMs);
180
+ };
181
+ }
182
+
183
+ // src/throttle.ts
184
+ function throttle(func, limitMs) {
185
+ let inThrottle = false;
186
+ let lastArgs = null;
187
+ return function throttled(...args) {
188
+ if (!inThrottle) {
189
+ func(...args);
190
+ inThrottle = true;
191
+ setTimeout(() => {
192
+ inThrottle = false;
193
+ if (lastArgs !== null) {
194
+ throttled(...lastArgs);
195
+ lastArgs = null;
196
+ }
197
+ }, limitMs);
198
+ } else {
199
+ lastArgs = args;
200
+ }
201
+ };
202
+ }
203
+
204
+ // src/storage.ts
205
+ var storage = {
206
+ /**
207
+ * Get item from localStorage with JSON parsing
208
+ */
209
+ get(key, defaultValue) {
210
+ if (typeof window === "undefined") return defaultValue ?? null;
211
+ try {
212
+ const item = window.localStorage.getItem(key);
213
+ return item ? JSON.parse(item) : defaultValue ?? null;
214
+ } catch {
215
+ return defaultValue ?? null;
216
+ }
217
+ },
218
+ /**
219
+ * Set item in localStorage with JSON stringification
220
+ */
221
+ set(key, value) {
222
+ if (typeof window === "undefined") return;
223
+ try {
224
+ window.localStorage.setItem(key, JSON.stringify(value));
225
+ } catch (error) {
226
+ console.error("Failed to set localStorage item:", error);
227
+ }
228
+ },
229
+ /**
230
+ * Remove item from localStorage
231
+ */
232
+ remove(key) {
233
+ if (typeof window === "undefined") return;
234
+ try {
235
+ window.localStorage.removeItem(key);
236
+ } catch (error) {
237
+ console.error("Failed to remove localStorage item:", error);
238
+ }
239
+ },
240
+ /**
241
+ * Clear all localStorage
242
+ */
243
+ clear() {
244
+ if (typeof window === "undefined") return;
245
+ try {
246
+ window.localStorage.clear();
247
+ } catch (error) {
248
+ console.error("Failed to clear localStorage:", error);
249
+ }
250
+ }
251
+ };
252
+ var sessionStorage = {
253
+ /**
254
+ * Get item from sessionStorage with JSON parsing
255
+ */
256
+ get(key, defaultValue) {
257
+ if (typeof window === "undefined") return defaultValue ?? null;
258
+ try {
259
+ const item = window.sessionStorage.getItem(key);
260
+ return item ? JSON.parse(item) : defaultValue ?? null;
261
+ } catch {
262
+ return defaultValue ?? null;
263
+ }
264
+ },
265
+ /**
266
+ * Set item in sessionStorage with JSON stringification
267
+ */
268
+ set(key, value) {
269
+ if (typeof window === "undefined") return;
270
+ try {
271
+ window.sessionStorage.setItem(key, JSON.stringify(value));
272
+ } catch (error) {
273
+ console.error("Failed to set sessionStorage item:", error);
274
+ }
275
+ },
276
+ /**
277
+ * Remove item from sessionStorage
278
+ */
279
+ remove(key) {
280
+ if (typeof window === "undefined") return;
281
+ try {
282
+ window.sessionStorage.removeItem(key);
283
+ } catch (error) {
284
+ console.error("Failed to remove sessionStorage item:", error);
285
+ }
286
+ },
287
+ /**
288
+ * Clear all sessionStorage
289
+ */
290
+ clear() {
291
+ if (typeof window === "undefined") return;
292
+ try {
293
+ window.sessionStorage.clear();
294
+ } catch (error) {
295
+ console.error("Failed to clear sessionStorage:", error);
296
+ }
297
+ }
298
+ };
299
+
300
+ exports.addDays = addDays;
301
+ exports.buildQueryString = buildQueryString;
302
+ exports.capitalize = capitalize;
303
+ exports.combineUrl = combineUrl;
304
+ exports.daysDifference = daysDifference;
305
+ exports.debounce = debounce;
306
+ exports.endOfDay = endOfDay;
307
+ exports.generateId = generateId;
308
+ exports.getDomain = getDomain;
309
+ exports.getLastNDays = getLastNDays;
310
+ exports.getPathname = getPathname;
311
+ exports.hashString = hashString;
312
+ exports.isToday = isToday;
313
+ exports.isValidUrl = isValidUrl;
314
+ exports.parseQueryParams = parseQueryParams;
315
+ exports.randomString = randomString;
316
+ exports.retry = retry;
317
+ exports.sessionStorage = sessionStorage;
318
+ exports.simpleHash = simpleHash;
319
+ exports.slugify = slugify;
320
+ exports.startOfDay = startOfDay;
321
+ exports.storage = storage;
322
+ exports.throttle = throttle;
323
+ exports.toCamelCase = toCamelCase;
324
+ exports.toDateString = toDateString;
325
+ exports.toISOString = toISOString;
326
+ exports.toKebabCase = toKebabCase;
327
+ exports.toSnakeCase = toSnakeCase;
328
+ exports.truncate = truncate;
329
+ //# sourceMappingURL=index.cjs.map
330
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,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AW,GAAG,CAAA;AAAA,IACtC,SAAS,KAAA,EAAO;AACd,MAAA,OAAA,CAAQ,KAAA,CAAM,yCAAyC,KAAK,CAAA;AAAA,IAC9D;AAAA,EACF,CAAA;AAAA;AAAA;AAAA;AAAA,EAKA,KAAA,GAAc;AACZ,IAAA,IAAI,OAAO,WAAW,WAAA,EAAa;AAEnC,IAAA,IAAI;AACF,MAAA,MAAA,CAAO,eAAe,KAAA,EAAM;AAAA,IAC9B,SAAS,KAAA,EAAO;AACd,MAAA,OAAA,CAAQ,KAAA,CAAM,mCAAmC,KAAK,CAAA;AAAA,IACxD;AAAA,EACF;AACF","file":"index.cjs","sourcesContent":["/**\n * String utility functions\n */\n\n/**\n * Truncate a string to a maximum length\n */\nexport function truncate(str: string, maxLength: number, suffix = '...'): string {\n if (str.length <= maxLength) return str;\n return str.slice(0, maxLength - suffix.length) + suffix;\n}\n\n/**\n * Capitalize the first letter of a string\n */\nexport function capitalize(str: string): string {\n return str.charAt(0).toUpperCase() + str.slice(1).toLowerCase();\n}\n\n/**\n * Convert string to kebab-case\n */\nexport function toKebabCase(str: string): string {\n return str\n .replace(/([a-z])([A-Z])/g, '$1-$2')\n .replace(/[\\s_]+/g, '-')\n .toLowerCase();\n}\n\n/**\n * Convert string to camelCase\n */\nexport function toCamelCase(str: string): string {\n return str\n .toLowerCase()\n .replace(/[^a-zA-Z0-9]+(.)/g, (_, chr) => chr.toUpperCase());\n}\n\n/**\n * Convert string to snake_case\n */\nexport function toSnakeCase(str: string): string {\n return str\n .replace(/([a-z])([A-Z])/g, '$1_$2')\n .replace(/[\\s-]+/g, '_')\n .toLowerCase();\n}\n\n/**\n * Generate a random alphanumeric string\n */\nexport function randomString(length: number): string {\n const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';\n let result = '';\n for (let i = 0; i < length; i++) {\n result += chars.charAt(Math.floor(Math.random() * chars.length));\n }\n return result;\n}\n\n/**\n * Slugify a string for URLs\n */\nexport function slugify(str: string): string {\n return str\n .toLowerCase()\n .trim()\n .replace(/[^\\w\\s-]/g, '')\n .replace(/[\\s_-]+/g, '-')\n .replace(/^-+|-+$/g, '');\n}\n","/**\n * Date utility functions\n */\n\n/**\n * Format date to ISO string\n */\nexport function toISOString(date: Date | string | number): string {\n return new Date(date).toISOString();\n}\n\n/**\n * Format date to YYYY-MM-DD\n */\nexport function toDateString(date: Date | string | number): string {\n const d = new Date(date);\n const year = d.getFullYear();\n const month = String(d.getMonth() + 1).padStart(2, '0');\n const day = String(d.getDate()).padStart(2, '0');\n return `${year}-${month}-${day}`;\n}\n\n/**\n * Get date range for the last N days\n */\nexport function getLastNDays(n: number): { startDate: Date; endDate: Date } {\n const endDate = new Date();\n const startDate = new Date();\n startDate.setDate(startDate.getDate() - n);\n return { startDate, endDate };\n}\n\n/**\n * Check if a date is today\n */\nexport function isToday(date: Date | string | number): boolean {\n const d = new Date(date);\n const today = new Date();\n return d.toDateString() === today.toDateString();\n}\n\n/**\n * Add days to a date\n */\nexport function addDays(date: Date, days: number): Date {\n const result = new Date(date);\n result.setDate(result.getDate() + days);\n return result;\n}\n\n/**\n * Get start of day\n */\nexport function startOfDay(date: Date): Date {\n const result = new Date(date);\n result.setHours(0, 0, 0, 0);\n return result;\n}\n\n/**\n * Get end of day\n */\nexport function endOfDay(date: Date): Date {\n const result = new Date(date);\n result.setHours(23, 59, 59, 999);\n return result;\n}\n\n/**\n * Get difference in days between two dates\n */\nexport function daysDifference(date1: Date, date2: Date): number {\n const oneDay = 24 * 60 * 60 * 1000;\n return Math.round(Math.abs((date1.getTime() - date2.getTime()) / oneDay));\n}\n","/**\n * URL utility functions\n */\n\n/**\n * Parse query parameters from URL\n */\nexport function parseQueryParams(url: string): Record<string, string> {\n const params: Record<string, string> = {};\n const urlObj = new URL(url);\n urlObj.searchParams.forEach((value, key) => {\n params[key] = value;\n });\n return params;\n}\n\n/**\n * Build query string from object\n */\nexport function buildQueryString(params: Record<string, unknown>): string {\n const searchParams = new URLSearchParams();\n Object.entries(params).forEach(([key, value]) => {\n if (value !== null && value !== undefined) {\n searchParams.append(key, String(value));\n }\n });\n return searchParams.toString();\n}\n\n/**\n * Get domain from URL\n */\nexport function getDomain(url: string): string {\n try {\n const urlObj = new URL(url);\n return urlObj.hostname;\n } catch {\n return '';\n }\n}\n\n/**\n * Get pathname from URL\n */\nexport function getPathname(url: string): string {\n try {\n const urlObj = new URL(url);\n return urlObj.pathname;\n } catch {\n return '';\n }\n}\n\n/**\n * Validate URL\n */\nexport function isValidUrl(url: string): boolean {\n try {\n new URL(url);\n return true;\n } catch {\n return false;\n }\n}\n\n/**\n * Combine URL parts\n */\nexport function combineUrl(base: string, ...paths: string[]): string {\n let url = base.replace(/\\/+$/, '');\n for (const path of paths) {\n url += '/' + path.replace(/^\\/+/, '');\n }\n return url;\n}\n","/**\n * Hashing utility functions\n */\n\n/**\n * Simple hash function for strings (non-cryptographic)\n */\nexport function simpleHash(str: string): number {\n let hash = 0;\n for (let i = 0; i < str.length; i++) {\n const char = str.charCodeAt(i);\n hash = (hash << 5) - hash + char;\n hash |= 0; // Convert to 32bit integer\n }\n return Math.abs(hash);\n}\n\n/**\n * Generate a simple hash string from input\n */\nexport function hashString(str: string): string {\n return simpleHash(str).toString(36);\n}\n\n/**\n * Generate a deterministic ID from multiple values\n */\nexport function generateId(...values: (string | number)[]): string {\n const combined = values.join('|');\n return hashString(combined);\n}\n","/**\n * Retry utility with exponential backoff\n */\n\nexport interface RetryOptions {\n maxAttempts?: number;\n delayMs?: number;\n backoffMultiplier?: number;\n maxDelayMs?: number;\n onRetry?: (error: Error, attempt: number) => void;\n}\n\n/**\n * Retry a function with exponential backoff\n */\nexport async function retry<T>(\n fn: () => Promise<T>,\n options: RetryOptions = {}\n): Promise<T> {\n const {\n maxAttempts = 3,\n delayMs = 1000,\n backoffMultiplier = 2,\n maxDelayMs = 30000,\n onRetry,\n } = options;\n\n let lastError: Error;\n\n for (let attempt = 1; attempt <= maxAttempts; attempt++) {\n try {\n return await fn();\n } catch (error) {\n lastError = error as Error;\n\n if (attempt === maxAttempts) {\n throw lastError;\n }\n\n const delay = Math.min(delayMs * Math.pow(backoffMultiplier, attempt - 1), maxDelayMs);\n\n if (onRetry) {\n onRetry(lastError, attempt);\n }\n\n await new Promise(resolve => setTimeout(resolve, delay));\n }\n }\n\n throw lastError!;\n}\n","/**\n * Debounce utility\n */\n\n// biome-ignore lint: any is needed for generic function signature\nexport function debounce<T extends (...args: any[]) => any>(\n func: T,\n waitMs: number\n): (...args: Parameters<T>) => void {\n let timeoutId: ReturnType<typeof setTimeout> | null = null;\n\n return function debounced(...args: Parameters<T>) {\n if (timeoutId !== null) {\n clearTimeout(timeoutId);\n }\n\n timeoutId = setTimeout(() => {\n func(...args);\n }, waitMs);\n };\n}\n","/**\n * Throttle utility\n */\n\n// biome-ignore lint: any is needed for generic function signature\nexport function throttle<T extends (...args: any[]) => any>(\n func: T,\n limitMs: number\n): (...args: Parameters<T>) => void {\n let inThrottle = false;\n let lastArgs: Parameters<T> | null = null;\n\n return function throttled(...args: Parameters<T>) {\n if (!inThrottle) {\n func(...args);\n inThrottle = true;\n\n setTimeout(() => {\n inThrottle = false;\n if (lastArgs !== null) {\n throttled(...lastArgs);\n lastArgs = null;\n }\n }, limitMs);\n } else {\n lastArgs = args;\n }\n };\n}\n","/**\n * Storage utility functions for browser localStorage/sessionStorage\n */\n\n/**\n * Safe localStorage wrapper\n */\nexport const storage = {\n /**\n * Get item from localStorage with JSON parsing\n */\n get<T>(key: string, defaultValue?: T): T | null {\n if (typeof window === 'undefined') return defaultValue ?? null;\n\n try {\n const item = window.localStorage.getItem(key);\n return item ? JSON.parse(item) : (defaultValue ?? null);\n } catch {\n return defaultValue ?? null;\n }\n },\n\n /**\n * Set item in localStorage with JSON stringification\n */\n set<T>(key: string, value: T): void {\n if (typeof window === 'undefined') return;\n\n try {\n window.localStorage.setItem(key, JSON.stringify(value));\n } catch (error) {\n console.error('Failed to set localStorage item:', error);\n }\n },\n\n /**\n * Remove item from localStorage\n */\n remove(key: string): void {\n if (typeof window === 'undefined') return;\n\n try {\n window.localStorage.removeItem(key);\n } catch (error) {\n console.error('Failed to remove localStorage item:', error);\n }\n },\n\n /**\n * Clear all localStorage\n */\n clear(): void {\n if (typeof window === 'undefined') return;\n\n try {\n window.localStorage.clear();\n } catch (error) {\n console.error('Failed to clear localStorage:', error);\n }\n },\n};\n\n/**\n * Safe sessionStorage wrapper\n */\nexport const sessionStorage = {\n /**\n * Get item from sessionStorage with JSON parsing\n */\n get<T>(key: string, defaultValue?: T): T | null {\n if (typeof window === 'undefined') return defaultValue ?? null;\n\n try {\n const item = window.sessionStorage.getItem(key);\n return item ? JSON.parse(item) : (defaultValue ?? null);\n } catch {\n return defaultValue ?? null;\n }\n },\n\n /**\n * Set item in sessionStorage with JSON stringification\n */\n set<T>(key: string, value: T): void {\n if (typeof window === 'undefined') return;\n\n try {\n window.sessionStorage.setItem(key, JSON.stringify(value));\n } catch (error) {\n console.error('Failed to set sessionStorage item:', error);\n }\n },\n\n /**\n * Remove item from sessionStorage\n */\n remove(key: string): void {\n if (typeof window === 'undefined') return;\n\n try {\n window.sessionStorage.removeItem(key);\n } catch (error) {\n console.error('Failed to remove sessionStorage item:', error);\n }\n },\n\n /**\n * Clear all sessionStorage\n */\n clear(): void {\n if (typeof window === 'undefined') return;\n\n try {\n window.sessionStorage.clear();\n } catch (error) {\n console.error('Failed to clear sessionStorage:', error);\n }\n },\n};\n"]}
@@ -0,0 +1,187 @@
1
+ /**
2
+ * String utility functions
3
+ */
4
+ /**
5
+ * Truncate a string to a maximum length
6
+ */
7
+ declare function truncate(str: string, maxLength: number, suffix?: string): string;
8
+ /**
9
+ * Capitalize the first letter of a string
10
+ */
11
+ declare function capitalize(str: string): string;
12
+ /**
13
+ * Convert string to kebab-case
14
+ */
15
+ declare function toKebabCase(str: string): string;
16
+ /**
17
+ * Convert string to camelCase
18
+ */
19
+ declare function toCamelCase(str: string): string;
20
+ /**
21
+ * Convert string to snake_case
22
+ */
23
+ declare function toSnakeCase(str: string): string;
24
+ /**
25
+ * Generate a random alphanumeric string
26
+ */
27
+ declare function randomString(length: number): string;
28
+ /**
29
+ * Slugify a string for URLs
30
+ */
31
+ declare function slugify(str: string): string;
32
+
33
+ /**
34
+ * Date utility functions
35
+ */
36
+ /**
37
+ * Format date to ISO string
38
+ */
39
+ declare function toISOString(date: Date | string | number): string;
40
+ /**
41
+ * Format date to YYYY-MM-DD
42
+ */
43
+ declare function toDateString(date: Date | string | number): string;
44
+ /**
45
+ * Get date range for the last N days
46
+ */
47
+ declare function getLastNDays(n: number): {
48
+ startDate: Date;
49
+ endDate: Date;
50
+ };
51
+ /**
52
+ * Check if a date is today
53
+ */
54
+ declare function isToday(date: Date | string | number): boolean;
55
+ /**
56
+ * Add days to a date
57
+ */
58
+ declare function addDays(date: Date, days: number): Date;
59
+ /**
60
+ * Get start of day
61
+ */
62
+ declare function startOfDay(date: Date): Date;
63
+ /**
64
+ * Get end of day
65
+ */
66
+ declare function endOfDay(date: Date): Date;
67
+ /**
68
+ * Get difference in days between two dates
69
+ */
70
+ declare function daysDifference(date1: Date, date2: Date): number;
71
+
72
+ /**
73
+ * URL utility functions
74
+ */
75
+ /**
76
+ * Parse query parameters from URL
77
+ */
78
+ declare function parseQueryParams(url: string): Record<string, string>;
79
+ /**
80
+ * Build query string from object
81
+ */
82
+ declare function buildQueryString(params: Record<string, unknown>): string;
83
+ /**
84
+ * Get domain from URL
85
+ */
86
+ declare function getDomain(url: string): string;
87
+ /**
88
+ * Get pathname from URL
89
+ */
90
+ declare function getPathname(url: string): string;
91
+ /**
92
+ * Validate URL
93
+ */
94
+ declare function isValidUrl(url: string): boolean;
95
+ /**
96
+ * Combine URL parts
97
+ */
98
+ declare function combineUrl(base: string, ...paths: string[]): string;
99
+
100
+ /**
101
+ * Hashing utility functions
102
+ */
103
+ /**
104
+ * Simple hash function for strings (non-cryptographic)
105
+ */
106
+ declare function simpleHash(str: string): number;
107
+ /**
108
+ * Generate a simple hash string from input
109
+ */
110
+ declare function hashString(str: string): string;
111
+ /**
112
+ * Generate a deterministic ID from multiple values
113
+ */
114
+ declare function generateId(...values: (string | number)[]): string;
115
+
116
+ /**
117
+ * Retry utility with exponential backoff
118
+ */
119
+ interface RetryOptions {
120
+ maxAttempts?: number;
121
+ delayMs?: number;
122
+ backoffMultiplier?: number;
123
+ maxDelayMs?: number;
124
+ onRetry?: (error: Error, attempt: number) => void;
125
+ }
126
+ /**
127
+ * Retry a function with exponential backoff
128
+ */
129
+ declare function retry<T>(fn: () => Promise<T>, options?: RetryOptions): Promise<T>;
130
+
131
+ /**
132
+ * Debounce utility
133
+ */
134
+ declare function debounce<T extends (...args: any[]) => any>(func: T, waitMs: number): (...args: Parameters<T>) => void;
135
+
136
+ /**
137
+ * Throttle utility
138
+ */
139
+ declare function throttle<T extends (...args: any[]) => any>(func: T, limitMs: number): (...args: Parameters<T>) => void;
140
+
141
+ /**
142
+ * Storage utility functions for browser localStorage/sessionStorage
143
+ */
144
+ /**
145
+ * Safe localStorage wrapper
146
+ */
147
+ declare const storage: {
148
+ /**
149
+ * Get item from localStorage with JSON parsing
150
+ */
151
+ get<T>(key: string, defaultValue?: T): T | null;
152
+ /**
153
+ * Set item in localStorage with JSON stringification
154
+ */
155
+ set<T>(key: string, value: T): void;
156
+ /**
157
+ * Remove item from localStorage
158
+ */
159
+ remove(key: string): void;
160
+ /**
161
+ * Clear all localStorage
162
+ */
163
+ clear(): void;
164
+ };
165
+ /**
166
+ * Safe sessionStorage wrapper
167
+ */
168
+ declare const sessionStorage: {
169
+ /**
170
+ * Get item from sessionStorage with JSON parsing
171
+ */
172
+ get<T>(key: string, defaultValue?: T): T | null;
173
+ /**
174
+ * Set item in sessionStorage with JSON stringification
175
+ */
176
+ set<T>(key: string, value: T): void;
177
+ /**
178
+ * Remove item from sessionStorage
179
+ */
180
+ remove(key: string): void;
181
+ /**
182
+ * Clear all sessionStorage
183
+ */
184
+ clear(): void;
185
+ };
186
+
187
+ export { type RetryOptions, addDays, buildQueryString, capitalize, combineUrl, daysDifference, debounce, endOfDay, generateId, getDomain, getLastNDays, getPathname, hashString, isToday, isValidUrl, parseQueryParams, randomString, retry, sessionStorage, simpleHash, slugify, startOfDay, storage, throttle, toCamelCase, toDateString, toISOString, toKebabCase, toSnakeCase, truncate };
@@ -0,0 +1,187 @@
1
+ /**
2
+ * String utility functions
3
+ */
4
+ /**
5
+ * Truncate a string to a maximum length
6
+ */
7
+ declare function truncate(str: string, maxLength: number, suffix?: string): string;
8
+ /**
9
+ * Capitalize the first letter of a string
10
+ */
11
+ declare function capitalize(str: string): string;
12
+ /**
13
+ * Convert string to kebab-case
14
+ */
15
+ declare function toKebabCase(str: string): string;
16
+ /**
17
+ * Convert string to camelCase
18
+ */
19
+ declare function toCamelCase(str: string): string;
20
+ /**
21
+ * Convert string to snake_case
22
+ */
23
+ declare function toSnakeCase(str: string): string;
24
+ /**
25
+ * Generate a random alphanumeric string
26
+ */
27
+ declare function randomString(length: number): string;
28
+ /**
29
+ * Slugify a string for URLs
30
+ */
31
+ declare function slugify(str: string): string;
32
+
33
+ /**
34
+ * Date utility functions
35
+ */
36
+ /**
37
+ * Format date to ISO string
38
+ */
39
+ declare function toISOString(date: Date | string | number): string;
40
+ /**
41
+ * Format date to YYYY-MM-DD
42
+ */
43
+ declare function toDateString(date: Date | string | number): string;
44
+ /**
45
+ * Get date range for the last N days
46
+ */
47
+ declare function getLastNDays(n: number): {
48
+ startDate: Date;
49
+ endDate: Date;
50
+ };
51
+ /**
52
+ * Check if a date is today
53
+ */
54
+ declare function isToday(date: Date | string | number): boolean;
55
+ /**
56
+ * Add days to a date
57
+ */
58
+ declare function addDays(date: Date, days: number): Date;
59
+ /**
60
+ * Get start of day
61
+ */
62
+ declare function startOfDay(date: Date): Date;
63
+ /**
64
+ * Get end of day
65
+ */
66
+ declare function endOfDay(date: Date): Date;
67
+ /**
68
+ * Get difference in days between two dates
69
+ */
70
+ declare function daysDifference(date1: Date, date2: Date): number;
71
+
72
+ /**
73
+ * URL utility functions
74
+ */
75
+ /**
76
+ * Parse query parameters from URL
77
+ */
78
+ declare function parseQueryParams(url: string): Record<string, string>;
79
+ /**
80
+ * Build query string from object
81
+ */
82
+ declare function buildQueryString(params: Record<string, unknown>): string;
83
+ /**
84
+ * Get domain from URL
85
+ */
86
+ declare function getDomain(url: string): string;
87
+ /**
88
+ * Get pathname from URL
89
+ */
90
+ declare function getPathname(url: string): string;
91
+ /**
92
+ * Validate URL
93
+ */
94
+ declare function isValidUrl(url: string): boolean;
95
+ /**
96
+ * Combine URL parts
97
+ */
98
+ declare function combineUrl(base: string, ...paths: string[]): string;
99
+
100
+ /**
101
+ * Hashing utility functions
102
+ */
103
+ /**
104
+ * Simple hash function for strings (non-cryptographic)
105
+ */
106
+ declare function simpleHash(str: string): number;
107
+ /**
108
+ * Generate a simple hash string from input
109
+ */
110
+ declare function hashString(str: string): string;
111
+ /**
112
+ * Generate a deterministic ID from multiple values
113
+ */
114
+ declare function generateId(...values: (string | number)[]): string;
115
+
116
+ /**
117
+ * Retry utility with exponential backoff
118
+ */
119
+ interface RetryOptions {
120
+ maxAttempts?: number;
121
+ delayMs?: number;
122
+ backoffMultiplier?: number;
123
+ maxDelayMs?: number;
124
+ onRetry?: (error: Error, attempt: number) => void;
125
+ }
126
+ /**
127
+ * Retry a function with exponential backoff
128
+ */
129
+ declare function retry<T>(fn: () => Promise<T>, options?: RetryOptions): Promise<T>;
130
+
131
+ /**
132
+ * Debounce utility
133
+ */
134
+ declare function debounce<T extends (...args: any[]) => any>(func: T, waitMs: number): (...args: Parameters<T>) => void;
135
+
136
+ /**
137
+ * Throttle utility
138
+ */
139
+ declare function throttle<T extends (...args: any[]) => any>(func: T, limitMs: number): (...args: Parameters<T>) => void;
140
+
141
+ /**
142
+ * Storage utility functions for browser localStorage/sessionStorage
143
+ */
144
+ /**
145
+ * Safe localStorage wrapper
146
+ */
147
+ declare const storage: {
148
+ /**
149
+ * Get item from localStorage with JSON parsing
150
+ */
151
+ get<T>(key: string, defaultValue?: T): T | null;
152
+ /**
153
+ * Set item in localStorage with JSON stringification
154
+ */
155
+ set<T>(key: string, value: T): void;
156
+ /**
157
+ * Remove item from localStorage
158
+ */
159
+ remove(key: string): void;
160
+ /**
161
+ * Clear all localStorage
162
+ */
163
+ clear(): void;
164
+ };
165
+ /**
166
+ * Safe sessionStorage wrapper
167
+ */
168
+ declare const sessionStorage: {
169
+ /**
170
+ * Get item from sessionStorage with JSON parsing
171
+ */
172
+ get<T>(key: string, defaultValue?: T): T | null;
173
+ /**
174
+ * Set item in sessionStorage with JSON stringification
175
+ */
176
+ set<T>(key: string, value: T): void;
177
+ /**
178
+ * Remove item from sessionStorage
179
+ */
180
+ remove(key: string): void;
181
+ /**
182
+ * Clear all sessionStorage
183
+ */
184
+ clear(): void;
185
+ };
186
+
187
+ export { type RetryOptions, addDays, buildQueryString, capitalize, combineUrl, daysDifference, debounce, endOfDay, generateId, getDomain, getLastNDays, getPathname, hashString, isToday, isValidUrl, parseQueryParams, randomString, retry, sessionStorage, simpleHash, slugify, startOfDay, storage, throttle, toCamelCase, toDateString, toISOString, toKebabCase, toSnakeCase, truncate };
package/dist/index.js ADDED
@@ -0,0 +1,300 @@
1
+ // src/string.ts
2
+ function truncate(str, maxLength, suffix = "...") {
3
+ if (str.length <= maxLength) return str;
4
+ return str.slice(0, maxLength - suffix.length) + suffix;
5
+ }
6
+ function capitalize(str) {
7
+ return str.charAt(0).toUpperCase() + str.slice(1).toLowerCase();
8
+ }
9
+ function toKebabCase(str) {
10
+ return str.replace(/([a-z])([A-Z])/g, "$1-$2").replace(/[\s_]+/g, "-").toLowerCase();
11
+ }
12
+ function toCamelCase(str) {
13
+ return str.toLowerCase().replace(/[^a-zA-Z0-9]+(.)/g, (_, chr) => chr.toUpperCase());
14
+ }
15
+ function toSnakeCase(str) {
16
+ return str.replace(/([a-z])([A-Z])/g, "$1_$2").replace(/[\s-]+/g, "_").toLowerCase();
17
+ }
18
+ function randomString(length) {
19
+ const chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
20
+ let result = "";
21
+ for (let i = 0; i < length; i++) {
22
+ result += chars.charAt(Math.floor(Math.random() * chars.length));
23
+ }
24
+ return result;
25
+ }
26
+ function slugify(str) {
27
+ return str.toLowerCase().trim().replace(/[^\w\s-]/g, "").replace(/[\s_-]+/g, "-").replace(/^-+|-+$/g, "");
28
+ }
29
+
30
+ // src/date.ts
31
+ function toISOString(date) {
32
+ return new Date(date).toISOString();
33
+ }
34
+ function toDateString(date) {
35
+ const d = new Date(date);
36
+ const year = d.getFullYear();
37
+ const month = String(d.getMonth() + 1).padStart(2, "0");
38
+ const day = String(d.getDate()).padStart(2, "0");
39
+ return `${year}-${month}-${day}`;
40
+ }
41
+ function getLastNDays(n) {
42
+ const endDate = /* @__PURE__ */ new Date();
43
+ const startDate = /* @__PURE__ */ new Date();
44
+ startDate.setDate(startDate.getDate() - n);
45
+ return { startDate, endDate };
46
+ }
47
+ function isToday(date) {
48
+ const d = new Date(date);
49
+ const today = /* @__PURE__ */ new Date();
50
+ return d.toDateString() === today.toDateString();
51
+ }
52
+ function addDays(date, days) {
53
+ const result = new Date(date);
54
+ result.setDate(result.getDate() + days);
55
+ return result;
56
+ }
57
+ function startOfDay(date) {
58
+ const result = new Date(date);
59
+ result.setHours(0, 0, 0, 0);
60
+ return result;
61
+ }
62
+ function endOfDay(date) {
63
+ const result = new Date(date);
64
+ result.setHours(23, 59, 59, 999);
65
+ return result;
66
+ }
67
+ function daysDifference(date1, date2) {
68
+ const oneDay = 24 * 60 * 60 * 1e3;
69
+ return Math.round(Math.abs((date1.getTime() - date2.getTime()) / oneDay));
70
+ }
71
+
72
+ // src/url.ts
73
+ function parseQueryParams(url) {
74
+ const params = {};
75
+ const urlObj = new URL(url);
76
+ urlObj.searchParams.forEach((value, key) => {
77
+ params[key] = value;
78
+ });
79
+ return params;
80
+ }
81
+ function buildQueryString(params) {
82
+ const searchParams = new URLSearchParams();
83
+ Object.entries(params).forEach(([key, value]) => {
84
+ if (value !== null && value !== void 0) {
85
+ searchParams.append(key, String(value));
86
+ }
87
+ });
88
+ return searchParams.toString();
89
+ }
90
+ function getDomain(url) {
91
+ try {
92
+ const urlObj = new URL(url);
93
+ return urlObj.hostname;
94
+ } catch {
95
+ return "";
96
+ }
97
+ }
98
+ function getPathname(url) {
99
+ try {
100
+ const urlObj = new URL(url);
101
+ return urlObj.pathname;
102
+ } catch {
103
+ return "";
104
+ }
105
+ }
106
+ function isValidUrl(url) {
107
+ try {
108
+ new URL(url);
109
+ return true;
110
+ } catch {
111
+ return false;
112
+ }
113
+ }
114
+ function combineUrl(base, ...paths) {
115
+ let url = base.replace(/\/+$/, "");
116
+ for (const path of paths) {
117
+ url += "/" + path.replace(/^\/+/, "");
118
+ }
119
+ return url;
120
+ }
121
+
122
+ // src/hash.ts
123
+ function simpleHash(str) {
124
+ let hash = 0;
125
+ for (let i = 0; i < str.length; i++) {
126
+ const char = str.charCodeAt(i);
127
+ hash = (hash << 5) - hash + char;
128
+ hash |= 0;
129
+ }
130
+ return Math.abs(hash);
131
+ }
132
+ function hashString(str) {
133
+ return simpleHash(str).toString(36);
134
+ }
135
+ function generateId(...values) {
136
+ const combined = values.join("|");
137
+ return hashString(combined);
138
+ }
139
+
140
+ // src/retry.ts
141
+ async function retry(fn, options = {}) {
142
+ const {
143
+ maxAttempts = 3,
144
+ delayMs = 1e3,
145
+ backoffMultiplier = 2,
146
+ maxDelayMs = 3e4,
147
+ onRetry
148
+ } = options;
149
+ let lastError;
150
+ for (let attempt = 1; attempt <= maxAttempts; attempt++) {
151
+ try {
152
+ return await fn();
153
+ } catch (error) {
154
+ lastError = error;
155
+ if (attempt === maxAttempts) {
156
+ throw lastError;
157
+ }
158
+ const delay = Math.min(delayMs * Math.pow(backoffMultiplier, attempt - 1), maxDelayMs);
159
+ if (onRetry) {
160
+ onRetry(lastError, attempt);
161
+ }
162
+ await new Promise((resolve) => setTimeout(resolve, delay));
163
+ }
164
+ }
165
+ throw lastError;
166
+ }
167
+
168
+ // src/debounce.ts
169
+ function debounce(func, waitMs) {
170
+ let timeoutId = null;
171
+ return function debounced(...args) {
172
+ if (timeoutId !== null) {
173
+ clearTimeout(timeoutId);
174
+ }
175
+ timeoutId = setTimeout(() => {
176
+ func(...args);
177
+ }, waitMs);
178
+ };
179
+ }
180
+
181
+ // src/throttle.ts
182
+ function throttle(func, limitMs) {
183
+ let inThrottle = false;
184
+ let lastArgs = null;
185
+ return function throttled(...args) {
186
+ if (!inThrottle) {
187
+ func(...args);
188
+ inThrottle = true;
189
+ setTimeout(() => {
190
+ inThrottle = false;
191
+ if (lastArgs !== null) {
192
+ throttled(...lastArgs);
193
+ lastArgs = null;
194
+ }
195
+ }, limitMs);
196
+ } else {
197
+ lastArgs = args;
198
+ }
199
+ };
200
+ }
201
+
202
+ // src/storage.ts
203
+ var storage = {
204
+ /**
205
+ * Get item from localStorage with JSON parsing
206
+ */
207
+ get(key, defaultValue) {
208
+ if (typeof window === "undefined") return defaultValue ?? null;
209
+ try {
210
+ const item = window.localStorage.getItem(key);
211
+ return item ? JSON.parse(item) : defaultValue ?? null;
212
+ } catch {
213
+ return defaultValue ?? null;
214
+ }
215
+ },
216
+ /**
217
+ * Set item in localStorage with JSON stringification
218
+ */
219
+ set(key, value) {
220
+ if (typeof window === "undefined") return;
221
+ try {
222
+ window.localStorage.setItem(key, JSON.stringify(value));
223
+ } catch (error) {
224
+ console.error("Failed to set localStorage item:", error);
225
+ }
226
+ },
227
+ /**
228
+ * Remove item from localStorage
229
+ */
230
+ remove(key) {
231
+ if (typeof window === "undefined") return;
232
+ try {
233
+ window.localStorage.removeItem(key);
234
+ } catch (error) {
235
+ console.error("Failed to remove localStorage item:", error);
236
+ }
237
+ },
238
+ /**
239
+ * Clear all localStorage
240
+ */
241
+ clear() {
242
+ if (typeof window === "undefined") return;
243
+ try {
244
+ window.localStorage.clear();
245
+ } catch (error) {
246
+ console.error("Failed to clear localStorage:", error);
247
+ }
248
+ }
249
+ };
250
+ var sessionStorage = {
251
+ /**
252
+ * Get item from sessionStorage with JSON parsing
253
+ */
254
+ get(key, defaultValue) {
255
+ if (typeof window === "undefined") return defaultValue ?? null;
256
+ try {
257
+ const item = window.sessionStorage.getItem(key);
258
+ return item ? JSON.parse(item) : defaultValue ?? null;
259
+ } catch {
260
+ return defaultValue ?? null;
261
+ }
262
+ },
263
+ /**
264
+ * Set item in sessionStorage with JSON stringification
265
+ */
266
+ set(key, value) {
267
+ if (typeof window === "undefined") return;
268
+ try {
269
+ window.sessionStorage.setItem(key, JSON.stringify(value));
270
+ } catch (error) {
271
+ console.error("Failed to set sessionStorage item:", error);
272
+ }
273
+ },
274
+ /**
275
+ * Remove item from sessionStorage
276
+ */
277
+ remove(key) {
278
+ if (typeof window === "undefined") return;
279
+ try {
280
+ window.sessionStorage.removeItem(key);
281
+ } catch (error) {
282
+ console.error("Failed to remove sessionStorage item:", error);
283
+ }
284
+ },
285
+ /**
286
+ * Clear all sessionStorage
287
+ */
288
+ clear() {
289
+ if (typeof window === "undefined") return;
290
+ try {
291
+ window.sessionStorage.clear();
292
+ } catch (error) {
293
+ console.error("Failed to clear sessionStorage:", error);
294
+ }
295
+ }
296
+ };
297
+
298
+ export { addDays, buildQueryString, capitalize, combineUrl, daysDifference, debounce, endOfDay, generateId, getDomain, getLastNDays, getPathname, hashString, isToday, isValidUrl, parseQueryParams, randomString, retry, sessionStorage, simpleHash, slugify, startOfDay, storage, throttle, toCamelCase, toDateString, toISOString, toKebabCase, toSnakeCase, truncate };
299
+ //# sourceMappingURL=index.js.map
300
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/string.ts","../src/date.ts","../src/url.ts","../src/hash.ts","../src/retry.ts","../src/debounce.ts","../src/throttle.ts","../src/storage.ts"],"names":[],"mappings":";AAOO,SAAS,QAAA,CAAS,GAAA,EAAa,SAAA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;AAAA,EAKA,KAAA,GAAc;AACZ,IAAA,IAAI,OAAO,WAAW,WAAA,EAAa;AAEnC,IAAA,IAAI;AACF,MAAA,MAAA,CAAO,eAAe,KAAA,EAAM;AAAA,IAC9B,SAAS,KAAA,EAAO;AACd,MAAA,OAAA,CAAQ,KAAA,CAAM,mCAAmC,KAAK,CAAA;AAAA,IACxD;AAAA,EACF;AACF","file":"index.js","sourcesContent":["/**\n * String utility functions\n */\n\n/**\n * Truncate a string to a maximum length\n */\nexport function truncate(str: string, maxLength: number, suffix = '...'): string {\n if (str.length <= maxLength) return str;\n return str.slice(0, maxLength - suffix.length) + suffix;\n}\n\n/**\n * Capitalize the first letter of a string\n */\nexport function capitalize(str: string): string {\n return str.charAt(0).toUpperCase() + str.slice(1).toLowerCase();\n}\n\n/**\n * Convert string to kebab-case\n */\nexport function toKebabCase(str: string): string {\n return str\n .replace(/([a-z])([A-Z])/g, '$1-$2')\n .replace(/[\\s_]+/g, '-')\n .toLowerCase();\n}\n\n/**\n * Convert string to camelCase\n */\nexport function toCamelCase(str: string): string {\n return str\n .toLowerCase()\n .replace(/[^a-zA-Z0-9]+(.)/g, (_, chr) => chr.toUpperCase());\n}\n\n/**\n * Convert string to snake_case\n */\nexport function toSnakeCase(str: string): string {\n return str\n .replace(/([a-z])([A-Z])/g, '$1_$2')\n .replace(/[\\s-]+/g, '_')\n .toLowerCase();\n}\n\n/**\n * Generate a random alphanumeric string\n */\nexport function randomString(length: number): string {\n const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';\n let result = '';\n for (let i = 0; i < length; i++) {\n result += chars.charAt(Math.floor(Math.random() * chars.length));\n }\n return result;\n}\n\n/**\n * Slugify a string for URLs\n */\nexport function slugify(str: string): string {\n return str\n .toLowerCase()\n .trim()\n .replace(/[^\\w\\s-]/g, '')\n .replace(/[\\s_-]+/g, '-')\n .replace(/^-+|-+$/g, '');\n}\n","/**\n * Date utility functions\n */\n\n/**\n * Format date to ISO string\n */\nexport function toISOString(date: Date | string | number): string {\n return new Date(date).toISOString();\n}\n\n/**\n * Format date to YYYY-MM-DD\n */\nexport function toDateString(date: Date | string | number): string {\n const d = new Date(date);\n const year = d.getFullYear();\n const month = String(d.getMonth() + 1).padStart(2, '0');\n const day = String(d.getDate()).padStart(2, '0');\n return `${year}-${month}-${day}`;\n}\n\n/**\n * Get date range for the last N days\n */\nexport function getLastNDays(n: number): { startDate: Date; endDate: Date } {\n const endDate = new Date();\n const startDate = new Date();\n startDate.setDate(startDate.getDate() - n);\n return { startDate, endDate };\n}\n\n/**\n * Check if a date is today\n */\nexport function isToday(date: Date | string | number): boolean {\n const d = new Date(date);\n const today = new Date();\n return d.toDateString() === today.toDateString();\n}\n\n/**\n * Add days to a date\n */\nexport function addDays(date: Date, days: number): Date {\n const result = new Date(date);\n result.setDate(result.getDate() + days);\n return result;\n}\n\n/**\n * Get start of day\n */\nexport function startOfDay(date: Date): Date {\n const result = new Date(date);\n result.setHours(0, 0, 0, 0);\n return result;\n}\n\n/**\n * Get end of day\n */\nexport function endOfDay(date: Date): Date {\n const result = new Date(date);\n result.setHours(23, 59, 59, 999);\n return result;\n}\n\n/**\n * Get difference in days between two dates\n */\nexport function daysDifference(date1: Date, date2: Date): number {\n const oneDay = 24 * 60 * 60 * 1000;\n return Math.round(Math.abs((date1.getTime() - date2.getTime()) / oneDay));\n}\n","/**\n * URL utility functions\n */\n\n/**\n * Parse query parameters from URL\n */\nexport function parseQueryParams(url: string): Record<string, string> {\n const params: Record<string, string> = {};\n const urlObj = new URL(url);\n urlObj.searchParams.forEach((value, key) => {\n params[key] = value;\n });\n return params;\n}\n\n/**\n * Build query string from object\n */\nexport function buildQueryString(params: Record<string, unknown>): string {\n const searchParams = new URLSearchParams();\n Object.entries(params).forEach(([key, value]) => {\n if (value !== null && value !== undefined) {\n searchParams.append(key, String(value));\n }\n });\n return searchParams.toString();\n}\n\n/**\n * Get domain from URL\n */\nexport function getDomain(url: string): string {\n try {\n const urlObj = new URL(url);\n return urlObj.hostname;\n } catch {\n return '';\n }\n}\n\n/**\n * Get pathname from URL\n */\nexport function getPathname(url: string): string {\n try {\n const urlObj = new URL(url);\n return urlObj.pathname;\n } catch {\n return '';\n }\n}\n\n/**\n * Validate URL\n */\nexport function isValidUrl(url: string): boolean {\n try {\n new URL(url);\n return true;\n } catch {\n return false;\n }\n}\n\n/**\n * Combine URL parts\n */\nexport function combineUrl(base: string, ...paths: string[]): string {\n let url = base.replace(/\\/+$/, '');\n for (const path of paths) {\n url += '/' + path.replace(/^\\/+/, '');\n }\n return url;\n}\n","/**\n * Hashing utility functions\n */\n\n/**\n * Simple hash function for strings (non-cryptographic)\n */\nexport function simpleHash(str: string): number {\n let hash = 0;\n for (let i = 0; i < str.length; i++) {\n const char = str.charCodeAt(i);\n hash = (hash << 5) - hash + char;\n hash |= 0; // Convert to 32bit integer\n }\n return Math.abs(hash);\n}\n\n/**\n * Generate a simple hash string from input\n */\nexport function hashString(str: string): string {\n return simpleHash(str).toString(36);\n}\n\n/**\n * Generate a deterministic ID from multiple values\n */\nexport function generateId(...values: (string | number)[]): string {\n const combined = values.join('|');\n return hashString(combined);\n}\n","/**\n * Retry utility with exponential backoff\n */\n\nexport interface RetryOptions {\n maxAttempts?: number;\n delayMs?: number;\n backoffMultiplier?: number;\n maxDelayMs?: number;\n onRetry?: (error: Error, attempt: number) => void;\n}\n\n/**\n * Retry a function with exponential backoff\n */\nexport async function retry<T>(\n fn: () => Promise<T>,\n options: RetryOptions = {}\n): Promise<T> {\n const {\n maxAttempts = 3,\n delayMs = 1000,\n backoffMultiplier = 2,\n maxDelayMs = 30000,\n onRetry,\n } = options;\n\n let lastError: Error;\n\n for (let attempt = 1; attempt <= maxAttempts; attempt++) {\n try {\n return await fn();\n } catch (error) {\n lastError = error as Error;\n\n if (attempt === maxAttempts) {\n throw lastError;\n }\n\n const delay = Math.min(delayMs * Math.pow(backoffMultiplier, attempt - 1), maxDelayMs);\n\n if (onRetry) {\n onRetry(lastError, attempt);\n }\n\n await new Promise(resolve => setTimeout(resolve, delay));\n }\n }\n\n throw lastError!;\n}\n","/**\n * Debounce utility\n */\n\n// biome-ignore lint: any is needed for generic function signature\nexport function debounce<T extends (...args: any[]) => any>(\n func: T,\n waitMs: number\n): (...args: Parameters<T>) => void {\n let timeoutId: ReturnType<typeof setTimeout> | null = null;\n\n return function debounced(...args: Parameters<T>) {\n if (timeoutId !== null) {\n clearTimeout(timeoutId);\n }\n\n timeoutId = setTimeout(() => {\n func(...args);\n }, waitMs);\n };\n}\n","/**\n * Throttle utility\n */\n\n// biome-ignore lint: any is needed for generic function signature\nexport function throttle<T extends (...args: any[]) => any>(\n func: T,\n limitMs: number\n): (...args: Parameters<T>) => void {\n let inThrottle = false;\n let lastArgs: Parameters<T> | null = null;\n\n return function throttled(...args: Parameters<T>) {\n if (!inThrottle) {\n func(...args);\n inThrottle = true;\n\n setTimeout(() => {\n inThrottle = false;\n if (lastArgs !== null) {\n throttled(...lastArgs);\n lastArgs = null;\n }\n }, limitMs);\n } else {\n lastArgs = args;\n }\n };\n}\n","/**\n * Storage utility functions for browser localStorage/sessionStorage\n */\n\n/**\n * Safe localStorage wrapper\n */\nexport const storage = {\n /**\n * Get item from localStorage with JSON parsing\n */\n get<T>(key: string, defaultValue?: T): T | null {\n if (typeof window === 'undefined') return defaultValue ?? null;\n\n try {\n const item = window.localStorage.getItem(key);\n return item ? JSON.parse(item) : (defaultValue ?? null);\n } catch {\n return defaultValue ?? null;\n }\n },\n\n /**\n * Set item in localStorage with JSON stringification\n */\n set<T>(key: string, value: T): void {\n if (typeof window === 'undefined') return;\n\n try {\n window.localStorage.setItem(key, JSON.stringify(value));\n } catch (error) {\n console.error('Failed to set localStorage item:', error);\n }\n },\n\n /**\n * Remove item from localStorage\n */\n remove(key: string): void {\n if (typeof window === 'undefined') return;\n\n try {\n window.localStorage.removeItem(key);\n } catch (error) {\n console.error('Failed to remove localStorage item:', error);\n }\n },\n\n /**\n * Clear all localStorage\n */\n clear(): void {\n if (typeof window === 'undefined') return;\n\n try {\n window.localStorage.clear();\n } catch (error) {\n console.error('Failed to clear localStorage:', error);\n }\n },\n};\n\n/**\n * Safe sessionStorage wrapper\n */\nexport const sessionStorage = {\n /**\n * Get item from sessionStorage with JSON parsing\n */\n get<T>(key: string, defaultValue?: T): T | null {\n if (typeof window === 'undefined') return defaultValue ?? null;\n\n try {\n const item = window.sessionStorage.getItem(key);\n return item ? JSON.parse(item) : (defaultValue ?? null);\n } catch {\n return defaultValue ?? null;\n }\n },\n\n /**\n * Set item in sessionStorage with JSON stringification\n */\n set<T>(key: string, value: T): void {\n if (typeof window === 'undefined') return;\n\n try {\n window.sessionStorage.setItem(key, JSON.stringify(value));\n } catch (error) {\n console.error('Failed to set sessionStorage item:', error);\n }\n },\n\n /**\n * Remove item from sessionStorage\n */\n remove(key: string): void {\n if (typeof window === 'undefined') return;\n\n try {\n window.sessionStorage.removeItem(key);\n } catch (error) {\n console.error('Failed to remove sessionStorage item:', error);\n }\n },\n\n /**\n * Clear all sessionStorage\n */\n clear(): void {\n if (typeof window === 'undefined') return;\n\n try {\n window.sessionStorage.clear();\n } catch (error) {\n console.error('Failed to clear sessionStorage:', error);\n }\n },\n};\n"]}
package/package.json ADDED
@@ -0,0 +1,60 @@
1
+ {
2
+ "name": "@entrolytics/utilities",
3
+ "version": "2.1.0",
4
+ "description": "Common utilities and helper functions for Entrolytics",
5
+ "keywords": [
6
+ "entrolytics",
7
+ "utilities",
8
+ "helpers",
9
+ "utils"
10
+ ],
11
+ "author": "Entrolytics <hey@entrolytics.click>",
12
+ "license": "MIT",
13
+ "homepage": "https://entrolytics.click",
14
+ "repository": {
15
+ "type": "git",
16
+ "url": "https://github.com/entrolytics/utilities",
17
+ "directory": "packages/utilities/entrolytics-utilities"
18
+ },
19
+ "bugs": {
20
+ "url": "https://github.com/entrolytics/utilities/issues"
21
+ },
22
+ "type": "module",
23
+ "main": "./dist/index.cjs",
24
+ "module": "./dist/index.js",
25
+ "types": "./dist/index.d.ts",
26
+ "exports": {
27
+ ".": {
28
+ "types": "./dist/index.d.ts",
29
+ "import": "./dist/index.js",
30
+ "require": "./dist/index.cjs"
31
+ }
32
+ },
33
+ "files": [
34
+ "dist",
35
+ "README.md",
36
+ "LICENSE"
37
+ ],
38
+ "sideEffects": false,
39
+ "engines": {
40
+ "node": ">=22.x"
41
+ },
42
+ "publishConfig": {
43
+ "access": "public"
44
+ },
45
+ "devDependencies": {
46
+ "@biomejs/biome": "2.3.11",
47
+ "@types/node": "^25.0.3",
48
+ "tsup": "^8.5.1",
49
+ "typescript": "^5.9.3",
50
+ "vitest": "^4.0.16"
51
+ },
52
+ "scripts": {
53
+ "dev": "tsup --watch",
54
+ "build": "tsup",
55
+ "lint": "biome check --write .",
56
+ "typecheck": "tsc --noEmit",
57
+ "test": "vitest run",
58
+ "test:watch": "vitest"
59
+ }
60
+ }