1.0.34 • Published 10 months ago

@talkohavy/filters v1.0.34

Weekly downloads
-
License
MIT
Repository
github
Last release
10 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.29

1 year ago

1.0.28

1 year ago

1.0.31

12 months ago

1.0.34

10 months ago

1.0.27

1 year ago

1.0.26

1 year ago

1.0.25

1 year ago

1.0.24

1 year ago

1.0.17

2 years ago

1.0.16

2 years ago

1.0.15

2 years ago

1.0.14

2 years ago

1.0.13

2 years ago

1.0.23

2 years ago

1.0.9

2 years ago

1.0.7

2 years ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.11

2 years ago

1.0.10

2 years ago

1.0.12

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago