Skip to content

A simple way to check if an object has the specified key. Great to prevent app errors!

License

Notifications You must be signed in to change notification settings

yavisht/has-key

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

38 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Release GitHub release (latest SemVer) semantic-release

HasKey - Does the object have the key?

A simple util that will return true or false if the specified key is present in the object supplied.

What's New?

  • Package now available on NPM and Github Package Registry

Installation

// NPM
npm i @yavisht/has-key 

// Yarn
yarn add @yavisht/has-key

Usage

// require example
const hasKey = require('@yavisht/has-key')

// import example 
import hasKey from '@yavisht/has-key'

// returns true
console.log(hasKey({foo:'bar'}, 'foo'))

// returns false
console.log(hasKey({foo:'bar'}, 'bar'))