https://github.com/smart-table/smart-table-search
full text search factory: takes a configuration object and returns a function operating on arrays
https://github.com/smart-table/smart-table-search
array filter search smart-table
Last synced: 9 months ago
JSON representation
full text search factory: takes a configuration object and returns a function operating on arrays
- Host: GitHub
- URL: https://github.com/smart-table/smart-table-search
- Owner: smart-table
- License: mit
- Created: 2017-02-03T14:27:16.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2021-08-10T17:40:17.000Z (almost 5 years ago)
- Last Synced: 2024-08-09T13:26:15.362Z (almost 2 years ago)
- Topics: array, filter, search, smart-table
- Language: JavaScript
- Size: 72.3 KB
- Stars: 1
- Watchers: 4
- Forks: 1
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# smart-table-search
[](https://circleci.com/gh/smart-table/smart-table-search)
full text search factory: takes a configuration object and returns a function operating on arrays
## basic
### options
* scope: an array with pointers to the properties to search
* value: the value items should match
* isCaseSensitive: whether the search should be case sensitive (default: false)
### usage
```Javascript
import {basic} from 'smart-table-search';
const collection = [
{a: 'woo', b: {c: 'foot'}},
{a: 'foo', b: {c: 'w'}},
{a: 'foo', b: {c: 'b'}},
];
const search = basic({value: 'w', scope: ['a', 'b.c']})
const output = search(collection);
// > [{"a": "woo", "b": {"c": "foot"}},{"a": "foo", "b": {"c": "w"}}]
```
## regexp
### options
* scope: an array with pointers to the properties to search
* value: the regex pattern items should match
* escape: whether special regexp syntax character should be escaped (default false)
* flags: a string with the flags to provide to the testing regexp (default '')
### usage
```Javascript
import {regexp} from 'smart-table-search';
const collection = [
{a: 'Woo', b: {c: 'bar'}},
{a: 'a', b: {c: 'w'}},
{a: 'owo', b: {c: 'bar'}}
];
const search = regexp({value: '^w', scope: ['a', 'b.c'], flags: 'i'});
const output = search(collection)
// > [ {a: 'Woo', b: {c: 'bar'}}, {a: 'a', b: {c: 'w'}}
```