10.1.2 • Published 10 months ago

@kikiutils/shared v10.1.2

Weekly downloads
-
License
MIT
Repository
github
Last release
10 months ago

@kikiutils/shared

npm version npm downloads codecov License

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.

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 >= 18.12.1

Installation

Using pnpm:

pnpm add @kikiutils/shared

You 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.

clipboard

  • copyBlobToClipboard
  • copyTextToClipboard

consola

Console logger integration.

crypto-hash

  • cryptoMd5, cryptoMd5ToBuffer
  • cryptoSha3224, cryptoSha3224ToBuffer
  • cryptoSha3256, cryptoSha3256ToBuffer
  • cryptoSha3384, cryptoSha3384ToBuffer
  • cryptoSha3512, cryptoSha3512ToBuffer

datetime

  • formatDate
  • getDateRangeFromDate
  • getMidnightDateFromToday

element-plus

  • createElFormItemRuleWithDefaults

enum

  • getEnumStringValues
  • getEnumNumberValues

env

  • checkAndGetEnvValue

general

  • extractFirstValue

hash

  • sha3224
  • sha3256
  • sha3384
  • sha3512

math

  • toPercentageString

number

  • toCompactNumberString

pino

Pino logger integration.

random

  • generateWithNestedRandomLength

storage

enhanced-local

  • createKeyedEnhancedLocalStore
  • enhancedLocalStorage

enhanced-redis

  • createEnhancedRedisStorage
  • createKeyedEnhancedRedisStore

lru/keyed-store

  • createKeyedLruStore

string

  • randomString

url

  • appendRedirectParamToUrl

vue

  • appendRedirectParamFromCurrentRouteToUrl
  • clearIntervalRef
  • clearTimeoutRef
  • usePreserveScroll

web

  • appendRedirectParamFromCurrentLocationToUrl
  • assignUrlWithRedirectParamFromCurrentLocation

License

MIT License

10.1.2

10 months ago

10.1.1

10 months ago

10.1.0

10 months ago

10.0.0

10 months ago

9.3.1

10 months ago

9.3.0

10 months ago

9.2.0

10 months ago

9.1.0

10 months ago

9.0.0

10 months ago