filter-string
Parse and stringify RESTFul filter string
Install
npm install filter-stringUse
Stringify
import { stringify } from 'filter-string'
const filters = [
{
key: 'a',
op: 'eq',
value: 'xxx',
},
{
key: 'b',
op: 'gt',
value: 'yyy',
},
]
const $filter = stringify(filters, {
op: 'and',
})
// output
// a eq xxx and b gt yyyParse
import { parse } from 'filter-string'
const $filter = 'a eq xxx and b gt yyy'
const filters = parse($filter)
// output
// [{
// key: 'a',
// op: 'eq',
// value: 'xxx'
// }, {
// key: 'b',
// op: 'gt',
// value: 'yyy'
// }]Needed polyfill
Array.prototype.filterArray.prototype.findFYI: You should add polyfill by yourself if need
Development
- Installation
npm install- Build for publish
npm run build- Run test
npm run test