closest-to

WebJar for closest-to

License

License

MIT
GroupId

GroupId

org.webjars.npm
ArtifactId

ArtifactId

closest-to
Last Version

Last Version

2.0.0
Release Date

Release Date

Type

Type

jar
Description

Description

closest-to
WebJar for closest-to
Project URL

Project URL

http://webjars.org
Source Code Management

Source Code Management

https://github.com/michaelrhodes/closest-to

Download closest-to

How to add to project

<!-- https://jarcasting.com/artifacts/org.webjars.npm/closest-to/ -->
<dependency>
    <groupId>org.webjars.npm</groupId>
    <artifactId>closest-to</artifactId>
    <version>2.0.0</version>
</dependency>
// https://jarcasting.com/artifacts/org.webjars.npm/closest-to/
implementation 'org.webjars.npm:closest-to:2.0.0'
// https://jarcasting.com/artifacts/org.webjars.npm/closest-to/
implementation ("org.webjars.npm:closest-to:2.0.0")
'org.webjars.npm:closest-to:jar:2.0.0'
<dependency org="org.webjars.npm" name="closest-to" rev="2.0.0">
  <artifact name="closest-to" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.webjars.npm', module='closest-to', version='2.0.0')
)
libraryDependencies += "org.webjars.npm" % "closest-to" % "2.0.0"
[org.webjars.npm/closest-to "2.0.0"]

Dependencies

There are no dependencies for this project. It is a standalone project that does not depend on any other jars.

Project Modules

There are no modules declared in this project.

closest-to

closest-to finds the closest value to a given target in a sorted array of numbers

Build status

Browser support

Install

npm install closest-to

Usage

require('closest-to')(needle, haystack, [returnIndex])
require('closest-to/nd')(needle, haystack, [returnIndex])
closest(10, [1, 3, 5, 7, 9])
> 9
closest(10, [1, 3, 5, 7, 9], true)
> 4
ndclosest([1, 2], [[1, 1], [2, 3], [3, 4]])
> [1, 1]

ndclosest([1, 2], [[1, 1], [2, 3], [3, 4]], true)
> 0

Benchmarks

[email protected] x 116,156 ops/sec ±1.02% (85 runs sampled)
[email protected] x 860,497 ops/sec ±1.09% (83 runs sampled)

License

MIT

Versions

Version
2.0.0