@nextgis/properties-filter
TypeScript icon, indicating that this package has built-in type declarations

2.3.0 • Public • Published

Properties Filter

size version

An auxiliary library that allows filtering objects by its properties using JSON-serializable expressions

Installation

# latest stable
npm install @nextgis/properties-filter

Usage

General view of expression

[ С , [E1] , [E2] , [EN] ]

  • С - condition (optional). May be 'all' or 'any';

  • E - expression:

    [key, operator, value]

    • key - property name;
    • operator - gt, lt, ge, le, eq, ne, in, notin, like, ilike;
    • value - anything to compare with property by operator

    in and notin:

    • [['id', 'in', [1,2,3]], ['id', 'notin', [1,2,3]]]

    like and ilike:

    Place %-character after or before key string to determine the direction of search.

    • ['str%', 'like', 'hello']
    • ['%str%', 'ilike', 'Worl']

Nesting

[ [E1], ['any', [E2], [E3, E4] ], ['any', [E5], [E6] ] ] ]

Example

import { propertiesFilter, featureFilter } from '@nextgis/properties-filter';

const properties = {
  place: 'Tofalaria',
  area: 21,
};

propertiesFilter(properties, [['place', 'eq', 'Tofalaria']]); // true
propertiesFilter(properties, [['place', 'in', ['Tofalaria', 'Siberia']]]); // true
propertiesFilter(properties, [['place%', 'like', 'Tof']]); // true

propertiesFilter(properties, [
  // 'and', // - by default
  ['place', 'eq', 'Tofalaria'],
  ['area', 'ge', 21],
]); // true
propertiesFilter(properties, [
  'any',
  ['place', 'eq', 'Siberia'],
  ['area', 'gt', 10],
]); // true

Commercial support

Need to fix a bug or add a feature to @nextgis/properties-filter? We provide custom development and support for this software. Contact us to discuss options!

http://nextgis.com

/@nextgis/properties-filter/

    Package Sidebar

    Install

    npm i @nextgis/properties-filter

    Weekly Downloads

    68

    Version

    2.3.0

    License

    MIT

    Unpacked Size

    74.4 kB

    Total Files

    21

    Last publish

    Collaborators

    • rendrom
    • maximdubinin
    • karavanjo