@cslug/core 0.1.0 → 0.2.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/package.json +2 -2
- package/src/contracts.ts +3 -0
- package/src/money.ts +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cslug/core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Application, container and @inject, providers, config, events, logger, errors, context, Clock, Money, i18n, contracts.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -28,6 +28,6 @@
|
|
|
28
28
|
"bun": ">=1.3.14"
|
|
29
29
|
},
|
|
30
30
|
"peerDependencies": {
|
|
31
|
-
"@cslug/validation": "0.
|
|
31
|
+
"@cslug/validation": "0.2.0"
|
|
32
32
|
}
|
|
33
33
|
}
|
package/src/contracts.ts
CHANGED
|
@@ -173,6 +173,7 @@ export abstract class Lock {
|
|
|
173
173
|
}
|
|
174
174
|
}
|
|
175
175
|
|
|
176
|
+
/** In-process `Lock` (tests and single-process apps); `@cslug/redis` provides the shared one. */
|
|
176
177
|
export class MemoryLock extends Lock {
|
|
177
178
|
private readonly held = new Map<string, { token: string; expires: number }>()
|
|
178
179
|
|
|
@@ -240,6 +241,7 @@ export abstract class RateLimiter {
|
|
|
240
241
|
}
|
|
241
242
|
}
|
|
242
243
|
|
|
244
|
+
/** In-process `RateLimiter` (sliding window); `@cslug/redis` provides the shared one. */
|
|
243
245
|
export class MemoryRateLimiter extends RateLimiter {
|
|
244
246
|
private readonly hits = new Map<string, number[]>()
|
|
245
247
|
|
|
@@ -273,6 +275,7 @@ export abstract class SessionStore {
|
|
|
273
275
|
abstract destroy(id: string): Promise<void>
|
|
274
276
|
}
|
|
275
277
|
|
|
278
|
+
/** In-process `SessionStore`: sessions are lost on restart (tests, development). */
|
|
276
279
|
export class MemorySessionStore extends SessionStore {
|
|
277
280
|
private readonly cache = new MemoryCache()
|
|
278
281
|
|
package/src/money.ts
CHANGED
|
@@ -163,7 +163,7 @@ export class Money {
|
|
|
163
163
|
/** Localised: `format('fr')` → `2 200,00 €`. Exact for any size (formats the decimal string). */
|
|
164
164
|
format(locale = 'en', options: Omit<Intl.NumberFormatOptions, 'style' | 'currency'> = {}): string {
|
|
165
165
|
const f = new Intl.NumberFormat(locale, { ...options, style: 'currency', currency: this.currency })
|
|
166
|
-
return f.format(this.toDecimal() as
|
|
166
|
+
return f.format(this.toDecimal() as `${number}`)
|
|
167
167
|
}
|
|
168
168
|
|
|
169
169
|
/** JSON has no bigint: `{ amount: "220000", currency: "EUR" }`. */
|