utilifyx is a compact, dependency-free utility library offering powerful helpers for:
- Objects
- Arrays
- Strings
- Async utilities
- Date utilities
- Validation
It is designed to be:
- Lightweight (~4 KB gzipped)
- Tree-shakable
- Fully typed (TypeScript)
- ESM-native
- Faster and smaller than Lodash
| Feature | utilifyx | lodash |
|---|---|---|
| Install size | 7.6 kB | ~1.4 MB |
| Bundle size (gzipped) | ~4 KB | ~72 KB |
| Tree-shaking | ✔ Yes | ❌ No |
| Zero dependencies | ✔ Yes | ❌ No |
| TypeScript types | ✔ Built-in | ✔ Yes |
| ESM support | ✔ Native | ❌ Legacy |
npm install utilifyxor:
yarn add utilifyximport { deepClone, groupBy, toCamelCase, debounce } from "utilifyx";
const obj = { a: { b: 1 } };
console.log(deepClone(obj));
const items = [
{ category: "fruit", name: "Apple" },
{ category: "fruit", name: "Banana" },
{ category: "veg", name: "Carrot" }
];
console.log(groupBy(items, "category"));
console.log(toCamelCase("hello_world")); // helloWorld
const fn = debounce(() => console.log("Run!"), 300);
fn();Below is the full API with practical, real-world examples.
import { deepClone } from "utilifyx";
const user = { name: "Alex", address: { city: "NY", zip: 12345 } };
const cloned = deepClone(user);
cloned.address.city = "LA";
console.log(user.address.city); // NYimport { deepMerge } from "utilifyx";
const a = { user: { name: "Alex" }, roles: ["admin"] };
const b = { user: { age: 25 }, roles: ["editor"] };
console.log(deepMerge(a, b));
// { user: { name: "Alex", age: 25 }, roles: ["admin", "editor"] }import { get } from "utilifyx";
const obj = { user: { profile: { age: 30 } } };
console.log(get(obj, "user.profile.age")); // 30
console.log(get(obj, "user.address.city", "unknown")); // "unknown"import { set } from "utilifyx";
const obj = {};
set(obj, "user.profile.age", 30);
console.log(obj);
// { user: { profile: { age: 30 } } }import { isEqual } from "utilifyx";
console.log(isEqual({ a: 1 }, { a: 1 })); // true
console.log(isEqual({ a: 1 }, { a: 2 })); // falseimport { omit } from "utilifyx";
const user = { id: 1, name: "Alex", password: "secret" };
console.log(omit(user, ["password"]));
// { id: 1, name: "Alex" }import { pick } from "utilifyx";
const user = { id: 1, name: "Alex", email: "a@mail.com" };
console.log(pick(user, ["name", "email"]));
// { name: "Alex", email: "a@mail.com" }import { removeEmptyValues } from "utilifyx";
const data = { name: "Alex", age: null, city: undefined };
console.log(removeEmptyValues(data));
// { name: "Alex" }import { shallowClone } from "utilifyx";
const obj = { a: 1, b: 2 };
console.log(shallowClone(obj));
// { a: 1, b: 2 }import { uniqueBy } from "utilifyx";
const items = [
{ id: 1, name: "A" },
{ id: 1, name: "A" },
{ id: 2, name: "B" }
];
console.log(uniqueBy(items, "id"));
// [{ id: 1, name: "A" }, { id: 2, name: "B" }]import { groupBy } from "utilifyx";
const items = [
{ category: "fruit", name: "Apple" },
{ category: "veg", name: "Carrot" },
{ category: "fruit", name: "Banana" }
];
console.log(groupBy(items, "category"));
// { fruit: [...], veg: [...] }import { sortBy } from "utilifyx";
const users = [
{ name: "Alex", age: 30 },
{ name: "Ben", age: 20 }
];
console.log(sortBy(users, "age"));
// [ { name: "Ben", age: 20 }, { name: "Alex", age: 30 } ]import { flatten } from "utilifyx";
console.log(flatten([1, [2, [3, 4]]]));
// [1, 2, 3, 4]import { arrayToMap } from "utilifyx";
const list = [
{ id: 1, name: "A" },
{ id: 2, name: "B" }
];
console.log(arrayToMap(list, "id"));
// { 1: {...}, 2: {...} }import { toCamelCase } from "utilifyx";
console.log(toCamelCase("hello_world")); // helloWorld
console.log(toCamelCase("my-name-is")); // myNameIsimport { toSnakeCase } from "utilifyx";
console.log(toSnakeCase("HelloWorld")); // hello_world
console.log(toSnakeCase("myNameIs")); // my_name_isimport { toKebabCase } from "utilifyx";
console.log(toKebabCase("HelloWorld")); // hello-worldimport { debounce } from "utilifyx";
const log = debounce(() => console.log("Run!"), 500);
log();
log();
// Only runs once after 500msimport { throttle } from "utilifyx";
const run = throttle(() => console.log("Fired!"), 1000);
run();
run();
// Only fires once per secondimport { memoize } from "utilifyx";
const slowAdd = (a, b) => a + b;
const fastAdd = memoize(slowAdd);
console.log(fastAdd(2, 3)); // calculated
console.log(fastAdd(2, 3)); // cachedimport { formatDate } from "utilifyx";
console.log(formatDate(new Date(), "en-US"));
// e.g., "12/10/2025"import { parseDate } from "utilifyx";
console.log(parseDate("2025-12-10"));
// returns Date objectimport { addDays } from "utilifyx";
console.log(addDays(new Date("2025-01-01"), 10));
// Jan 11, 2025import { diffDays } from "utilifyx";
console.log(diffDays("2025-01-10", "2025-01-01"));
// 9import { validateEmail } from "utilifyx";
console.log(validateEmail("test@gmail.com")); // true
console.log(validateEmail("x@y")); // falseimport { validatePhone } from "utilifyx";
console.log(validatePhone("9876543210")); // true
console.log(validatePhone("12345")); // falseimport { isEmpty } from "utilifyx";
console.log(isEmpty("")); // true
console.log(isEmpty([])); // true
console.log(isEmpty({})); // true
console.log(isEmpty("text")); // falseimport { isNumeric } from "utilifyx";
console.log(isNumeric("123")); // true
console.log(isNumeric("A12")); // falsenpm testThis runs all Jest test suites with coverage.
npm run buildOutput files will be generated inside:
dist/
Contributions are welcome!
- Fork the repository
- Create a feature branch
- Add your changes + tests
- Submit a Pull Request
This project is licensed under the MIT License.
If utilifyx helps you, please:
- ⭐ Star the GitHub repository
- ⭐ Star the package on npm
- Share it with your developer community
Your support helps the project grow!