does-property-exist

1.0.0 • Public • Published

does-property-exist

A Node.js module which tests whether an object have specific properties or not. It's like hasOwnProperty() but with additional config option 'every' or 'some'.

Installation

npm install does-property-exist --save

Params:

  • every [true / false] - checks whether every property exist or not. [Default true]
  • checkFalsy [true / false] - check falsy value. [Default false]

Usage

const doesPropertyExist = require('does-property-exist')

const obj = { "a": 1, "b": 2 };

doesPropertyExist(obj, ["a"]) // 'true'
doesPropertyExist(obj, ["a", "b"]) // 'true'
doesPropertyExist(obj, ["a", "c"]) // 'false'

doesPropertyExist(obj, ["a", "c"], {every: false}) // 'true'

doesPropertyExist(obj, ["a", "b"], {checkFalsy: true}) // 'true'

doesPropertyExist(obj, ["a", "c"], {
  every: false,
  checkFalsy: true, 
}) // 'true'

doesPropertyExist(obj, ["a", "b"], {
  every: false,
  checkFalsy: true,
}) // 'true'

License

Copyright © 2021, Tanvir Rahman. Released under the MIT License.


Package Sidebar

Install

npm i does-property-exist

Weekly Downloads

2

Version

1.0.0

License

MIT

Unpacked Size

3.46 kB

Total Files

4

Last publish

Collaborators

  • tanvir_rahman