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

mpath

Package Overview
Dependencies
Maintainers
2
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mpath

{G,S}et object values using MongoDB-like path notation

  • 0.9.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1.6M
decreased by-30.29%
Maintainers
2
Weekly downloads
 
Created

What is mpath?

The mpath npm package is a utility for getting and setting values of nested properties in JavaScript objects using dot notation or array paths. It is particularly useful for manipulating deeply nested objects without having to write complex and repetitive code.

What are mpath's main functionalities?

Get Value

This feature allows you to retrieve the value of a nested property within an object using a dot notation path.

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

Set Value

This feature allows you to set the value of a nested property within an object using a dot notation path.

const mpath = require('mpath');
const obj = { a: { b: { c: 42 } } };
mpath.set('a.b.c', 100, obj);
console.log(obj.a.b.c); // 100

Unset Value

This feature allows you to unset (delete) a nested property within an object using a dot notation path.

const mpath = require('mpath');
const obj = { a: { b: { c: 42 } } };
mpath.unset('a.b.c', obj);
console.log(obj.a.b.c); // undefined

Has Value

This feature allows you to check if a nested property exists within an object using a dot notation path.

const mpath = require('mpath');
const obj = { a: { b: { c: 42 } } };
const hasValue = mpath.has('a.b.c', obj);
console.log(hasValue); // true

Other packages similar to mpath

Keywords

FAQs

Package last updated on 17 Apr 2022

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