Socket
Socket
Sign inDemoInstall

oprop

Package Overview
Dependencies
0
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    oprop

Extends Object type to have hasProperty and getProperty methods


Version published
Maintainers
1
Install size
3.08 kB
Created

Readme

Source

Oprop

Simple package that extends Javascript's Object object to have these helper functions. See the docs: oprop.ramseydsilva.com

hasProperty

Returns true or false

require('oprop');

myobj = {a: {b: {c: 1}}};

myobj.hasProperty('a'); // true
myobj.hasProperty('a.b.c'); // true
myobj.hasProperty('b.c'); // false
myobj.hasProperty('a.b.c.d'); // false

getProperty

Returns the object's property else undefined

require('oprop');

myobj = {a: {b: {c: 1}}};

myobj.getProperty('a'); // {b: {c: 1}}
myobj.getProperty('a.b.c'); // 1
myobj.getProperty('b.c'); // undefined
myobj.getProperty('a.b.c.d'); // undefined

Testing

npm test

OMG IT EXTENDS OBJECT???!?!@

Yes, yes it does, with a single getters for each method, and no it won't break your code, because it does this properly with a non-enumerable property.

Keywords

FAQs

Last updated on 10 Apr 2014

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