@laisky/js-utils
v0.0.5
Published
Utility library for React/JS applications
Maintainers
Readme
Laisky Utils
A comprehensive utility library for React and JavaScript applications with database, DOM, cryptography, caching, and other utilities.
Installation
npm install @laisky/js-utilsUsage
// Import everything
import laiskyUtils from "laisky-utils";
// Or import specific modules
import { KvSet, KvGet } from "laisky-utils";
import { formatRelativeTime } from "laisky-utils";
// Example usage
const timestamp = new Date();
console.log(formatRelativeTime(timestamp)); // "just now"
// Using the database utilities
await KvSet("myKey", { foo: "bar" });
const value = await KvGet("myKey");API Reference
Database Operations
KvSet(key, value)- Store data in IndexedDBKvGet(key)- Retrieve data from IndexedDBKvExists(key)- Check if key existsKvDel(key)- Delete a key
Caching
SetCache(key, value, ttlSeconds)- Cache with TTLGetCache(key)- Get from cache
DOM Utilities
LoadJsModules(urls, type)- Load JS scripts dynamicallyEnableTooltipsEverywhere()- Initialize Bootstrap tooltipswaitElementReady(selector, maxWaitMs)- Wait for element to appear
Cryptography
SHA256(str)- Calculate SHA-256 hashgetSHA1(str)- Calculate SHA-1 hash
Markdown
Markdown2HTML(markdown)- Convert markdown to HTML
String Utilities
TrimSpace(str)- Trim whitespaceescapeHtml(str)- Escape HTML special charactersformatRelativeTime(timestamp)- Format as relative time
License
MIT
