Skip to content

ashishingle29/utilifyx

Repository files navigation


📦 utilifyx

A modern, lightweight utility toolkit for JavaScript & TypeScript

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

🚀 Why utilifyx?

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

📥 Installation

npm install utilifyx

or:

yarn add utilifyx

🔧 Quick Start Example

import { 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();

📚 API Reference

Below is the full API with practical, real-world examples.


🟦 OBJECT UTILITIES

1️⃣ deepClone

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);  // NY

2️⃣ deepMerge

import { 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"] }

3️⃣ get

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"

4️⃣ set

import { set } from "utilifyx";

const obj = {};

set(obj, "user.profile.age", 30);

console.log(obj);
// { user: { profile: { age: 30 } } }

5️⃣ isEqual

import { isEqual } from "utilifyx";

console.log(isEqual({ a: 1 }, { a: 1 })); // true
console.log(isEqual({ a: 1 }, { a: 2 })); // false

6️⃣ omit

import { omit } from "utilifyx";

const user = { id: 1, name: "Alex", password: "secret" };

console.log(omit(user, ["password"]));
// { id: 1, name: "Alex" }

7️⃣ pick

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" }

8️⃣ removeEmptyValues

import { removeEmptyValues } from "utilifyx";

const data = { name: "Alex", age: null, city: undefined };

console.log(removeEmptyValues(data));
// { name: "Alex" }

9️⃣ shallowClone

import { shallowClone } from "utilifyx";

const obj = { a: 1, b: 2 };
console.log(shallowClone(obj));
// { a: 1, b: 2 }

🟩 ARRAY UTILITIES

1️⃣ uniqueBy

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" }]

2️⃣ groupBy

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: [...] }

3️⃣ sortBy

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 } ]

4️⃣ flatten

import { flatten } from "utilifyx";

console.log(flatten([1, [2, [3, 4]]])); 
// [1, 2, 3, 4]

5️⃣ arrayToMap

import { arrayToMap } from "utilifyx";

const list = [
  { id: 1, name: "A" },
  { id: 2, name: "B" }
];

console.log(arrayToMap(list, "id"));
// { 1: {...}, 2: {...} }

🟧 STRING UTILITIES

1️⃣ toCamelCase

import { toCamelCase } from "utilifyx";

console.log(toCamelCase("hello_world")); // helloWorld
console.log(toCamelCase("my-name-is"));  // myNameIs

2️⃣ toSnakeCase

import { toSnakeCase } from "utilifyx";

console.log(toSnakeCase("HelloWorld")); // hello_world
console.log(toSnakeCase("myNameIs"));   // my_name_is

3️⃣ toKebabCase

import { toKebabCase } from "utilifyx";

console.log(toKebabCase("HelloWorld")); // hello-world

🟨 ASYNC UTILITIES

1️⃣ debounce

import { debounce } from "utilifyx";

const log = debounce(() => console.log("Run!"), 500);

log();
log();
// Only runs once after 500ms

2️⃣ throttle

import { throttle } from "utilifyx";

const run = throttle(() => console.log("Fired!"), 1000);

run();
run();
// Only fires once per second

3️⃣ memoize

import { memoize } from "utilifyx";

const slowAdd = (a, b) => a + b;
const fastAdd = memoize(slowAdd);

console.log(fastAdd(2, 3)); // calculated
console.log(fastAdd(2, 3)); // cached

🟫 DATE UTILITIES

1️⃣ formatDate

import { formatDate } from "utilifyx";

console.log(formatDate(new Date(), "en-US"));
// e.g., "12/10/2025"

2️⃣ parseDate

import { parseDate } from "utilifyx";

console.log(parseDate("2025-12-10"));
// returns Date object

3️⃣ addDays

import { addDays } from "utilifyx";

console.log(addDays(new Date("2025-01-01"), 10));
// Jan 11, 2025

4️⃣ diffDays

import { diffDays } from "utilifyx";

console.log(diffDays("2025-01-10", "2025-01-01"));
// 9

🟪 VALIDATION UTILITIES

1️⃣ validateEmail

import { validateEmail } from "utilifyx";

console.log(validateEmail("test@gmail.com")); // true
console.log(validateEmail("x@y")); // false

2️⃣ validatePhone

import { validatePhone } from "utilifyx";

console.log(validatePhone("9876543210")); // true
console.log(validatePhone("12345")); // false

3️⃣ isEmpty

import { isEmpty } from "utilifyx";

console.log(isEmpty(""));      // true
console.log(isEmpty([]));      // true
console.log(isEmpty({}));      // true
console.log(isEmpty("text"));  // false

4️⃣ isNumeric

import { isNumeric } from "utilifyx";

console.log(isNumeric("123")); // true
console.log(isNumeric("A12")); // false

🧪 Running Tests

npm test

This runs all Jest test suites with coverage.


🏗 Building the Package

npm run build

Output files will be generated inside:

dist/

🤝 Contributing

Contributions are welcome!

  1. Fork the repository
  2. Create a feature branch
  3. Add your changes + tests
  4. Submit a Pull Request

📄 License

This project is licensed under the MIT License.


⭐ Support the Project

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!

About

A modern, lightweight utility toolkit for JavaScript & TypeScript.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors