New:Introducing Socket Scanning for VS Code Marketplace Extensions.Learn more →
Get Started

nested-obj

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nested-obj

Safely access and modify nested object properties using string paths

latest
Source
npmnpm
Version
0.2.3
Version published
Weekly downloads
288K
-27.79%
Maintainers
1
Weekly downloads
 
Created
Source

nested-obj

nested-obj is a simple and lightweight JavaScript utility library for safely accessing and modifying nested properties in objects using string paths.

Features

  • Get: Safely access nested properties in an object.
  • Set: Set a value at a specific path in an object. Does not overwrite if the value is undefined.
  • Has: Check if a specific path exists within an object.

Installation

npm install nested-obj

Usage

Get

Retrieve a nested property value from an object.

import objectPath from 'nested-obj';

const obj = {
  user: {
    name: 'John Doe',
    address: {
      street: '123 Main St',
      city: 'Anytown'
    }
  }
};

const userName = objectPath.get(obj, 'user.name');
console.log(userName); // 'John Doe'

Set

Set a value at a specific path in an object. If any part of the path does not exist, it will be created.

objectPath.set(obj, 'user.address.zip', '12345');
console.log(obj.user.address.zip); // '12345'

Has

Check if a path exists within an object.

const hasCity = objectPath.has(obj, 'user.address.city');
console.log(hasCity); // true

Running Tests

To run tests, execute the following command:

npm test

or for continuous

npm test:watch

Development

Setup

  • Clone the repository:
git clone https://github.com/constructive-io/dev-utils.git
  • Install dependencies:
cd dev-utils
pnpm install
pnpm build
  • Test the package of interest:
cd packages/<packagename>
pnpm test:watch

Credits

🛠 Built by the Constructive team — creators of modular Postgres tooling for secure, composable backends. If you like our work, contribute on GitHub.

Disclaimer

AS DESCRIBED IN THE LICENSES, THE SOFTWARE IS PROVIDED "AS IS", AT YOUR OWN RISK, AND WITHOUT WARRANTIES OF ANY KIND.

No developer or entity involved in creating this software will be liable for any claims or damages whatsoever associated with your use, inability to use, or your interaction with other users of the code, including any direct, indirect, incidental, special, exemplary, punitive or consequential damages, or loss of profits, cryptocurrencies, tokens, or anything else of value.

FAQs

Package last updated on 31 Jul 2026

Related posts