feat(common): add zero-dep scalar coercion primitives (coerce)

Phase 1 of de-duplicating config normalization. isObject/boolOr/clampNum/
clampInt were copied verbatim across notifications/config and webui/
ui-config; give them a single home as @snowluma/common/coerce (new
per-file subpath export, zero deps — fits common's leaf-utility charter).

Byte-identical to both originals (adversarially verified), so the phase-2
migration is a pure delete-and-import. clampInt is clamp-then-trunc;
10 table tests pin types, numeric-string coercion, non-finite→fallback,
bounds, and the clamp/trunc order. Not yet wired into consumers.
This commit is contained in:
DrSmoothl committed 2026-06-25 00:01:39 +08:00
1 parent 3a4af38842
commit 1ce7385d1e
3 files changed
+112

No files matched your search

+4
View File
@@ -16,6 +16,10 @@
"types": "./src/logger.ts",
"default": "./src/logger.ts"
},
"./coerce": {
"types": "./src/coerce.ts",
"default": "./src/coerce.ts"
},
"./hex": {
"types": "./src/hex.ts",
"default": "./src/hex.ts"