UNPKG

ut2

Version:

一个现代 JavaScript 实用工具库。[点击查看在线文档]。

32 lines (28 loc) 765 B
'use strict'; var toNumber = require('../toNumber.js'); function createOperation(comparator) { return function (value, other) { if (!(typeof value === 'string' && typeof other === 'string')) { value = toNumber(value); other = toNumber(other); } return comparator(value, other); }; } var baseGt = function (value, other) { return value > other; }; var baseGte = function (value, other) { return value >= other; }; var baseLt = function (value, other) { return value < other; }; var baseLte = function (value, other) { return value <= other; }; exports.baseGt = baseGt; exports.baseGte = baseGte; exports.baseLt = baseLt; exports.baseLte = baseLte; exports.createOperation = createOperation;