blob: a17c6b5e72f7ec04a8f8ecb663af10f12ea968ce [file] [log] [blame]
Yang Guo4fd355c2019-09-19 08:59:031var toNumber = require('./toNumber');
2
3/**
4 * Creates a function that performs a relational operation on two values.
5 *
6 * @private
7 * @param {Function} operator The function to perform the operation.
8 * @returns {Function} Returns the new relational operation function.
9 */
10function createRelationalOperation(operator) {
11 return function(value, other) {
12 if (!(typeof value == 'string' && typeof other == 'string')) {
13 value = toNumber(value);
14 other = toNumber(other);
15 }
16 return operator(value, other);
17 };
18}
19
20module.exports = createRelationalOperation;