Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mvllow/has-match
Check object value for match
https://github.com/mvllow/has-match
Last synced: 3 months ago
JSON representation
Check object value for match
- Host: GitHub
- URL: https://github.com/mvllow/has-match
- Owner: mvllow
- License: mit
- Created: 2021-11-21T01:16:39.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2024-06-06T18:25:13.000Z (7 months ago)
- Last Synced: 2024-10-08T16:55:23.471Z (3 months ago)
- Language: JavaScript
- Size: 15.6 KB
- Stars: 3
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: license
Awesome Lists containing this project
README
# has-match
> Check object value for match
## Install
```sh
npm install has-match
```## Usage
```js
import hasMatch from 'has-match'const garden = {
name: 'Sunny Fields',
plants: ['roses', 'lilies', 'gerberas'],
}hasMatch(garden, 'gerb')
// => truehasMatch(garden, 'sunny fields')
// => truehasMatch(garden, 'sunny fields', ['plants'])
// => false
```**Filter**
```js
const gardens = [
{
name: 'Sunny Fields',
plants: ['roses', 'lilies', 'gerberas'],
},
{
name: 'Moony Meadows',
plants: ['cosmos', 'lilies', 'mushrooms'],
},
]gardens.filter((garden) => hasMatch(garden, 'cosmos'))
// => [{ name: 'Moony Meadows', plants: ['cosmos', 'lilies', 'mushrooms'] }]
```