Node-comparison is a lightweight tool for compare any type of arguments with keyword, written on node.js
install node-comparison via npm
npm install node-comparison
Node-comparison takes arguments written in JSON friendly format as input. Arguments could be many types of data (number, string, boolean, date, ...) with a humanity operator format in String (Number "equal" Number, Date "before" Date, ...), return value is the boolean of the comparison result.
- number: ['equal', 'notEqual', 'lessThan', 'lessThanOrEqual', 'greaterThan', 'greaterThanOrEqual', 'between'],
- date: ['on', 'before', 'after', 'onOrBefore', 'onOrAfter', 'within'],
- boolean: ['equal', 'notEqual'],
- string: ['is', 'startWith', 'contains']
var compare = require('node_comparison').compare;
console.log('compare result');
console.log(compare('date', 'within', new Date(2017, 1, 20), new Date(2017, 1, 19), new Date(2017, 1, 23)));