find-with
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

find-with Travis CI Build Status

Find the item in an array with the highest computed value.

NPM Badge

Install

npm install find-with

Usage

const findWith = require("find-with")

findWith(["a", "abc", "ab"], item => item.length)
//=> "abc"

findWith.multiple(["a", "abc", "abc", "ab"], item => item.length)
//=> ["abc", "abc"]

API

findWith(array, predicate)

Find the item in an array with the highest computed value.

findWith.multiple(array, predicate)

Find the items in an array with the highest computed values.

array

Type: array

The array to find the items from.

predicate

Type: (item, index, array) => number

A predicate that is provided with each item in the array.

item

The item in the array.

index

The index of the item in the array.

array

The array.

Package Sidebar

Install

npm i find-with

Weekly Downloads

0

Version

1.0.0

License

MIT

Unpacked Size

4.68 kB

Total Files

6

Last publish

Collaborators

  • richienb