Introducing Socket Firewall: Free, Proactive Protection for Your Software Supply Chain.Learn More
Socket
Book a DemoInstallSign in
Socket

@bemoje/arr-first-where

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install
Package was removed
Sorry, it seems this package was removed from the registry

@bemoje/arr-first-where

Return the first element of an array where the callback returns true.

unpublished
latest
Source
npmnpm
Version
1.0.2
Version published
Maintainers
1
Created
Source

@bemoje/arr-first-where

Return the first element of an array where the callback returns true.

Version

NPM version

Travis CI

dependencies

Dependencies

dependencies

Stats

NPM downloads Forks

Donate

Buy Me A Beer donate button PayPal donate button

Installation

npm install @bemoje/arr-first-where
npm install --save @bemoje/arr-first-where
npm install --save-dev @bemoje/arr-first-where

Usage

import arrFirstWhere from '@bemoje/arr-first-where'

const arr = [1, 2, 3, 4, 5]

arrFirstWhere(arr, (element) => {
	return element >= 3
})
//=> 3

arrFirstWhere(arr, (element) => {
	return element >= 6
})
//=> null

Tests

Uses Jest to test module functionality. Run tests to get coverage details.

npm run test

API

arrFirstWhere

Return the first element of an array where the callback returns true.

Parameters
  • arr Array The array to iterate

  • callback predicate The callback(element, index, array): boolean

Returns

any The first element to satisfy the condition

predicate

Type: Function

Parameters
  • element any The current array element

  • index number The current index

  • array Array The array being itereated

Returns

boolean

Keywords

return

FAQs

Package last updated on 30 Apr 2020

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