Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

filter-value

Package Overview
Dependencies
Maintainers
1
Versions
40
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

filter-value

Data engine is small data management lib for some sort and filter.

  • 3.0.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2
decreased by-66.67%
Maintainers
1
Weekly downloads
 
Created
Source

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

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()
    }

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;

Keywords

FAQs

Package last updated on 13 Mar 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc