quick-utils-kit
v1.0.0
Published
A lightweight JavaScript utility library for strings, arrays, objects, numbers, async, dates, and performance optimizations.
Maintainers
Readme
Quick Utils
Quick Utils is a lightweight, modular JavaScript utility library for developers.
It provides commonly used functions for strings, arrays, objects, numbers, dates, async operations, and performance optimization.
Save time by not rewriting the same helpers over and over, and make your projects cleaner and more maintainable.
Installation
Using npm:
npm install quick-utilsOr using yarn:
yarn add quick-utilsUsage
Import the entire library:
import * as utils from 'quick-utils';Or import only what you need:
import { toCamelCase, uniqueArray, debounce } from 'quick-utils';Modules & Examples
1️⃣ String Utilities
Functions for cleaning, formatting, validating, and manipulating strings.
| Function | Description | Input | Output |
| ---------------------- | ---------------------------------------- | ----------------------------- | ---------------------------------------- |
| cleanSpaces | Remove extra spaces | " Hello World " | "Hello World" |
| removeSpecialChars | Remove special characters | "Hello@# World!" | "Hello World" |
| capitalize | Capitalize first letter | "hello" | "Hello" |
| reverseString | Reverse string | "abc" | "cba" |
| wordCount | Count words | "Hello world!" | 2 |
| toCamelCase | Convert to camelCase | "hello world" | "helloWorld" |
| toSnakeCase | Convert to snake_case | "HelloWorld!" | "hello_world" |
| toTitleCase | Convert to Title Case | "hello world" | "Hello World" |
| truncateString | Truncate string to length | "Hello world", 5 | "Hello..." |
| matchStrings | Compare two strings ignoring case/spaces | " Test ", "test" | true |
| generateRandomString | Generate random alphanumeric string | 8 | "aB12Cd34" |
| generateUUID | Generate UUID v4 | - | "f47ac10b-58cc-4372-a567-0e02b2c3d479" |
| countCharacters | Count letters a-zA-Z | "abc123" | 3 |
| slugify | Convert string to URL slug | "Hello World!" | "hello-world" |
| unslugify | Convert slug to normal string | "hello-world" | "Hello World" |
| isPalindrome | Check if palindrome | "Racecar" | true |
| isEmail | Validate email | "[email protected]" | true |
| isURL | Validate URL | "https://example.com" | true |
| isNumeric | Check numeric string | "12345" | true |
| isPhoneNumber | Validate phone number | "+923001234567" | true |
| extractNumbers | Extract all numbers | "abc123def45" | [123,45] |
| extractEmails | Extract emails | "[email protected] [email protected]" | ["[email protected]","[email protected]"] |
| extractURLs | Extract URLs | "Visit https://example.com" | ["https://example.com"] |
2️⃣ Array Utilities
Functions for unique values, flattening, chunking, shuffling, merging, and validation.
| Function | Description | Input | Output |
| ------------------ | ----------------------------- | ----------------------------------------- | -------------------------------- |
| uniqueArray | Remove duplicates | [1,2,2,3] | [1,2,3] |
| flattenArray | Flatten nested array | [1,[2,[3]]] | [1,2,3] |
| chunkArray | Split array into chunks | [1,2,3,4], 2 | [[1,2],[3,4]] |
| sumArray | Sum numeric elements | [1,2,3] | 6 |
| shuffleArray | Shuffle array randomly | [1,2,3] | [2,1,3] |
| intersectArrays | Return common elements | [1,2,3], [2,3,4] | [2,3] |
| groupBy | Group array of objects by key | [{id:1},{id:2},{id:1}], "id" | {1:[{id:1},{id:1}],2:[{id:2}]} |
| compactArray | Remove falsy values | [0,1,false,2,"",3] | [1,2,3] |
| findIndexByKey | Find index by object key | [{id:1},{id:2}], "id", 2 | 1 |
| sortByKey | Sort array of objects by key | [{name:"Bob"},{name:"Alice"}], "name" | [{name:"Alice"},{name:"Bob"}] |
| mergeArrays | Merge arrays | [1,2], [3,4] | [1,2,3,4] |
| countOccurrences | Count value occurrences | [1,2,2,3], 2 | 2 |
| deepCompact | Remove falsy recursively | [0,[1,false],[null,2]] | [[1],[2]] |
| deepCopy | Deep copy object/array | [1,2] | [1,2] |
| shallowCopy | Shallow copy array/object | [1,2] | [1,2] |
| mergeUnique | Merge arrays uniquely | [1,2], [2,3] | [1,2,3] |
| hasMinItems | Check minimum items | [1,2], 2 | true |
| hasMaxItems | Check maximum items | [1,2], 3 | true |
| arrayHasObjects | Array contains object | [1,{a:1}] | true |
| arrayHasStrings | Array contains string | [1,"a"] | true |
| arrayHasNumbers | Array contains number | [1,"a"] | true |
| isEmptyArray | Check empty array | [] | true |
| isArray | Check if value is array | [1,2] | true |
3️⃣ Object Utilities
Functions for inspecting, picking, omitting, cleaning, and validating objects.
| Function | Description | Input | Output |
| --------------------- | --------------------- | ---------------------------- | ------------------- |
| objectKeyCount | Number of keys | {a:1,b:2} | 2 |
| objectKeysList | Keys as array | {a:1,b:2} | ["a","b"] |
| objectEntriesList | Entries as array | {a:1,b:2} | [["a",1],["b",2]] |
| objectValuesList | Values as array | {a:1,b:2} | [1,2] |
| hasAllKeys | Object has all keys | {a:1,b:2}, ["a","b"] | true |
| hasAnyOfKeys | Object has any key | {a:1,b:2}, ["c","b"] | true |
| hasKey | Object has key | {a:1}, "a" | true |
| safeObject | Ensure object | null | {} |
| pickKeys | Pick keys | {a:1,b:2,c:3}, ["a","c"] | {a:1,c:3} |
| omitKeys | Omit keys | {a:1,b:2,c:3}, ["b"] | {a:1,c:3} |
| removeNullishKeys | Remove null/undefined | {a:null,b:2} | {b:2} |
| removeUndefinedKeys | Remove undefined | {a:undefined,b:2} | {b:2} |
| isPlainObject | Check plain object | {} | true |
| isEmptyObject | Check empty | {} | true |
| isObject | Check object | {} | true |
4️⃣ Number Utilities
| Function | Description | Input | Output |
| -------------- | ------------------ | --------- | ------------- |
| clamp | Clamp number | 10,0,5 | 5 |
| randomInt | Random integer | 1,10 | 3 (random) |
| isEven | Check even | 4 | true |
| isOdd | Check odd | 5 | true |
| formatNumber | Format with commas | 1234567 | "1,234,567" |
5️⃣ Async Utilities
| Function | Description | Input | Output |
| ----------------- | ----------------------------- | ----------------- | --------------------------- |
| delay | Wait for ms | 1000 | Promise resolves after 1s |
| promiseAllLimit | Run promises with concurrency | [fn1, fn2], 2 | Array of results |
| retry | Retry async function | fn,3,1000 | Result or error |
6️⃣ Date Utilities
| Function | Description | Input | Output |
| -------------- | ---------------------- | --------------------------- | -------------- |
| formatDate | Format date | "2025-12-14" | "2025-12-14" |
| addDays | Add days to date | "2025-12-14",5 | "2025-12-19" |
| dateDiffDays | Difference in days | "2025-12-01","2025-12-14" | 13 |
| isToday | Check if date is today | "2025-12-14" | true/false |
7️⃣ Optimize Utilities
| Function | Description | Input | Output |
| ---------- | --------------------- | ----------- | ------------------ |
| debounce | Debounce function | (fn,500) | Debounced function |
| throttle | Throttle function | (fn,500) | Throttled function |
| memoize | Memoize function | (fn) | Cached function |
| once | Run function once | (fn) | Runs once |
| pipe | Compose left-to-right | (fn1,fn2) | Composed function |
| compose | Compose right-to-left | (fn1,fn2) | Composed function |
