Socket
Socket
Sign inDemoInstall

dot-object

Package Overview
Dependencies
Maintainers
1
Versions
40
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dot-object

dot-object makes it possible to transform and read (JSON) objects using dot notation.


Version published
Weekly downloads
228K
decreased by-40.12%
Maintainers
1
Weekly downloads
 
Created

What is dot-object?

The dot-object npm package is a utility for transforming and manipulating JavaScript objects using dot notation. It allows you to easily convert between nested objects and flat objects, set and get values using dot notation, and remove properties from objects.

What are dot-object's main functionalities?

Flattening Objects

This feature allows you to convert a nested object into a flat object using dot notation. The code sample demonstrates how to flatten a nested object.

const Dot = require('dot-object');
const dot = new Dot();
const nested = { a: { b: { c: 1 } } };
const flattened = dot.dot(nested);
console.log(flattened); // { 'a.b.c': 1 }

Unflattening Objects

This feature allows you to convert a flat object with dot notation keys back into a nested object. The code sample demonstrates how to unflatten a flat object.

const Dot = require('dot-object');
const dot = new Dot();
const flattened = { 'a.b.c': 1 };
const nested = dot.object(flattened);
console.log(nested); // { a: { b: { c: 1 } } }

Setting Values

This feature allows you to set a value in an object using dot notation. The code sample demonstrates how to set a nested value in an object.

const Dot = require('dot-object');
const dot = new Dot();
const obj = {};
dot.set('a.b.c', 1, obj);
console.log(obj); // { a: { b: { c: 1 } } }

Getting Values

This feature allows you to get a value from an object using dot notation. The code sample demonstrates how to retrieve a nested value from an object.

const Dot = require('dot-object');
const dot = new Dot();
const obj = { a: { b: { c: 1 } } };
const value = dot.pick('a.b.c', obj);
console.log(value); // 1

Removing Properties

This feature allows you to remove a property from an object using dot notation. The code sample demonstrates how to delete a nested property from an object.

const Dot = require('dot-object');
const dot = new Dot();
const obj = { a: { b: { c: 1 } } };
dot.del('a.b.c', obj);
console.log(obj); // { a: { b: {} } }

Other packages similar to dot-object

Keywords

FAQs

Package last updated on 15 Dec 2014

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc