JSPM

@basekits/kit-object

1.0.1
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 4
  • Score
    100M100P100Q32101F
  • License MIT

Object type helpers kit for basekits.

Package Exports

  • @basekits/kit-object

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@basekits/kit-object) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

@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.