ohas

1.0.6 • Public • Published

has()

Build Status Coverage Status GitHub license NPM downloads GitHub issues

Determine if a javascript object has a key. Allows for nested key detection.

Installation

With yarn

yarn add ohas

With npm

npm install ohas --save

Usage

import has from 'ohas';
 
const user = {
  firstname: 'John',
  lastname: 'Smith',
  address: {
    street1: '123 Road Way Blvd',
    street2: 'APT 21',
    city: 'Brooklyn',
    state: 'NY'
  }
}
 
const hasFirstname = has(user, 'firstname');
console.log(hasFirstname); // true
 
const hasCity = has(user, 'address', 'city');
console.log(hasCity); // true
 
const hasZip = has(user, 'address', 'zip');
console.log(hasZip); // false
 
const hasUser2 = has(user2, 'firstname');
console.log(hasUser2); // false

Dependents (1)

Package Sidebar

Install

npm i ohas

Weekly Downloads

4

Version

1.0.6

License

MIT

Unpacked Size

6.86 kB

Total Files

10

Last publish

Collaborators

  • luisfcolon