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 🙏

© 2025 – Pkg Stats / Ryan Hefner

objmod

v2.1.2

Published

type-safe object editor in javascript

Readme

objmod

A lightweight and type-safe utility module for working with deeply nested object properties using dot-separated string paths in TypeScript.

Features

  • 🔍 Access deeply nested values with full TypeScript type safety.
  • 🛠️ Set, delete, and check nested values.
  • 🔁 Scan object trees and iterate over all deep paths.
  • 🧠 Type inference for path strings and returned values.
  • Caching support for faster repeated access.
  • 🧹 Functional utilities like map, filter, and foreach.

Installation

npm install objmod
npm install --save-dev @types/objmod

Or just copy and paste the module into your project as it's completely dependency-free.

Usage

Basic API

get<T, P>(obj: T, path: P, def?: V): V

Get a nested value from an object.

get({ a: { b: { c: 42 } } }, "a.b.c"); // 42

set<T, P>(obj: T, path: P, value: V): void

Set a value at a given nested path.

set(obj, "a.b.c", 100);

has<T, P>(obj: T, path: P): boolean

Check if a nested path exists.

has(obj, "a.b.c"); // true or false

del<T, P>(obj: T, path: P): boolean

Delete a deeply nested property.

del(obj, "a.b.c");

Advanced Utilities

scan<T>(obj: T): Map<string, any>

Recursively get a flat map of dot-separated paths to values.

scan({ a: { b: 1, c: { d: 2 } } });
// Map { "a.b" => 1, "a.c.d" => 2 }

foreach<T>(obj: T, cb)

Call a function for each deep key.

foreach(obj, (path, value) => console.log(path, value));

map<T>(obj: T, cb)

Transform all deep values in-place.

map(obj, (path, value) => typeof value === 'number' ? value * 2 : value);

filter<T>(obj: T, cb)

Remove entries based on a predicate.

filter(obj, (path, value) => typeof value === 'string');

merge<T, S>(target: T, source: S): T & S

Deep merge two objects.

merge({ a: 1 }, { b: { c: 2 } });
// { a: 1, b: { c: 2 } }

cache<T>(obj: T)

Create a cached interface for nested operations.

const cached = cache(myObject);
cached.get("a.b");
cached.set("x.y", 42);
cached.refresh();

Types

DeepKeyOf<T>

Recursively extracts all possible dot-separated keys in an object.

DeepValueOf<T, P>

Given a type T and a key path P, returns the type at that path.

Example

type Data = {
  user: {
    name: string;
    preferences: {
      theme: string;
    };
  };
};

type Keys = DeepKeyOf<Data>; // "user.name" | "user.preferences.theme"
type ThemeType = DeepValueOf<Data, "user.preferences.theme">; // string

License

MIT © 2025 Mahdi Najafzadeh