Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

voll

kikobeats1kMIT1.2.6

Boolean expressions evaluator.

bool, boolean, evaluator, expression, interpreter, parser

readme

voll
Boolean expressions evaluator.

Last version Build Status Coverage Status Donate
Dependency status Dev Dependencies Status NPM Status

voll is based mayority bool but improved in some aspects:

  • Exact word matching.
  • Insensitive comparison support.
  • Detect words based on unicode ranges.
  • Caching level for speed up AST evaluation.
  • Detect quotes words using scape quotes (' or ") for exact matches.
  • Operators alias (example: red+yellow means the same than red OR yellow).

Install

$ npm install voll --save

Usage

var voll = require('voll')
var test = voll('(red OR blue) AND (orange OR yellow)')

test('red') //=> false
test('yellow') //=> false
test('red yellow') //=> true

You can build complex expressions as you need. Use parentheses to specify the preference:

((red OR blue) AND NOT (orange OR yellow)) OR orange

In other case the preference is left to right. Also it handles malformed expressions. For example:

((red OR blue) AND NOT (orange yellow)) OR orange

Produces the follow error:

SyntaxError: Parse error on line 1:
...ue) AND NOT (orange yellow)) OR orange
-----------------------^

Operators

Operator Alias
AND
OR +
NOT -

API

voll(expr, [options])

expr

Required
Type: string

Boolean expression to be evaluated.

options

Type: object

Provide specific parser options

insensitive

Type: boolean
Default: false

Enable/Disable insensitive comparison.

cache

Type: boolean
Default: true

Enable/Disable caching.

cacheOpts

Type: object

Provide specific cache options. See mem#options.

License

Icon made by Darius Dan from flaticon.

MIT © Kiko Beats

changelog

Changelog

All notable changes to this project will be documented in this file. See standard-version for commit guidelines.

1.2.6 (2020-10-11)

Bug Fixes

  • package: update mem to version 5.1.0 (f35649a)
  • linter (749ed1c)
  • package: update mem to version 2.0.0 (5af6272)
  • package: update mem to version 3.0.0 (1b5934a)
  • package: update mem to version 4.0.0 (93c13b1)
  • package: update mem to version 4.2.0 (3ed078b)
  • package: update mem to version 4.3.0 (2e96cc1)

1.2.5 (2019-05-18)

  • build: update dependencies (bfd208a)
  • fix: linter (749ed1c)
  • fix(package): update mem to version 4.2.0 (3ed078b)
  • fix(package): update mem to version 4.3.0 (2e96cc1)
  • [ImgBot] Optimize images (f34bb88)
  • refactor style (cabad7a)
  • Update compositor.json via compositor.io (ecdfd18)
  • Update README.md (717ffdf)

1.2.4 (2018-08-28)

  • Meta tweaks (df2db44)
  • Update .travis.yml (179e0e5)
  • Update compositor.json (241ae73)
  • Update compositor.json (3004222)
  • Update package.json (e921bb4)
  • Update README.md (87339a8)
  • Update README.md (c164890)
  • fix(package): update mem to version 2.0.0 (5af6272)
  • fix(package): update mem to version 3.0.0 (1b5934a)
  • fix(package): update mem to version 4.0.0 (93c13b1)
  • docs(readme): add Greenkeeper badge (2787a17)

1.2.3 (2017-07-18)

  • Fix lint (2b6e9f7)
  • Update README.md (eb008c8)
  • docs(readme): add Greenkeeper badge (cd40f50)
  • chore(package): update mem to version 1.1.0 (614b980)

1.2.2 (2016-08-09)

1.2.1 (2016-07-20)

1.2.0 (2016-07-19)

1.1.1 (2016-07-18)

  • Add cache level for improve speed (858a156)
  • Fix insensitive support (41514c0)
  • Little refactor (8fd8acd)

1.1.0 (2016-07-18)

  • Add insensitive comparison (ac91c2b)

1.0.0 (2016-07-17)