New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

object-pruner

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

object-pruner

A TypeScript utility for deeply pruning objects.

latest
Source
npmnpm
Version
1.0.4
Version published
Maintainers
1
Created
Source

Object Pruner

🚀 A powerful TypeScript utility and CLI tool to deeply prune JavaScript/JSON objects — removing null, undefined, empty strings, arrays, and objects — with full customization.

🔧 Features

  • ✅ Deep recursive pruning
  • ✅ Selective pruning (null, undefined, "", {}, [])
  • ✅ Returns both cleaned object and pruned values
  • ✅ Fully typed for TypeScript projects
  • ✅ CLI support with advanced flags
  • ✅ Unit tested using Vitest

📦 Installation

Local (as a module)

npm install /path/to/object-pruner

📥 Usage (Code)

import { ObjectPruner } from 'object-pruner';

const input = {
  name: "",
  age: null,
  email: "john@example.com",
  details: {
    bio: "",
    hobbies: [],
    preferences: {
      theme: "dark",
      language: ""
    }
  }
};

const pruner = new ObjectPruner({ returnPrunedValues: true });
const result = pruner.prune(input);

console.log(result.cleaned);
console.log(result.pruned);

🖥 CLI Usage

Basic

node dist/cli.js test.json

With Flags

node dist/cli.js test.json --only null,undefined,emptyArray --dry-run

Flags

FlagDescription
--onlyPrune specific types: null,undefined,emptyArray
--dry-runDo not overwrite the original file

🧪 Running Tests

npm install
npm run build
npm run test

📁 Folder Structure

src/
  index.ts
  cli.ts
  core/
    Pruner.ts
    types.ts
    utils.ts
tests/
  pruner.test.ts

🧠 Author

Made with ❤️ by Ritik Pal

📄 License

MIT

Keywords

typescript

FAQs

Package last updated on 24 Jul 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts