feat(complex-matcher/Comparison): can match with non numbers

It will use implicit conversion.
This commit is contained in:
Julien Fontanet
2025-09-10 11:45:34 +02:00
parent b4e05b3183
commit b56ffbdb8d
3 changed files with 9 additions and 1 deletions

View File

@@ -70,6 +70,7 @@
- @xen-orchestra/rest-api minor
- @xen-orchestra/web minor
- @xen-orchestra/web-core minor
- complex-matcher major
- xo-server minor
- xo-web minor

View File

@@ -75,7 +75,7 @@ class Comparison extends Node {
}
match(value) {
return typeof value === 'number' && this._comparator(value, this._value)
return this._comparator(value, this._value)
}
toString() {

View File

@@ -76,6 +76,13 @@ describe('Comparison', () => {
assert(new Comparison('<', 42).match(41))
assert(new Comparison('<=', 42).match(42))
})
it('can match with non numbers', () => {
const ts = Date.now()
assert(new Comparison('>', ts).match(new Date(ts + 1)))
assert(!new Comparison('>', ts).match(new Date(ts)))
})
})
describe('GlobPattern', () => {