main
Last change
on this file since 0c6b92a was d565449, checked in by stefan toskovski <stefantoska84@…>, 3 months ago |
Update repo after prototype presentation
|
-
Property mode
set to
100644
|
File size:
576 bytes
|
Rev | Line | |
---|
[d565449] | 1 | import toNumber from './toNumber.js';
|
---|
| 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 | */
|
---|
| 10 | function 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 |
|
---|
| 20 | export default createRelationalOperation;
|
---|
Note:
See
TracBrowser
for help on using the repository browser.