Need private packages and team management tools?Check out npm Teams »

some-truthy-right

1.1.10 • Public • Published

someTruthyRight

Checks if the callback returns truthy for any element of the array. Iteration is stopped once the callback returns truthy

Return the truthy value or the last falsy value if none of the iteration returns truthy

Run over the given array from right to left

Usage: someTruthyRight<T, R>(list: Array<T>, callback: (value: T, index: number, list: Array<T>) => R): R

import { someTruthyRight } from 'some-truthy-right'
 
someTruthyRight([0, 1, 2], num => num) // Return the first truthy value it found, from the right to left
// Output: 2
someTruthyRight([0, false, undefined, null], falsy => falsy) // Return the last falsy value if non of the given items is truthy, from the right to left
// Output: 0

This module exported from utilizes project.

Install

npm i some-truthy-right

DownloadsWeekly Downloads

0

Version

1.1.10

License

MIT

Unpacked Size

3.54 kB

Total Files

5

Last publish

Collaborators

  • avatar