Home

Awesome

<h1 align="center"> <img src="/logo.png" alt="voll" width="200"> <br> Boolean expressions evaluator. <br> <br> </h1> <p align="center"> <img src="https://img.shields.io/github/tag/Kikobeats/voll.svg?style=flat-square" alt="Last version"> <a href="https://travis-ci.org/Kikobeats/voll"><img src="http://img.shields.io/travis/Kikobeats/voll/master.svg?style=flat-square" alt="Build Status"></a> <a href="https://coveralls.io/github/Kikobeats/voll"><img src="https://img.shields.io/coveralls/Kikobeats/voll.svg?style=flat-square" alt="Coverage Status"></a> <a href="https://paypal.me/kikobeats"><img src="https://img.shields.io/badge/donate-paypal-blue.svg?style=flat-square" alt="Donate"></a><br><a href="https://david-dm.org/Kikobeats/voll"><img src="http://img.shields.io/david/Kikobeats/voll.svg?style=flat-square" alt="Dependency status"></a> <a href="https://david-dm.org/Kikobeats/voll#info=devDependencies"><img src="http://img.shields.io/david/dev/Kikobeats/voll.svg?style=flat-square" alt="Dev Dependencies Status"></a> <a href="https://www.npmjs.org/package/voll"><img src="http://img.shields.io/npm/dm/voll.svg?style=flat-square" alt="NPM Status"></a> </p>

voll is based mayority bool but improved in some aspects:

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

OperatorAlias
AND
OR+
NOT-

API

voll(expr, [options])

expr

Required<br> Type: string

Boolean expression to be evaluated.

options

Type: object

Provide specific parser options

insensitive

Type: boolean<br> Default: false

Enable/Disable insensitive comparison.

cache

Type: boolean<br> 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