1.0.0 • Published 3 years ago

find-with v1.0.0

Weekly downloads
3
License
MIT
Repository
github
Last release
3 years ago

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.