Package Exports
- filterion
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (filterion) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Filterion
Immutable data structure for filter criteria management.
Install
Install filterion
using yarn or npm:
$ yarn add filterion
# or
$ npm i filterion
Then require it into any module:
import { Filterion } from 'filterion';
const filter = new Filterion()
.add('device', 'iPhone');
console.log(filter.getPayload());
/*
{
device: { '=': [ 'iPhone' ] },
price: { '=': [ 649 ] }
}
*/
Usage with query strings
Simple usage:
const query = 'device=iPhone&price=649';
const newQuery = new Filterion()
.fromQueryString(query)
.remove('price')
.add('year', 2007)
.toQueryString();
console.log(newQuery);
/*
'device=iPhone&year=2007'
*/
Advanced usage:
const query = 'device=iPhone&price=649';
const newQuery = new Filterion({ operators: ['=', '<', '>'] })
.fromQueryString(query)
.add('year', 2007, '>')
.add('year', 2019, '<')
.toQueryString();
console.log(newQuery);
/*
'device=iPhone&price=649&year>2007&year<2019'
*/