3.1.1 • Published 6 years ago

filter-value v3.1.1

Weekly downloads
4
License
MIT
Repository
github
Last release
6 years ago

FILTER VALUE

Filter value is engine for filtering data by it's value

Installation

npm install --save filter-value

Example Usage

import FilterValue from 'filter-value';
var FilterValue = require('filter-value');

Example data

const a = [
    {
        'column1': 1,
        'column2': false,
        'column3': 'test',
    }, {
        'column1': 2,
        'column2': true,
        'column3': 'test2',
    }
]

Constructor

Creating new Filter value instance

    const filterValue = new FilterValue();
    const filterValue2 = new FilterValue(name);
    const filterValue3 = new FilterValue(name, value);
    const filterValue4 = new FilterValue(name, value, staticType);

Name

    filterValue.Name = 'new Name';
    const name = filterValue.Name;

Value

Valid values:

  • String
  • Number
  • Date
  • Function
  • Boolean
  • Regexp
  • Null
  • Array
    filterValue.Value = 'new value';
    const value = filterValue.Value;

Range filter

Range filter can be used with one value, which will filter smaller or bigger values.

Valid value for range

  • Number
  • String
  • Date*

Note: *Date will try to create date from given item in array if item isn't instance of Date

    filterValue.Value = {
        from: new Date(),
        to: new Date()
    };

    filterValue.Value = {
        from: new Date(),
        to: null
    };

    filterValue.Value = {
        from: null,
        to: new Date()
    };

Array filter

Array filter can be variety of types

Valid values for array

  • String
  • Number
  • Date
  • Function
  • Boolean
  • Regexp
  • Null

Limitations

Only one dimensional array can be used

    filterValue.Value = [
        'yes',
        false,
        null,
        new Date()
    ]

Type

When type is set value will automatically retype to chosen type. It's possible to get original value, example is shown below.

Valid types

  • Boolean
  • Date*
  • Number
  • Regexp**
  • String

*It's used native function new Date(arg)

**Using native function new RegExp() with escaping characters

    filterValue.Type = 'string';
    filterValue.removeType();
    const originalValue = filterValue.Original;
    const type = filterValue.Type;
3.1.1

6 years ago

3.1.0

6 years ago

3.0.4

6 years ago

3.0.3

6 years ago

3.0.2

6 years ago

3.0.1

6 years ago

3.0.0

6 years ago

2.0.2-rc.6

6 years ago

2.0.2-rc.5

6 years ago

2.0.2-rc.3

6 years ago

2.0.2-rc.1

6 years ago

2.0.1

6 years ago

2.0.0

6 years ago

2.0.0-rc.13

6 years ago

2.0.0-rc.12

6 years ago

2.0.0-rc.11

6 years ago

2.0.0-rc.10

6 years ago

2.0.0-rc.9

6 years ago

2.0.0-rc.8

6 years ago

2.0.0-rc.7

6 years ago

2.0.0-rc.6

6 years ago

2.0.0-rc.5

6 years ago

2.0.0-rc.4

6 years ago

2.0.0-rc.3

6 years ago

2.0.0-rc.2

6 years ago

2.0.0-rc.1

6 years ago

1.0.2-rc.3

6 years ago

1.0.2-rc.2

6 years ago

1.0.2-rc.1

6 years ago

1.0.2-rc.0

6 years ago

1.0.1

6 years ago

1.0.0

7 years ago

0.1.7

7 years ago

0.1.6

7 years ago

0.1.5

7 years ago

0.1.4

7 years ago

0.1.3

7 years ago

0.1.2

7 years ago

0.1.0

7 years ago

0.0.9-0

7 years ago