1.5.3 • Published 1 year ago

filterion v1.5.3

Weekly downloads
2
License
MIT
Repository
github
Last release
1 year ago

TypeScript codecov Release

📦 Install

Install filterion using npm:

npm i filterion

🔨 Usage

Require it into any module and use natively:

import { Filterion } from 'filterion';

const filter = new Filterion()
  .add('device', 'iPhone')
  .add('price', 649);

console.log(filter.getPayload());

/*
{
  device: { '=': [ 'iPhone' ] },
  price: { '=': [ 649 ] }
}
*/

Or leverage the query string API:

import { Filterion } from 'filterion';

const newQuery = new Filterion()
  .fromQueryString('device=iPhone&price=649')
  .remove('price')
  .add('year', 2007)
  .toQueryString();

console.log(newQuery);

/*
device=iPhone&year=2007
*/

Typescript

Filterion can be used in a type-safe context:

import { Filterion } from 'filterion';

// Good
const filterion = new Filterion<{ price: string }>()
  .add('price', 649);

// Bad
const filterion = new Filterion<{ name: string }>()
  .add('price', 649);

/*
error TS2345: Argument of type '"price"' is not assignable to parameter of type '"name"'.
*/

Inspired by immutable.js, an immutable collections library for JavaScript.

License

MIT

1.5.3

1 year ago

1.5.2

1 year ago

1.5.1

1 year ago

1.5.0

1 year ago

1.4.2

2 years ago

1.4.1

4 years ago

1.4.0

4 years ago

1.3.2

4 years ago

1.3.1

4 years ago

1.3.0

4 years ago

1.2.0

4 years ago

1.2.1

4 years ago

1.1.0

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.3

4 years ago

1.0.0

4 years ago

0.0.0

4 years ago