Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

dot-prop

Package Overview
Dependencies
Maintainers
1
Versions
29
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dot-prop

Get, set, or delete a property from a nested object using a dot path

  • 9.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
20M
decreased by-3.61%
Maintainers
1
Weekly downloads
 
Created

What is dot-prop?

The dot-prop npm package allows for getting, setting, and deleting properties from objects using dot-path notation. This can be particularly useful for accessing deeply nested properties without having to check each level of the object structure.

What are dot-prop's main functionalities?

Get a property

Retrieve a property from an object by specifying its path as a string.

const dotProp = require('dot-prop');
const object = {foo: {bar: 'a'}};
console.log(dotProp.get(object, 'foo.bar')); //=> 'a'

Set a property

Set a property on an object at a specified path, creating any necessary objects along the path.

const dotProp = require('dot-prop');
let object = {foo: {bar: 'a'}};
dotProp.set(object, 'foo.bar', 'b');
console.log(object.foo.bar); //=> 'b'

Delete a property

Delete a property from an object at a specified path.

const dotProp = require('dot-prop');
let object = {foo: {bar: 'a'}};
dotProp.delete(object, 'foo.bar');
console.log(object); //=> { foo: {} }

Check if an object has a property

Check if an object has a property at a specified path.

const dotProp = require('dot-prop');
const object = {foo: {bar: 'a'}};
console.log(dotProp.has(object, 'foo.bar')); //=> true

Other packages similar to dot-prop

Keywords

FAQs

Package last updated on 09 May 2024

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