1.0.0 • Published 4 years ago

does-property-exist v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
4 years ago

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:

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.