Skip to content
This repository was archived by the owner on May 1, 2025. It is now read-only.

Commit eeae510

Browse files
author
Hans Kristian Flaatten
committed
fix(near): allow max and min float values
1 parent f913baa commit eeae510

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,8 @@ module.exports.prototype.customNear = field => (query, point) => {
6868

6969
if (pointArr.length >= 2) {
7070
if (!isNaN(pointArr.reduce((a, b) => a + b))) {
71-
const max = parseInt(pointArr[2], 10);
72-
const min = parseInt(pointArr[3], 10);
71+
const max = pointArr[2];
72+
const min = pointArr[3];
7373

7474
query[field] = {
7575
$near: {

test.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ describe('customNear()', () => {
7979
type: 'Point',
8080
coordinates: point.split(',').splice(0, 2).map(parseFloat, 10),
8181
},
82-
$maxDistance: parseInt(point.split(',')[2], 10),
82+
$maxDistance: parseFloat(point.split(',')[2], 10),
8383
},
8484
},
8585
});
@@ -98,8 +98,8 @@ describe('customNear()', () => {
9898
type: 'Point',
9999
coordinates: point.split(',').splice(0, 2).map(parseFloat, 10),
100100
},
101-
$maxDistance: parseInt(point.split(',')[2], 10),
102-
$minDistance: parseInt(point.split(',')[3], 10),
101+
$maxDistance: parseFloat(point.split(',')[2], 10),
102+
$minDistance: parseFloat(point.split(',')[3], 10),
103103
},
104104
},
105105
});

0 commit comments

Comments
 (0)