@regardio/js 1.0.2 → 1.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/README.md +29 -31
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -1,26 +1,25 @@
|
|
|
1
1
|
# @regardio/js
|
|
2
2
|
|
|
3
|
-
>
|
|
3
|
+
> TypeScript utilities for Regardio applications.
|
|
4
4
|
|
|
5
|
-
A collection of
|
|
6
|
-
like text manipulation, HTTP handling, internationalization, time formatting, and validation.
|
|
5
|
+
A collection of small, tree-shakeable utilities for the everyday work of text, HTTP, internationalisation, time, and validation — the pieces you end up re-implementing in every project.
|
|
7
6
|
|
|
8
|
-
##
|
|
7
|
+
## Pre-release notice
|
|
9
8
|
|
|
10
|
-
|
|
9
|
+
This package is currently at v0.x. The utilities run in production across Regardio's own projects, but the API may still move between minor versions. A few habits that help:
|
|
11
10
|
|
|
12
|
-
-
|
|
13
|
-
-
|
|
14
|
-
-
|
|
11
|
+
- Pin to exact versions in `package.json`
|
|
12
|
+
- Read the changelog before upgrading
|
|
13
|
+
- Expect the occasional breaking change until v1.0
|
|
15
14
|
|
|
16
|
-
##
|
|
15
|
+
## What it's for
|
|
17
16
|
|
|
18
|
-
|
|
17
|
+
`@regardio/js` exists so a handful of steady utilities don't have to be reinvented:
|
|
19
18
|
|
|
20
|
-
- **
|
|
21
|
-
- **
|
|
22
|
-
- **
|
|
23
|
-
- **
|
|
19
|
+
- **Shared, well-used helpers** — these functions carry real Regardio projects and have been refined through actual use
|
|
20
|
+
- **Less boilerplate** — text formatting, cookie handling, language detection, and time formatting collected in one place
|
|
21
|
+
- **Framework-agnostic** — works with any JavaScript/TypeScript project (React, Node, Deno, and so on)
|
|
22
|
+
- **Tree-shakeable** — import what's needed, leave the rest out of the bundle
|
|
24
23
|
|
|
25
24
|
## Installation
|
|
26
25
|
|
|
@@ -30,9 +29,9 @@ pnpm add @regardio/js
|
|
|
30
29
|
|
|
31
30
|
## Modules
|
|
32
31
|
|
|
33
|
-
###
|
|
32
|
+
### `@regardio/js/text`
|
|
34
33
|
|
|
35
|
-
String manipulation and formatting
|
|
34
|
+
String manipulation and formatting.
|
|
36
35
|
|
|
37
36
|
```ts
|
|
38
37
|
import {
|
|
@@ -49,9 +48,9 @@ formatBytes(1500000); // "1.5 MB"
|
|
|
49
48
|
parseAuthorString('John <john@example.com>'); // { name: 'John', email: 'john@example.com' }
|
|
50
49
|
```
|
|
51
50
|
|
|
52
|
-
###
|
|
51
|
+
### `@regardio/js/time`
|
|
53
52
|
|
|
54
|
-
Date, time, and async
|
|
53
|
+
Date, time, and async helpers.
|
|
55
54
|
|
|
56
55
|
```ts
|
|
57
56
|
import {
|
|
@@ -68,17 +67,17 @@ await delay(1000); // Wait 1 second
|
|
|
68
67
|
await measure('fetchData', () => fetch('/api')); // Logs timing
|
|
69
68
|
```
|
|
70
69
|
|
|
71
|
-
###
|
|
70
|
+
### `@regardio/js/http`
|
|
72
71
|
|
|
73
72
|
HTTP, cookie, and routing utilities.
|
|
74
73
|
|
|
75
74
|
```ts
|
|
76
75
|
import {
|
|
77
|
-
// Client-side cookies (async
|
|
76
|
+
// Client-side cookies (async — Cookie Store API + fallback)
|
|
78
77
|
getCookie,
|
|
79
78
|
setCookie,
|
|
80
79
|
deleteCookie,
|
|
81
|
-
// Client-side cookies (sync
|
|
80
|
+
// Client-side cookies (sync — document.cookie only)
|
|
82
81
|
getCookieSync,
|
|
83
82
|
setCookieSync,
|
|
84
83
|
deleteCookieSync,
|
|
@@ -121,7 +120,7 @@ const domain = createDomain(request); // "https://example.com"
|
|
|
121
120
|
isRouteActive('/account', '/account/settings', false); // true
|
|
122
121
|
```
|
|
123
122
|
|
|
124
|
-
###
|
|
123
|
+
### `@regardio/js/intl`
|
|
125
124
|
|
|
126
125
|
Server-side language detection for i18n.
|
|
127
126
|
|
|
@@ -136,9 +135,9 @@ const detector = new LanguageDetector({
|
|
|
136
135
|
const locale = await detector.detect(request);
|
|
137
136
|
```
|
|
138
137
|
|
|
139
|
-
###
|
|
138
|
+
### `@regardio/js/assert`
|
|
140
139
|
|
|
141
|
-
Runtime
|
|
140
|
+
Runtime assertions and validation.
|
|
142
141
|
|
|
143
142
|
```ts
|
|
144
143
|
import { invariant, invariantResponse, verifyAccept } from '@regardio/js/assert';
|
|
@@ -148,7 +147,7 @@ invariantResponse(user, 'User not found', { status: 404 }); // Throws Response
|
|
|
148
147
|
verifyAccept('image/png', 'image/*'); // true
|
|
149
148
|
```
|
|
150
149
|
|
|
151
|
-
###
|
|
150
|
+
### `@regardio/js/encoding`
|
|
152
151
|
|
|
153
152
|
Binary encoding utilities.
|
|
154
153
|
|
|
@@ -158,7 +157,7 @@ import { urlBase64ToUint8Array } from '@regardio/js/encoding';
|
|
|
158
157
|
const bytes = urlBase64ToUint8Array(vapidPublicKey);
|
|
159
158
|
```
|
|
160
159
|
|
|
161
|
-
## Module
|
|
160
|
+
## Module overview
|
|
162
161
|
|
|
163
162
|
| Module | Description |
|
|
164
163
|
|--------|-------------|
|
|
@@ -171,17 +170,16 @@ const bytes = urlBase64ToUint8Array(vapidPublicKey);
|
|
|
171
170
|
|
|
172
171
|
## Contributing
|
|
173
172
|
|
|
174
|
-
|
|
173
|
+
The package is maintained primarily for Regardio's own work, but contributions from elsewhere are welcome:
|
|
175
174
|
|
|
176
175
|
- Bug reports and fixes
|
|
177
176
|
- Documentation improvements
|
|
178
|
-
- Feature suggestions (
|
|
177
|
+
- Feature suggestions (not every one will become an implementation)
|
|
179
178
|
|
|
180
179
|
## License
|
|
181
180
|
|
|
182
|
-
**MIT
|
|
181
|
+
**MIT** — free to use in commercial and open-source projects.
|
|
183
182
|
|
|
184
183
|
---
|
|
185
184
|
|
|
186
|
-
*Part of the [Regardio Ensemble](https://regard.io/ensemble) toolkit for
|
|
187
|
-
shared well-being.*
|
|
185
|
+
*Part of the [Regardio Ensemble](https://regard.io/ensemble) toolkit for shared well-being.*
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://www.schemastore.org/package.json",
|
|
3
3
|
"name": "@regardio/js",
|
|
4
|
-
"version": "1.0
|
|
4
|
+
"version": "1.1.0",
|
|
5
5
|
"private": false,
|
|
6
6
|
"description": "Regardio JavaScript utilities",
|
|
7
7
|
"keywords": [
|
|
@@ -66,9 +66,9 @@
|
|
|
66
66
|
"@types/node": "25.6.0",
|
|
67
67
|
"@vitest/coverage-v8": "4.1.5",
|
|
68
68
|
"@vitest/ui": "4.1.5",
|
|
69
|
-
"tsdown": "0.21.
|
|
69
|
+
"tsdown": "0.21.10",
|
|
70
70
|
"vitest": "4.1.5",
|
|
71
|
-
"@regardio/dev": "2.0
|
|
71
|
+
"@regardio/dev": "2.1.0"
|
|
72
72
|
},
|
|
73
73
|
"scripts": {
|
|
74
74
|
"build": "tsdown",
|