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

property-expr

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

property-expr

tiny util for getting and setting deep object props safely

  • 2.0.0
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created

What is property-expr?

The property-expr package is a utility for working with property paths. It allows for accessing and manipulating properties on objects using string paths. It's particularly useful for operations like getting or setting nested properties without having to manually check each level of the object structure.

What are property-expr's main functionalities?

Accessing Nested Properties

This feature allows you to access deeply nested properties within an object using a string path. It's useful for retrieving values without having to write verbose and error-prone code to navigate object structures.

"var propertyExpr = require('property-expr');\nvar obj = { some: { nested: { property: 'value' } } };\nvar value = propertyExpr.getter('some.nested.property')(obj); // 'value'"

Setting Nested Properties

This feature enables setting the value of a deeply nested property by specifying its path as a string. It simplifies the process of modifying nested structures without manually traversing them.

"var propertyExpr = require('property-expr');\nvar obj = {};\npropertyExpr.setter('some.nested.property')(obj, 'new value');\nconsole.log(obj.some.nested.property); // 'new value'"

Compiling Expressions

Compiles a string path into a function that can be used to access or evaluate the specified property path on an object. This is useful for scenarios where the property path needs to be dynamically evaluated multiple times.

"var propertyExpr = require('property-expr');\nvar expr = propertyExpr.compile('some.nested.property');\nconsole.log(expr({ some: { nested: { property: 'value' } } })); // 'value'"

Other packages similar to property-expr

Keywords

FAQs

Package last updated on 05 Mar 2020

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