@habemus-papadum/utils
v0.0.2
Published
Utility functions for the ljs monorepo
Readme
@habemus-papadum/utils
Utility functions for the ljs monorepo.
Installation
npm install @habemus-papadum/utilsUsage
import { slugify, debounce, deepClone, isPlainObject, sleep } from "@habemus-papadum/utils";
// Convert text to URL-friendly slug
slugify("Hello World!"); // "hello-world"
// Create debounced function
const debouncedFn = debounce(() => console.log("called"), 300);
// Deep clone an object
const clone = deepClone({ nested: { value: 1 } });
// Check if value is a plain object
isPlainObject({}); // true
isPlainObject([]); // false
// Sleep for specified milliseconds
await sleep(1000);API
slugify(text: string): string
Converts a string to a URL-friendly slug.
debounce<T>(fn: T, delay: number): (...args) => void
Creates a debounced version of a function.
deepClone<T>(obj: T): T
Creates a deep clone of an object.
isPlainObject(value: unknown): boolean
Checks if a value is a plain object.
sleep(ms: number): Promise<void>
Returns a promise that resolves after the specified milliseconds.
License
ISC
