first-mapped

0.2.0 • Public • Published

first-mapped

Returns the first truthy mapping of elements in an array.

It's a very small package that implements a pattern I kept seeing.

It's much like Array.find except it returns the value computed instead of the element that it's computed from

Installation

npm install --save first-mapped

Usage

const firstMapped = require('first-mapped')
 
let mapped = firstMapped([1, 2, 3], (val, index, arr) => {
  if (val === 3) {
    return 'HERE'
  } else {
    return false
  }
})
 
console.log(mapped) // HERE 

Readme

Keywords

Package Sidebar

Install

npm i first-mapped

Weekly Downloads

0

Version

0.2.0

License

ISC

Last publish

Collaborators

  • allain