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
Markdown
# clean-object-keys
๐งน A tiny JavaScript utility to remove `null`, `undefined`, and `""` (empty string) values from an object.



## ๐ฆ 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!