1.0.1 • Published 4 years ago

@bemoje/arr-any v1.0.1

Weekly downloads
1
License
MIT
Repository
github
Last release
4 years ago

@bemoje/arr-any

Check whether a condition is true for any element of an array. The condition check is in the form of a callback.

Version

Travis CI

Dependencies

Stats

Donate

Installation

npm install @bemoje/arr-any
npm install --save @bemoje/arr-any
npm install --save-dev @bemoje/arr-any

Usage

import arrAny from '@bemoje/arr-any'

const arr = ['hi', 'there']

arrAny(arr, (element) => {
	return element === 'there'
})
//=> true

arrAny(arr, (element) => {
	return element.length === 5
})
//=> true

arrAny(arr, (element) => {
	return element.length > 5
})
//=> false

Tests

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

npm run test

API

arrAny

Check whether a condition is true for any element of an array. The condition check is in the form of a callback.

Parameters
  • arr Array The array to iterate

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

Returns

boolean

callback

Type: Function

Parameters
Returns

boolean