Socket
Socket
Sign inDemoInstall

to-object-path

Package Overview
Dependencies
2
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

to-object-path

Create an object path from a list or array of strings.


Version published
Maintainers
1
Weekly downloads
12,145,524
decreased by-1.08%
Bundle size
721 bytes
Minified + gzipped

Weekly downloads

Package description

What is to-object-path?

The 'to-object-path' npm package is designed to convert strings or arrays into a normalized dot-property path. This is particularly useful for accessing nested properties within an object in a dynamic and string-based manner. It simplifies the process of dealing with deeply nested object structures by providing a straightforward way to generate paths that can be used with other libraries to get or set nested values.

What are to-object-path's main functionalities?

String to Object Path Conversion

Converts a string path into a normalized dot-property path. This is useful for accessing nested properties within an object using a string path.

"user.info.name.first"

Array to Object Path Conversion

Converts an array of strings representing a path into a normalized dot-property path. This allows for dynamic path creation based on variable parts.

["user", "info", "name", "first"]

Other packages similar to to-object-path

Readme

Source

to-object-path NPM version

Create an object path from a list or array of strings.

Install

Install with npm

$ npm i to-object-path --save

Usage

var toPath = require('to-object-path');

toPath('foo', 'bar', 'baz');
toPath('foo', ['bar', 'baz']);
//=> 'foo.bar.baz'

Also supports passing an arguments object (without having to slice args):

function foo()
  return toPath(arguments);
}

foo('foo', 'bar', 'baz');
foo('foo', ['bar', 'baz']);
//=> 'foo.bar.baz'

Visit the example to see how this could be used in an application.

  • get-value: Use property paths ( a.b.c) to get a nested value from an object. | homepage
  • has-value: Returns true if a value exists, false if empty. Works with deeply nested values using… more | homepage
  • omit-value: Omit properties from an object or deeply nested property of an object using object path… more | homepage
  • set-value: Create nested values and any intermediaries using dot notation ('a.b.c') paths. | homepage
  • unset-value: Delete nested properties from an object using dot notation. | homepage

Running tests

Install dev dependencies:

$ npm i -d && npm test

Contributing

Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.

Author

Jon Schlinkert

License

Copyright © 2015 Jon Schlinkert Released under the MIT license.


This file was generated by verb-cli on October 28, 2015.

Keywords

FAQs

Last updated on 31 Jan 2016

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc