@rrc/service-rule-evaluator

3.2.0 • Public • Published

service-rule-evaluator NPM version Build Status Dependency Status Coverage percentage

service rule evaluator

Installation

$ npm install --save @rrc/service-rule-evaluator
or
$ yarn add @rrc/service-rule-evaluator -S

Usage

const evaluator = require('@rrc/service-rule-evaluator');

// 判断是否匹配
evaluator.isMatch('123', { eq: 123 });     // true
evaluator.isMatch('123', { lte: 123 });    // true
evaluator.isMatch('123', { gte: 123 });    // true

// 解释和执行
evaluator.evaluate('count=count+1', { count: 20 });     // { count: 21 }
evaluator.evaluate('count=count  -1', { count: 20 };    // { count: 19 }
evaluator.evaluate('count=count*  3', { count: 20 });   // { count: 60 }
evaluator.evaluate('count=count  /  2', { count: 20 }); // { count: 10 }
evaluator.evaluate('count = Math.max(count/increment, increment*2);', { count: 20, increment: 2 });     // { count: 10 }

License

MIT © wangshijun

Readme

Keywords

Package Sidebar

Install

npm i @rrc/service-rule-evaluator

Weekly Downloads

0

Version

3.2.0

License

MIT

Unpacked Size

10.2 kB

Total Files

4

Last publish

Collaborators

  • xierenhong