Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

get-closest

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

get-closest - npm Package Compare versions

Comparing version 0.0.1 to 0.0.2

2

package.json
{
"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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc