Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

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

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');
//=> true

keyValueExists({foo: true, bar: {baz: {foobaz: true}}, foobar: {barbaz: true}}, 'zoo');
//=> false

keyValueExists({foo: true, bar: {baz: {foobaz: true}}, foobar: {barbaz: true}}, 'foobaz', {deep: true});
//=> true

keyValueExists({foo: true, bar: {baz: {foobaz: true}}, foobar: {barbaz: true}}, {foobaz: true}, {deep: true});
//=> true

keyValueExists({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