Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

has-props-js

camcam26059MIT1.0.2

The library to determines whether an object has the specified properties.

has-own-property, has-own-properties, has property, has own, object

readme

has-props-js

The library to determines whether an object has the specified properties.

Installation

npm i has-props-js

or

yarn add has-props-js

Usage

import hasProps from "has-props-js";

const myObject = { orange: "Orange", lemon: "Lemon", watermelon: "Watermelon" };

hasProps(myObject, "orange"); // true
hasProps(myObject, ["orange", "lemon"]); // true
hasProps(myObject, ["orange", "lemon"], { pick: true }); // false

API

hasProps(object, props, options)

  • object - object (Required) - The object to check
  • props - string | number | symbol | any[] (Required) - The property to check, accept multiple properties as an array
  • options - object (Optional) - options.pick option allow the object can only contain properties of props
  • return an boolean