1.0.4 • Published 2 years ago

has-match v1.0.4

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

has-match

Check object value for match

Install

npm install has-match

Usage

import hasMatch from 'has-match'

const garden = {
	name: 'Sunny Fields',
	plants: ['roses', 'lilies', 'gerberas'],
}

hasMatch(garden, 'gerb')
// => true

hasMatch(garden, 'sunny fields')
// => true

hasMatch(garden, 'sunny fields', ['plants'])
// => false

Filter

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'] }]
1.0.4

2 years ago

1.0.2

2 years ago

1.0.3

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago

0.1.1

2 years ago

0.1.0

2 years ago