A function that, when given a target number and an array of numbers, will return the array value closest to the target.
npm install closest-to

sh
npm install closest-to
`$3
`js
require('closest-to')(needle, haystack, [returnIndex])
require('closest-to/nd')(needle, haystack, [returnIndex])
`
`js
closest(10, [1, 3, 5, 7, 9])
> 9
closest(10, [1, 3, 5, 7, 9], true)
> 4
`
`js
ndclosest([1, 2], [[1, 1], [2, 3], [3, 4]])
> [1, 1]ndclosest([1, 2], [[1, 1], [2, 3], [3, 4]], true)
> 0
`$3
`
closest-to@1.0.1 x 116,156 ops/sec ±1.02% (85 runs sampled)
closest-to@2.0.0 x 860,497 ops/sec ±1.09% (83 runs sampled)
``