https://github.com/junosuarez/like
node module: build a regex from user input for filtering data
https://github.com/junosuarez/like
Last synced: about 1 year ago
JSON representation
node module: build a regex from user input for filtering data
- Host: GitHub
- URL: https://github.com/junosuarez/like
- Owner: junosuarez
- License: mit
- Created: 2013-02-20T02:37:06.000Z (over 13 years ago)
- Default Branch: master
- Last Pushed: 2014-07-18T16:03:32.000Z (about 12 years ago)
- Last Synced: 2025-07-07T13:16:05.017Z (about 1 year ago)
- Language: JavaScript
- Size: 135 KB
- Stars: 9
- Watchers: 6
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# like
build a regex from user input for filtering data
## installation
```console
$ npm install like
```
## usage
```js
var like = require('like')
var filter = like(searchField.value)
var matches = items.filter(function (x) {
return filter.test(x)
})
// or we could get a predicate function like so:
var matches = items.filter(like.fn(searchField.value))
```
**note** As of 0.3.0, matches are case-sensitive by default. Functions take an options parameter which takes a `ignoreCase` option. Example:
```js
like('foo', {ignoreCase: true})
```
## api
Described using [jsig](https://github.com/jden/jsig):
`type Predicate : (Value) => Boolean`
### `like : (String, options: Object?) => RegExp`
### `like.startsWith : (String, options: Object?) => RegExp`
### `like.endsWith : (String, options: Object?) => RegExp`
### `like.fn : (String, options: Object?) => Predicate`
### `like.startsWithFn : (String, options: Object?) => Predicate`
### `like.endsWithFn : (String, options: Object?) => Predicate`
## running the tests
```console
$ git clone git@github.com:AgileDiagnosis/like.git && cd like
$ npm install
$ npm test
```
## kudos to
substack for [quotemeta](https://www.npmjs.org/package/quotemeta)
## contributors
jden
## license
MIT. (c) 2013 Agile Diagnosis . See LICENSE.md