UNPKG

clean-object-keys

Version:

A tiny JavaScript utility to remove null, undefined, and empty string values from objects. Lightweight and supports nested objects.

59 lines (43 loc) โ€ข 1.27 kB
# clean-object-keys ๐Ÿงน A tiny JavaScript utility to remove `null`, `undefined`, and `""` (empty string) values from an object. ![NPM Version](https://img.shields.io/npm/v/clean-object-keys.svg) ![Downloads](https://img.shields.io/npm/dt/clean-object-keys.svg) ![License](https://img.shields.io/npm/l/clean-object-keys.svg) ## ๐Ÿ“ฆ Installation ```bash npm install clean-object-keys ``` ### โœ… 3. Why Use This? ```markdown โœ… Clean API request payloads โœ… Sanitize form data or configs โœ… Remove empty/invalid values easily โœ… Supports nested objects โœ… 100% lightweight (no dependencies) ``` ### โžค Basic Example ``` const { cleanObject } = require("clean-object-keys"); const data = { name: "Manu", email: "", phone: undefined, age: null, country: "India", }; const cleaned = cleanObject(data); console.log(cleaned); // Output: { name: 'Manu', country: 'India' } ``` ## ๐Ÿ“ Folder Structure ``` clean-object-keys/ โ”œโ”€โ”€ src/ โ”‚ โ””โ”€โ”€ index.js # Core function โ”œโ”€โ”€ test/ โ”‚ โ””โ”€โ”€ index.test.js # Test file โ”œโ”€โ”€ package.json โ”œโ”€โ”€ README.md โ””โ”€โ”€ .gitignore ``` > โšก Made by Manu Kumar Pal โ€” feel free to contribute, star โญ, or share!