verificator
Version:
Client and server-side validation JavaScript library
18 lines (17 loc) • 443 B
text/typescript
const compare = (first: number, second: number, operator: string) => {
switch (operator) {
case '<':
return first < second
case '>':
return first > second
case '<=':
return first <= second
case '>=':
return first >= second
case '=':
return first === second
default:
throw new TypeError()
}
}
export default compare