Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/faizanu94/key-value-exists
Returns existence of key or value in an object
https://github.com/faizanu94/key-value-exists
exists key-value key-value-pair map object primitive search
Last synced: 5 days ago
JSON representation
Returns existence of key or value in an object
- Host: GitHub
- URL: https://github.com/faizanu94/key-value-exists
- Owner: faizanu94
- License: mit
- Created: 2021-01-31T16:58:08.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2021-04-05T12:13:14.000Z (over 3 years ago)
- Last Synced: 2024-12-19T10:44:44.287Z (8 days ago)
- Topics: exists, key-value, key-value-pair, map, object, primitive, search
- Language: JavaScript
- Homepage: https://www.npmjs.com/package/key-value-exists
- Size: 5.86 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# key-value-exists
> Returns existence of key or value in an object## Install
```
$ npm install key-value-exists
```## Usage
```js
const keyValueExists = require('key-value-exists');keyValueExists({foo: true, bar: {baz: {foobaz: true}}, foobar: {barbaz: true}}, 'foo');
//=> truekeyValueExists({foo: true, bar: {baz: {foobaz: true}}, foobar: {barbaz: true}}, 'zoo');
//=> falsekeyValueExists({foo: true, bar: {baz: {foobaz: true}}, foobar: {barbaz: true}}, 'foobaz', {deep: true});
//=> truekeyValueExists({foo: true, bar: {baz: {foobaz: true}}, foobar: {barbaz: true}}, {foobaz: true}, {deep: true});
//=> truekeyValueExists({foo: true, bar: {baz: {foobaz: true}}, foobar: {barbaz: true}}, {foobaz: false}, {deep: true});
//=> false
```## API
### keyValueExists(object, target, options?)
#### object
Type: `object`
Source object to traverse
#### target
Type: `any`
Value to be searched
#### options
Type: `object`
##### deep
Type: `boolean`\
Default: `false`Recurse nested objects and objects in arrays