Skip to content

Commit 34ca4f3

Browse files
committed
Consolidate relational modules.
1 parent 11052f4 commit 34ca4f3

File tree

7 files changed

+32
-58
lines changed

7 files changed

+32
-58
lines changed

.internal/baseGt.js

Lines changed: 0 additions & 14 deletions
This file was deleted.

.internal/baseLt.js

Lines changed: 0 additions & 14 deletions
This file was deleted.

.internal/createRelationalOperation.js

Lines changed: 0 additions & 20 deletions
This file was deleted.

gt.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import baseGt from './.internal/baseGt.js';
2-
import createRelationalOperation from './.internal/createRelationalOperation.js';
1+
import toNumber from './toNumber.js';
32

43
/**
54
* Checks if `value` is greater than `other`.
@@ -22,6 +21,12 @@ import createRelationalOperation from './.internal/createRelationalOperation.js'
2221
* gt(1, 3);
2322
* // => false
2423
*/
25-
const gt = createRelationalOperation(baseGt);
24+
function gt(value, other) {
25+
if (!(typeof value == 'string' && typeof other == 'string')) {
26+
value = toNumber(value);
27+
other = toNumber(other);
28+
}
29+
return value > other;
30+
}
2631

2732
export default gt;

gte.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import createRelationalOperation from './.internal/createRelationalOperation.js';
1+
import toNumber from './toNumber.js';
22

33
/**
44
* Checks if `value` is greater than or equal to `other`.
@@ -21,6 +21,12 @@ import createRelationalOperation from './.internal/createRelationalOperation.js'
2121
* gte(1, 3);
2222
* // => false
2323
*/
24-
const gte = createRelationalOperation((value, other) => value >= other);
24+
function gte(value, other) {
25+
if (!(typeof value == 'string' && typeof other == 'string')) {
26+
value = toNumber(value);
27+
other = toNumber(other);
28+
}
29+
return value >= other;
30+
}
2531

2632
export default gte;

lt.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import baseLt from './.internal/baseLt.js';
2-
import createRelationalOperation from './.internal/createRelationalOperation.js';
1+
import toNumber from './toNumber.js';
32

43
/**
54
* Checks if `value` is less than `other`.
@@ -22,6 +21,12 @@ import createRelationalOperation from './.internal/createRelationalOperation.js'
2221
* lt(3, 1);
2322
* // => false
2423
*/
25-
const lt = createRelationalOperation(baseLt);
24+
function lt(value, other) {
25+
if (!(typeof value == 'string' && typeof other == 'string')) {
26+
value = toNumber(value);
27+
other = toNumber(other);
28+
}
29+
return value < other;
30+
}
2631

2732
export default lt;

lte.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import createRelationalOperation from './.internal/createRelationalOperation.js';
1+
import toNumber from './toNumber.js';
22

33
/**
44
* Checks if `value` is less than or equal to `other`.
@@ -21,6 +21,12 @@ import createRelationalOperation from './.internal/createRelationalOperation.js'
2121
* lte(3, 1);
2222
* // => false
2323
*/
24-
const lte = createRelationalOperation((value, other) => value <= other);
24+
function lte(value, other) {
25+
if (!(typeof value == 'string' && typeof other == 'string')) {
26+
value = toNumber(value);
27+
other = toNumber(other);
28+
}
29+
return value <= other;
30+
}
2531

2632
export default lte;

0 commit comments

Comments
 (0)