https://github.com/dfkaye/fluent-comparators
fluent javascript dsl comparators (eq, neq, gt, lt, gte, lte) for numbers, strings and booleans
https://github.com/dfkaye/fluent-comparators
Last synced: 3 months ago
JSON representation
fluent javascript dsl comparators (eq, neq, gt, lt, gte, lte) for numbers, strings and booleans
- Host: GitHub
- URL: https://github.com/dfkaye/fluent-comparators
- Owner: dfkaye
- License: mit
- Created: 2015-05-12T21:44:50.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2015-06-16T23:23:32.000Z (almost 10 years ago)
- Last Synced: 2025-01-02T03:46:40.046Z (5 months ago)
- Language: JavaScript
- Homepage:
- Size: 234 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# fluent-comparators
Not meant to be an expects-matcher library. Adds fluent javascript dsl comparator methods (eq, neq, gt, lt, gte, lte) to numbers, strings and booleans.Given:
path.to.value = 1; // (or true or 'hello');
Then these return `true`:path.to.value.eq(testValue = path.to.value);
path.to.value.neq(testValue = path.to.value + 1);
path.to.value.gt(testValue = path.to.value);
path.to.value.gte(testValue = path.to.value + 1);
path.to.value.lt(testValue = path.to.value + 1);
path.to.value.lte(testValue = path.to.value + 1);
Support for mod operator (%):12.mod(4).eq(0);
13.mod(4).eq(1);
'13'.mod(4).eq(1);
13.mod('4').eq(1);
'not a number'.mod('not a number').toString().eq('NaN');## qunit test suite on rawgit
https://rawgit.com/dfkaye/fluent-comparators/master/test/qunit/browser.html## TODO:
+ add math operators [16 June 2015] ~ plus(), minus(), times(), divBy()
+ add isNaN() [16 June 2015]
+ add callback support [ 10-May-2015]:
value.eq(other, function capture(result) {
console.log(result);
return result; // or return this for chaining rather than if-ing...
});
+ travis
+ testem
+ npm init test and pub