googlish

0.0.8 • Public • Published

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

Readme

Keywords

none

Package Sidebar

Install

npm i googlish

Weekly Downloads

1

Version

0.0.8

License

ISC

Last publish

Collaborators

  • philholden