0.0.3 • Published 8 years ago

@omysoul/googlish v0.0.3

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

Googlish

Enter a Google search style query and it will return a test function that returns true when its input satisfies the query.

Works with double and single quoted inner strings:

const test = googlish('over fox "lazy dog"')
test('the quick brown fox jumps over the lazy dog')
//true

const test = googlish('over fox "dog lazy"')
test('the quick brown fox jumps over the lazy dog')
//false

By default substrings count as matches and search is case insensitive. This can be changed:

let wholeWords = true
let caseSensitive = true
googlish('over fox', wholeWords, caseSensitive)

Ideal for creating filter functions:

const isLazyDog = googlish('"lazy dog"')
const dogs = ['happy dog', 'lazy dog']
const lazyDogs = dogs.filter(isLazyDog)
// ['lazy dog']