3.1.1 • Published 2 years ago

filter-string v3.1.1

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

filter-string

node npm license Build Status Standard - JavaScript Style Guide Coverage Status

Parse and stringify RESTFul filter string

Install

npm install filter-string

Use

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 yyy

Parse

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.filter
Array.prototype.find

FYI: You should add polyfill by yourself if need

Development

  • Installation
npm install
  • Build for publish
npm run build
  • Run test
npm run test
3.1.1

2 years ago

3.1.0

4 years ago

3.0.2

4 years ago

3.0.1

4 years ago

3.0.0

4 years ago

2.1.3

5 years ago

2.1.2

5 years ago

2.1.1

5 years ago

2.1.0

5 years ago

2.0.0

5 years ago

1.0.1

6 years ago

1.0.0

6 years ago

0.2.4

6 years ago

0.2.3

6 years ago

0.2.2

6 years ago

0.2.1

6 years ago

0.2.0

6 years ago

0.1.2

6 years ago

0.1.1

6 years ago

0.1.0

6 years ago