JSPM

first-match

0.0.1
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 468738
  • Score
    100M100P100Q176437F
  • License MIT

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

Package Exports

  • first-match

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (first-match) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

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