@kikiutils/shared
v14.0.0
Published
A lightweight and modular utility library for modern JavaScript and TypeScript — includes secure hashing, flexible logging, datetime tools, Vue/web helpers, storage abstraction, and more.
Maintainers
Readme
@kikiutils/shared
A lightweight and modular utility library for modern JavaScript and TypeScript — includes secure hashing, flexible logging, datetime tools, Vue/web helpers, storage abstraction, and more.
TODO: update README
Features
- 📋 Clipboard utilities — copy text and blobs using the modern Clipboard API (Browser only)
- 📜 Logging utilities — simple and extensible logging via Consola and Pino
- 🔒 Crypto utilities — secure hashing functions: MD5, SHA3-224/256/384/512
- 📅 Datetime utilities — manipulate, format, and offset dates and ranges
- 🔢 Enum utilities — extract enum keys and values (number or string)
- 🌱 Environment helpers — safe env var access with error handling (Node only)
- 📈 Math utilities — rounding, formatting percentages, and ratios
- 💎 Number utilities — number padding, compact display, currency formatting
- 🔤 String utilities — casing, trimming, random string generation, etc.
- 🌐 URL utilities — parse and construct query strings and redirect URLs
- 🧩 Vue 3 utilities — composables like scroll preservation and key handling
- 🖥️ Web utilities — browser DOM helpers (e.g. scroll to top, key matching)
- 🗄️ Storage utilities — enhanced localStorage, Redis, and LRU abstractions
- 📦 Modular by design — import only what you need via
@kikiutils/shared/<module>
Requirements
- Node.js
>=22.12.0
Installation
Using pnpm:
pnpm add @kikiutils/sharedYou can also use yarn, npm, or bun.
[!NOTE] This package is modular. It does not install all dependencies by default.
If a utility depends on a third-party package (e.g.
date-fns), you must install it manually.
Usage
Import the functions or modules you want to use:
import { logger } from '@kikituils/shared/consola';
import { extractFirstValue } from '@kikituils/shared/general';
const data = [
0,
1
];
const value = extractFirstValue(data);
console.log(value); // 0
logger.info(value);Modules & Functions
Each module file includes function-level comments and usage examples.
buffer
toBuffer
clipboard
copyBlobToClipboardcopyTextToClipboard
consola
Console logger integration.
crypto-hash
cryptoMd5,cryptoMd5ToBuffercryptoSha3224,cryptoSha3224ToBuffercryptoSha3256,cryptoSha3256ToBuffercryptoSha3384,cryptoSha3384ToBuffercryptoSha3512,cryptoSha3512ToBuffer
datetime
formatDategetDateRangeFromDategetMidnightDateFromToday
element-plus
createElFormItemRuleWithDefaults
enum
getEnumStringValuesgetEnumNumberValuesgetEnumValues
env
checkAndGetEnvValue
general
extractFirstValue
hash
sha3224sha3256sha3384sha3512
math
toPercentageString
number
toCompactNumberString
object
stringifyObjectDeterministically
pino
Pino logger integration.
random
generateWithNestedRandomLength
storage
enhanced-local
createKeyedEnhancedLocalStoreenhancedLocalStorage
enhanced-redis
createEnhancedRedisStoragecreateKeyedEnhancedRedisStore
lru/keyed-store
createKeyedLruStore
string
randomString
url
appendRedirectParamToUrl
vue
appendRedirectParamFromCurrentRouteToUrlclearIntervalRefclearTimeoutRefusePreserveScroll
web
appendRedirectParamFromCurrentLocationToUrlassignUrlWithRedirectParamFromCurrentLocation