Socket
Socket
Sign inDemoInstall

first-match

Package Overview
Dependencies
0
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    first-match

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


Version published
Weekly downloads
204K
increased by5.32%
Maintainers
1
Install size
4.92 kB
Created
Weekly downloads
 

Readme

Source

first-match Build Status

Finds the first element in an array that passes a callback test. Equivalent to _.find().

Installation

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.

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

Keywords

FAQs

Last updated on 05 Jan 2013

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc