@ewanc26/utils 0.1.3 → 0.1.4
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 +2 -33
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -1,43 +1,12 @@
|
|
|
1
1
|
# @ewanc26/utils
|
|
2
2
|
|
|
3
|
-
Shared utility functions
|
|
4
|
-
|
|
5
|
-
## Modules
|
|
6
|
-
|
|
7
|
-
- **Date & Locale** — `formatRelativeTime`, `formatLocalizedDate`, `getUserLocale`
|
|
8
|
-
- **Number Formatting** — `formatCompactNumber`, `formatNumber`
|
|
9
|
-
- **URL Utilities** — `getDomain`, `atUriToBlueskyUrl`, `getBlueskyProfileUrl`, `isExternalUrl`
|
|
10
|
-
- **Validators & Text** — `isValidTid`, `isValidDid`, `truncateText`, `escapeHtml`, `getInitials`, `debounce`, `throttle`
|
|
11
|
-
- **RSS Generation** — `generateRSSFeed`, `generateRSSItem`, `createRSSResponse`, `escapeXml`, `normalizeCharacters`, `formatRSSDate`
|
|
12
|
-
|
|
13
|
-
## Installation
|
|
3
|
+
Shared utility functions — date formatting, number formatting, URL utilities, validators, text helpers, and RSS generation. Zero runtime dependencies.
|
|
14
4
|
|
|
15
5
|
```bash
|
|
16
6
|
pnpm add @ewanc26/utils
|
|
17
7
|
```
|
|
18
8
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
```typescript
|
|
22
|
-
import { formatRelativeTime, formatCompactNumber, getDomain, isValidDid, generateRSSFeed } from '@ewanc26/utils';
|
|
23
|
-
|
|
24
|
-
formatRelativeTime('2025-11-13T00:00:00Z'); // '3d ago'
|
|
25
|
-
formatCompactNumber(1500); // '1.5K'
|
|
26
|
-
getDomain('https://www.example.com/path'); // 'example.com'
|
|
27
|
-
isValidDid('did:plc:abc123'); // true
|
|
28
|
-
|
|
29
|
-
const xml = generateRSSFeed({ title: 'My Blog', link: 'https://mysite.com', description: '…' }, items);
|
|
30
|
-
```
|
|
31
|
-
|
|
32
|
-
All functions are SSR-safe and fall back to `en-GB` when `navigator` / `window` are unavailable.
|
|
33
|
-
|
|
34
|
-
## Build
|
|
35
|
-
|
|
36
|
-
```bash
|
|
37
|
-
pnpm build # tsc
|
|
38
|
-
pnpm dev # tsc --watch
|
|
39
|
-
pnpm check # tsc --noEmit
|
|
40
|
-
```
|
|
9
|
+
Full documentation at **[docs.ewancroft.uk](https://docs.ewancroft.uk/projects/utils)**.
|
|
41
10
|
|
|
42
11
|
## Licence
|
|
43
12
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ewanc26/utils",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.4",
|
|
4
4
|
"description": "Shared utility functions extracted from ewancroft.uk",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -19,12 +19,12 @@
|
|
|
19
19
|
"dist",
|
|
20
20
|
"src"
|
|
21
21
|
],
|
|
22
|
+
"devDependencies": {
|
|
23
|
+
"typescript": "^5.9.3"
|
|
24
|
+
},
|
|
22
25
|
"scripts": {
|
|
23
26
|
"build": "tsc --project tsconfig.json",
|
|
24
27
|
"dev": "tsc --project tsconfig.json --watch",
|
|
25
28
|
"check": "tsc --noEmit"
|
|
26
|
-
},
|
|
27
|
-
"devDependencies": {
|
|
28
|
-
"typescript": "^5.9.3"
|
|
29
29
|
}
|
|
30
|
-
}
|
|
30
|
+
}
|