npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

deep-merge-lite-ts

v1.0.0

Published

Fast, zero-dependency, prototype-pollution safe deep object merger with configurable array strategies.

Readme

🔀 deep-merge-lite-ts

Ultra-fast, zero-dependency, prototype-pollution safe deep object merger with configurable array strategies and TypeScript generics.

npm version License: MIT Sponsor TypeScript Bundle Size


💡 Why deep-merge-lite-ts?

Merging JavaScript objects is ubiquitous, but popular utilities often bring major downsides:

  • Object.assign() and spread syntax ({ ...a, ...b }) are shallow, accidentally replacing entire nested configurations.
  • Popular libraries like lodash.merge or heavy merge packages weigh 20 KB+ and frequently suffer from prototype pollution security vulnerabilities.

deep-merge-lite-ts provides:

  • ⚡ Zero Dependencies — Pure native TypeScript, minified to under 1.2 KB.
  • 🛡️ Prototype Pollution Protection — Blocks __proto__, constructor, and prototype property injections out of the box.
  • 🎛️ Configurable Array Strategies — Easily toggle between replace, concat, and deduplicated union.
  • 🧬 Non-Mutating Deep Cloning — Deep clones nested structures, Dates, and RegExps so your original input objects stay untouched.
  • 📦 Dual ESM & CommonJS — Compatible with Node.js, Next.js, Vite, Remix, React Native, and browsers.

📥 Installation

# npm
npm install deep-merge-lite-ts

# pnpm
pnpm add deep-merge-lite-ts

# yarn
yarn add deep-merge-lite-ts

# bun
bun add deep-merge-lite-ts

🚀 Usage & Real-World Examples

1. Basic Deep Merge

import { deepMerge } from 'deep-merge-lite-ts';

const defaultSettings = {
  theme: 'dark',
  server: {
    host: 'localhost',
    port: 3000,
  },
  logging: {
    level: 'info',
    colorize: true,
  },
};

const userSettings = {
  server: {
    port: 8080, // Overrides port without losing host!
  },
  logging: {
    level: 'debug',
  },
};

const config = deepMerge(defaultSettings, userSettings);
console.log(config);
// Output:
// {
//   theme: 'dark',
//   server: { host: 'localhost', port: 8080 },
//   logging: { level: 'debug', colorize: true }
// }

2. Configurable Array Merging (Union & Concat)

By default, arrays are replaced. Use createMerger() to concatenate or deduplicate arrays:

import { createMerger } from 'deep-merge-lite-ts';

const baseConfig = { roles: ['viewer', 'editor'], permissions: [1, 2] };
const adminConfig = { roles: ['admin', 'editor'], permissions: [3] };

// Deduplicate arrays with 'union'
const unionMerge = createMerger({ arrayMerge: 'union' });
const result = unionMerge(baseConfig, adminConfig);

console.log(result.roles);
// ['viewer', 'editor', 'admin'] (no duplicate 'editor')

// Concatenate all items with 'concat'
const concatMerge = createMerger({ arrayMerge: 'concat' });
console.log(concatMerge(baseConfig, adminConfig).roles);
// ['viewer', 'editor', 'admin', 'editor']

3. Merging Multiple Objects in Sequence

import { deepMerge } from 'deep-merge-lite-ts';

const envDefaults = { env: 'development', debug: true };
const fileConfig = { debug: false, db: 'sqlite' };
const cliOverrides = { db: 'postgres' };

const finalAppConfig = deepMerge(envDefaults, fileConfig, cliOverrides);
console.log(finalAppConfig);
// { env: 'development', debug: false, db: 'postgres' }

📖 API Reference

deepMerge(target, ...sources)

Deeply merges multiple source objects into a cloned target object.

  • Parameters:
    • target (Record<string, any>): The initial object.
    • ...sources (Record<string, any>[]): One or more objects to merge over target.
  • Returns: Cloned, deeply merged object.

createMerger(options)

Factory creating a configured merge function.

Options (MergeOptions):

| Option | Type | Default | Description | |---|---|---|---| | arrayMerge | 'replace' \| 'concat' \| 'union' | 'replace' | Array merge algorithm | | clone | boolean | true | Deep clone nested objects/arrays to prevent mutations |


🛡️ Security: Prototype Pollution Guard

deep-merge-lite-ts guards against malicious property injections:

const maliciousPayload = JSON.parse('{"__proto__": {"isAdmin": true}}');
deepMerge({}, maliciousPayload);

console.log(({} as any).isAdmin); // undefined (safe!)

💖 Support the Project

If deep-merge-lite-ts keeps your data structures tidy and safe, please support continued development:

👉 Sponsor @Piratha97 on GitHub Sponsors


📄 License

MIT © 2026 Pirapaakaran Pirathapan