get-closest
Advanced tools
Comparing version 0.0.1 to 0.0.2
{ | ||
"name": "get-closest", | ||
"description": "Compare your item to items in an array and get the closest one.", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"homepage": "https://github.com/cosmosio/get-closest", | ||
@@ -6,0 +6,0 @@ "licenses": [ |
@@ -34,7 +34,7 @@ Get closest | ||
If you want to find the closest to 17.5, as it's exactly between 15 and 20, `closest` will return the last item in the array that matches, which is 20 in our case. | ||
If you want to find the closest to 17.5, as it's exactly between 15 and 20, `number` will return the last number in the array that matches, which is 20 in our case. | ||
```js | ||
getCloset.closest(17.5, items); // 3, as items[3] === 20 | ||
getCloset.closest(35, items); // 4, as items[4] === 50 | ||
getCloset.number(17.5, items); // 3, as items[3] === 20 | ||
getCloset.number(35, items); // 4, as items[4] === 50 | ||
``` | ||
@@ -48,3 +48,3 @@ | ||
If there's an exact match, it's returned. The last exact match will be returned too, to be consistent .closest. | ||
If there's an exact match, it's returned. The last exact match will be returned too, to be consistent .number. | ||
@@ -51,0 +51,0 @@ ```js |
7661