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

obj-lib

v1.0.3

Published

A lightweight zero-dependency object utility library

Downloads

9

Readme

obj-lib - Zero-Dependency Object Utility Library

A lightweight, zero-dependency object utility library for Node.js and the browser.

npm version npm downloads Bundle Size License: MIT GitHub Types

Features

  • Zero dependencies: Keeps your project light.
  • TypeScript support: Built with TypeScript for full type safety.
  • Common utilities: deepClone, deepMerge, get, set, pick, omit, and more.

Installation

Install using your preferred package manager:

npm

npm install obj-lib

Yarn

yarn add obj-lib

pnpm

pnpm add obj-lib

Usage

Import the functions you need from the package:

import { deepClone, get, set, deepMerge } from 'obj-lib';

// Deep Clone
const original = { a: 1, b: { c: 2 } };
const copy = deepClone(original);
console.log(copy); // { a: 1, b: { c: 2 } }

// Get
const obj = { a: { b: { c: 3 } } };
const value = get(obj, 'a.b.c');
console.log(value); // 3

// Set
const target = {};
set(target, 'x.y.z', 42);
console.log(target); // { x: { y: { z: 42 } } }

// Deep Merge
const obj1 = { a: 1, b: { x: 1 } };
const obj2 = { b: { y: 2 }, c: 3 };
const merged = deepMerge(obj1, obj2);
console.log(merged); // { a: 1, b: { x: 1, y: 2 }, c: 3 }

API Reference

clean<T>(obj: T): T

  • Removes undefined keys from an object recursively.

diff(obj1: any, obj2: any): Record<string, any>

  • Returns a difference object showing keys that have changed between two objects.

flatten(obj: any, prefix?: string): Record<string, any>

  • Flattens a nested object into a single level object with dot-separated keys.

unflatten(flatObj: Record<string, any>): any

  • Unflattens a dot-separated key object back into a nested object.

keysToCamel(obj: any): any

  • Recursively transforms object keys to camelCase.

keysToSnake(obj: any): any

  • Recursively transforms object keys to snake_case.

freeze<T>(obj: T): T

  • Deeply freezes an object to make it immutable.

trimStrings(obj: any): any

  • Recursively trims all string values in an object.

update<T>(obj: T, patch: Partial<T>): T

  • Returns a new object with the patch applied (shallow merge), like Redux.

isNullOrUndefined(value: any): boolean

  • Checks if a value is null or undefined.

isPrimitive(value: any): boolean

  • Checks if a value is a primitive (not object or function, includes null).

deepClone<T>(value: T): T

  • Creates a deep copy of a value. Handles objects, arrays, Dates, and RegExps.

clone<T>(value: T): T

  • Fast deep clone using JSON.parse(JSON.stringify(value)). Note: Does not handle Dates or RegExps correctly.

deepMerge<T, U>(target: T, source: U): T & U

  • Deeply merges two objects. Arrays and other non-mergable types are overwritten.

get(obj: any, path: string | string[], defaultValue?: any): any

  • Gets a value from an object at a specific path. Path can be a dot-separated string or an array of keys.

set(obj: any, path: string | string[], value: any): void

  • Sets a value on an object at a specific path. Creates nested objects/arrays as needed.

pick<T, K>(obj: T, keys: K[]): Pick<T, K>

  • Creates an object composed of the picked object properties.

omit<T, K>(obj: T, keys: K[]): Omit<T, K>

  • Creates an object composed of the object properties not omitted.

has(obj: any, path: string | string[]): boolean

  • Checks if a path exists in an object.

isEmpty(value: any): boolean

  • Checks if a value is an empty object, array, or string.

isEqual(a: any, b: any): boolean

  • Performs a deep comparison between two values.

isObject(value: any): boolean

  • Checks if a value is a plain object.

Contributing

See CONTRIBUTING.md for details.

License

This project is licensed under the MIT License - see the LICENSE file for details.