Socket
Socket
Sign inDemoInstall

@basekits/kit-object

Package Overview
Dependencies
0
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @basekits/kit-object

Object type helpers kit for basekits.


Version published
Maintainers
1
Install size
6.89 kB
Created

Readme

Source

@basekits/kit-object

Object type helpers kit for basekits.

Install

npm i @basekits/kit-type @basekits/kit-object

Usage

const kit = require('@basekits/core')
const type = require('@basekits/kit-type')
const object = require('@basekits/kit-object')
kit.addKit(type)
kit.addKit(object)

Available Items

The following methods will be available after adding this kit:

.getProp(obj, path, defaultValue = undefined)

Returns the value of the property specified in path inside an object obj. The defaultValue will be returned if obj doesn't have a such path.

const obj = {
  name: 'Murat',
  address: {
    country: 'TR'
  }
}
kit.getProp(obj, 'name') // returns 'Murat'
kit.getProp(obj, ['address', 'country']) // returns 'TR'
kit.getProp(obj, 'nonExistingProp', 'none') // returns 'none'

.removeProp(obj, prop)

Returns a new object by removing its prop property. Returns input object if it doesn't have a prop or returns undefined if obj is not an object.


Keywords

FAQs

Last updated on 20 Jan 2020

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