@regardio/js 0.8.0 → 0.8.1

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 (2) hide show
  1. package/README.md +13 -4
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -74,11 +74,14 @@ HTTP, cookie, and routing utilities.
74
74
 
75
75
  ```ts
76
76
  import {
77
- // Client-side cookies (Cookie Store API + fallback)
77
+ // Client-side cookies (async - Cookie Store API + fallback)
78
78
  getCookie,
79
79
  setCookie,
80
- updateCookie,
81
80
  deleteCookie,
81
+ // Client-side cookies (sync - document.cookie only)
82
+ getCookieSync,
83
+ setCookieSync,
84
+ deleteCookieSync,
82
85
  // Server-side cookies (Request/Response)
83
86
  parseCookies,
84
87
  serializeCookie,
@@ -92,12 +95,18 @@ import {
92
95
  isRouteActive,
93
96
  } from '@regardio/js/http';
94
97
 
95
- // Client-side: Cookie Store API with document.cookie fallback
98
+ // Client-side async: Cookie Store API with document.cookie fallback
96
99
  await setCookie('theme', 'dark', { path: '/', secure: true, sameSite: 'lax' });
97
100
  const theme = await getCookie('theme');
98
- await updateCookie('theme', 'light', { path: '/' });
101
+ await setCookie('theme', 'light', { path: '/' }); // Update by setting again
99
102
  await deleteCookie('theme', { path: '/' });
100
103
 
104
+ // Client-side sync: document.cookie only (no async/await needed)
105
+ setCookieSync('theme', 'dark', { path: '/', secure: true, sameSite: 'lax' });
106
+ const themeSync = getCookieSync('theme');
107
+ setCookieSync('theme', 'light', { path: '/' }); // Update by setting again
108
+ deleteCookieSync('theme', { path: '/' });
109
+
101
110
  // Server-side: Request/Response cookie handling
102
111
  const session = getCookieFromRequest(request, 'session');
103
112
  const allCookies = getAllCookiesFromRequest(request);
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": "0.8.0",
4
+ "version": "0.8.1",
5
5
  "private": false,
6
6
  "description": "Regardio JavaScript utilities",
7
7
  "keywords": [