Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

first-match

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

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()

  • 0.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
244K
increased by6%
Maintainers
1
Weekly downloads
 
Created
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

Package last updated on 05 Jan 2013

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc