Skip to content

๐Ÿ… A declarative JavaScript library for search params orchestration.

License

Notifications You must be signed in to change notification settings

emmettullrich12/filterion

ย 
ย 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

56 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

Filterion

A zero-dependency, immutable data structure for search params management.

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

About

๐Ÿ… A declarative JavaScript library for search params orchestration.

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 98.0%
  • JavaScript 1.6%
  • Shell 0.4%