0.1.2 • Published 3 years ago

@monsterbilligt/predicate-parser v0.1.2

Weekly downloads
-
License
ISC
Repository
-
Last release
3 years ago

predicate-parser

Parses predicate strings. Developed to support parsing simple predicate strings (containing numbers, variables and +'s) and evaluate their truthfulness.

Install

npm i @monsterbilligt/predicate-parser

Usage

Use evaluatePredicateString() to evaluate a predicate string. Validates the string before parsing. Use as a predicate (ie. returns either true or false).

Use createPredicateRegExp() to create a regular expression that can validate user input as a predicate string.

Example:

import { evaluatePredicateString } from '@monsterbilligt/predicate-parser'

console.log(
  evaluatePredicateString('duration > 24 days', { duration: 26, numberSuffix: 'days' })
)

// > true

Develop

npm i && npm test