# first-match

> Find the first element in an array that passes a callback test. Equivalent to underscore.find()

Latest version **0.0.1** (published 2013-01-05) · MIT license · 0 weekly downloads

## Install

```sh
npm install first-match
pnpm add first-match
yarn add first-match
bun add first-match
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.1 |
| Published | 2013-01-05 |
| First published | 2013-01-05 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Hugh Kennedy |
| Maintainers | hughsk |
| Keywords | element, array, first, truth, test, find |

## Links

- npm: https://www.npmjs.com/package/first-match
- Repository: https://github.com/hughsk/first-match
- npm.io page: https://npm.io/package/first-match

## Alternatives

- [duck](https://npm.io/package/duck.md) — 4.2M weekly downloads
- [ava](https://npm.io/package/ava.md) — 560.2K weekly downloads
- [storybook-addon-module-mock](https://npm.io/package/storybook-addon-module-mock.md) — 71.7K weekly downloads
- [vest](https://npm.io/package/vest.md) — 50.1K weekly downloads
- [@ethereum-waffle/mock-contract](https://npm.io/package/@ethereum-waffle/mock-contract.md) — 40.0K weekly downloads

## Recent versions

- 0.0.1 (latest) — 2013-01-05

## README

# first-match [![Build Status](https://travis-ci.org/hughsk/first-match.png?branch=master)](https://travis-ci.org/hughsk/first-match?branch=master) #

Finds the first element in an array that passes a callback test.
Equivalent to [_.find()](http://underscorejs.org#find).

## Installation ##

``` bash
npm install first-match
```

## Usage ##

`first(array, [iterator], [context])`. If an iterator is not passed, the method
will just return the first truthy value in the array. The context defaults to
the array being evaluated.

``` javascript
var first = require('first-match')
  , array = [0, 1, 2, 3, 4, 5]

first(array)                               // 1
first(array, function(n) { return n > 3 }) // 4
first(array, function(n) { return n % 2 }) // 1
first(array, function(n) { return n + 2 > this.length }) // 5
```

---
_Source: https://npm.io/package/first-match · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
