@cybertools/utils
v1.0.1
Published
Framework-free helpers for Cyberscope apps: pagination params, number magnitude, date/BigInt deserialization.
Downloads
93
Readme
@cybertools/utils
Framework-free helpers for Cyberscope apps: pagination parameters, number magnitude formatting, and date/BigInt deserialization. Ships ESM and CJS builds with type declarations.
pnpm add @cybertools/utils| Export | Description |
| ----------------------------------------------------------- | --------------------------------------------------------------------------- |
| capitalFirst(str) | Upper-cases the first character. |
| getLimit(limit, maxLimit) | Parses a limit query value and clamps it to maxLimit. |
| getPage(page) | Parses a page query value, defaulting to 1. |
| identity(value) | Returns its argument. |
| getMagnitude(value) | Formats large numbers, e.g. 1500 becomes "1 Thousand". |
| wait(ms) | Promise that resolves after ms milliseconds. |
| deserialize(value, options) | Recursively converts dateFields to Date and bigIntFields to BigInt. |
| makeDeserializeCollection(fn) | Builds a function mapping a collection through fn. |
| makeDeserializeById(fn, key) | Builds a function returning [byId, ids] for a collection. |
| serialize, makeSerializeCollection, makeSerializeById | Deprecated; kept for @cybertools/ui compatibility. |
