Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/andreruffert/closest-number
π’ Find the closest number out of an array to a specific value
https://github.com/andreruffert/closest-number
array closest closest-number number
Last synced: 2 months ago
JSON representation
π’ Find the closest number out of an array to a specific value
- Host: GitHub
- URL: https://github.com/andreruffert/closest-number
- Owner: andreruffert
- License: mit
- Created: 2016-07-06T14:15:51.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2023-02-11T10:57:51.000Z (almost 2 years ago)
- Last Synced: 2024-10-05T11:01:19.589Z (3 months ago)
- Topics: array, closest, closest-number, number
- Language: JavaScript
- Homepage: https://npm.im/closest-number
- Size: 186 KB
- Stars: 4
- Watchers: 2
- Forks: 1
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# closest-number
[![CI status](https://github.com/andreruffert/closest-number/workflows/CI/badge.svg)](https://github.com/andreruffert/closest-number/actions?workflow=CI)
[![npm version](https://img.shields.io/npm/v/closest-number.svg)](https://www.npmjs.com/package/closest-number)
[![npm](https://img.shields.io/npm/dm/closest-number?logo=npm)](https://www.npmjs.com/package/closest-number)> Find the closest number out of an array to a specific value
## Install
```console
$ npm i closest-number
```## Usage
```js
const closestNumber = require('closest-number');closestNumber([10, 20, 30], 12);
// => 10
```## License
MIT Β© [AndrΓ© Ruffert](http://andreruffert.com)