does-property-exist
v1.0.0
Published
To check whether object owns properties or not (every / some)
Downloads
5
Maintainers
Readme
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.