@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.

Usage no npm install needed!

<script type="module">
  import bemojeArrAny from 'https://cdn.skypack.dev/@bemoje/arr-any';
</script>

README

@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

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