Socket
Socket
Sign inDemoInstall

dot-component

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dot-component

MongoDB-style "dot notation" querying for JavaScript.


Version published
Weekly downloads
356
increased by15.96%
Maintainers
1
Weekly downloads
 
Created
Source

dot

MongoDB-style "dot notation" querying for JavaScript.

Installation

$ component install component/dot

Example

var dot = require('dot');
var obj = {
  name: {
    first: "tobi"
  },
  pets: [
    { id: 1, name: 'loki' },
    { id: 2, name: 'jane' }
  ]
};

dot.get(obj, 'name.first'); // tobi
dot.get(obj, 'name.1.id'); // 2
dot.parent(obj, 'name.first'); // obj.name
dot.set(obj, 'name.1.name', 'Jane');

API

get(obj, path)

Queries the given path in obj.

set(obj, path, val, init)

Sets the given path to val in obj. If init is false it won't initialize the path if it doesn't exit.

parent(obj, path, init)

Returns the parent object/array that contains path within obj. Could be obj itself. If init is true it initializes the path.

License

MIT

Keywords

FAQs

Package last updated on 27 Jan 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