@entrolytics/utilities 2.2.0 → 2.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -6,9 +6,13 @@ Common utilities and helper functions for Entrolytics projects.
6
6
 
7
7
  ```bash
8
8
  npm install @entrolytics/utilities
9
+
9
10
  # or
11
+
10
12
  pnpm add @entrolytics/utilities
13
+
11
14
  # or
15
+
12
16
  yarn add @entrolytics/utilities
13
17
  ```
14
18
 
@@ -29,17 +33,17 @@ yarn add @entrolytics/utilities
29
33
  ### String Utilities
30
34
 
31
35
  ```typescript
32
- import { truncate, slugify, toKebabCase } from '@entrolytics/utilities';
36
+ import { truncate, slugify, toKebabCase } from "@entrolytics/utilities";
33
37
 
34
- truncate('Long text here', 10); // 'Long te...'
35
- slugify('Hello World!'); // 'hello-world'
36
- toKebabCase('camelCaseString'); // 'camel-case-string'
38
+ truncate("Long text here", 10); // 'Long te...'
39
+ slugify("Hello World!"); // 'hello-world'
40
+ toKebabCase("camelCaseString"); // 'camel-case-string'
37
41
  ```
38
42
 
39
43
  ### Date Utilities
40
44
 
41
45
  ```typescript
42
- import { getLastNDays, toDateString, addDays } from '@entrolytics/utilities';
46
+ import { getLastNDays, toDateString, addDays } from "@entrolytics/utilities";
43
47
 
44
48
  const { startDate, endDate } = getLastNDays(7);
45
49
  toDateString(new Date()); // '2025-12-26'
@@ -49,21 +53,21 @@ addDays(new Date(), 5); // Date 5 days from now
49
53
  ### URL Utilities
50
54
 
51
55
  ```typescript
52
- import { parseQueryParams, getDomain, combineUrl } from '@entrolytics/utilities';
56
+ import { parseQueryParams, getDomain, combineUrl } from "@entrolytics/utilities";
53
57
 
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'
58
+ parseQueryParams("https://example.com?foo=bar"); // { foo: 'bar' }
59
+ getDomain("https://example.com/path"); // 'example.com'
60
+ combineUrl("https://api.com", "v1", "users"); // 'https://api.com/v1/users'
57
61
  ```
58
62
 
59
63
  ### Retry with Backoff
60
64
 
61
65
  ```typescript
62
- import { retry } from '@entrolytics/utilities';
66
+ import { retry } from "@entrolytics/utilities";
63
67
 
64
68
  await retry(
65
69
  async () => {
66
- const response = await fetch('https://api.example.com/data');
70
+ const response = await fetch("https://api.example.com/data");
67
71
  return response.json();
68
72
  },
69
73
  {
@@ -73,37 +77,37 @@ await retry(
73
77
  onRetry: (error, attempt) => {
74
78
  console.log(`Retry attempt ${attempt}:`, error.message);
75
79
  },
76
- }
80
+ },
77
81
  );
78
82
  ```
79
83
 
80
84
  ### Debounce & Throttle
81
85
 
82
86
  ```typescript
83
- import { debounce, throttle } from '@entrolytics/utilities';
87
+ import { debounce, throttle } from "@entrolytics/utilities";
84
88
 
85
89
  const debouncedSearch = debounce((query: string) => {
86
- console.log('Searching for:', query);
90
+ console.log("Searching for:", query);
87
91
  }, 300);
88
92
 
89
93
  const throttledScroll = throttle(() => {
90
- console.log('Scrolling...');
94
+ console.log("Scrolling...");
91
95
  }, 100);
92
96
  ```
93
97
 
94
98
  ### Storage Utilities
95
99
 
96
100
  ```typescript
97
- import { storage, sessionStorage } from '@entrolytics/utilities';
101
+ import { storage, sessionStorage } from "@entrolytics/utilities";
98
102
 
99
103
  // localStorage
100
- storage.set('user', { name: 'John', id: 123 });
101
- const user = storage.get('user'); // { name: 'John', id: 123 }
102
- storage.remove('user');
104
+ storage.set("user", { name: "John", id: 123 });
105
+ const user = storage.get("user"); // { name: 'John', id: 123 }
106
+ storage.remove("user");
103
107
 
104
108
  // sessionStorage
105
- sessionStorage.set('tempData', { value: 42 });
106
- const data = sessionStorage.get('tempData');
109
+ sessionStorage.set("tempData", { value: 42 });
110
+ const data = sessionStorage.get("tempData");
107
111
  ```
108
112
 
109
113
  ## API Reference