1.0.27 • Published 2 months ago

@talkohavy/filters v1.0.27

Weekly downloads
-
License
MIT
Repository
github
Last release
2 months ago

@talkohavy/filters

Easy & intuitive way to apply complex filters.

NPM Version

Features

This package exposes the class object of Filter.
Filter holds 2 powerful methods for you to utilize:

  • applyFilters
  • changeSchema

Installation

Using npm:

npm install @talkohavy/filters

Using pnpm:

pnpm add @talkohavy/filters

Using yarn:

yarn add @talkohavy/filters

How to use

Here's a code example of how to use the package:

import { Filterer } from '@talkohavy/filters';

const dummyData = [
  {
    id: 1,
    name: 'Dander Mente',
    type: 'customer',
    orders: { amount: 10 },
    address: 'NY USA',
    order: 'A4BC',
    tax: 145.2,
    total: 13.9,
  },
  {
    id: 2,
    name: 'Tracey Bill',
    type: 'customer',
    orders: { amount: 10, isVIP: null },
    address: 'NJ USA',
    order: 'A8O7X',
    tax: 1.2,
    total: 93.46,
  },
  {
    id: 3,
    name: 'Gina Doe',
    type: 'worker',
    address: 'CA USA',
    order: 'B3KL',
    tax: 75.6,
    total: 30.1,
  },
];

/** @type {Filter} */
const filterScheme = [
  { fieldName: 'name', value: 'Dan', operator: 'startsWith' },
  { fieldName: 'total', value: 13.8, operator: 'gte' },
];

const filterer = new Filterer({ filterScheme });
const filteredData = filterer.applyFilters({ data: dummyData });

console.log(filteredData);

License

MIT

1.0.27

2 months ago

1.0.26

4 months ago

1.0.25

4 months ago

1.0.24

4 months ago

1.0.17

5 months ago

1.0.16

5 months ago

1.0.15

5 months ago

1.0.14

5 months ago

1.0.13

5 months ago

1.0.23

5 months ago

1.0.9

5 months ago

1.0.7

5 months ago

1.0.6

5 months ago

1.0.5

5 months ago

1.0.4

5 months ago

1.0.11

5 months ago

1.0.10

5 months ago

1.0.12

5 months ago

1.0.3

5 months ago

1.0.2

5 months ago

1.0.1

5 months ago

1.0.0

5 months ago