UNPKG

@rxjs-ninja/rxjs-array

Version:

Operators for RxJS for filtering with boolean logic

39 lines (38 loc) 1.43 kB
/** * @packageDocumentation * @module Array */ import { PredicateFn } from '../types/generic-methods'; import { OperatorFunction } from 'rxjs'; /** * Returns an Observable that emits a boolean when all values in the source Array or Set return truthy using Array.some * When working with data, if the array contains numbers `0` will be returned as a value to the [[PredicateFn]], but all * other falsy values will be ignored * * @category Query * * @see The [[filterSome]] operator returns the array value instead of boolean * * @typeParam T Item type contained in the Array or Set * * @param predicate Optional [[PredicateFn]] used to get a truthy value of array values * * @example * Return a boolean value if some of the elements are truthy * ```ts * const input = [ [0, 0, 0], [0, 0, 1], [1, 1, 1] ] * from(input).pipe(some()).subscribe() * ``` * Output: `false, true, true` * * @example * Return a boolean value if some of the elements are truthy with a predicate * ```ts * const input = [ ['RxJS', 'Rocks'], ['RxJS', 'Ninja'], ['Foo', 'Bar'] ] * fromArray(input).pipe(some(v => v === 'RxJS')).subscribe() * ``` * Output: `true, true, false` * * @returns An Observable that emits a boolean when all values in source array return truthy */ export declare function some<T extends unknown>(predicate?: PredicateFn<T>): OperatorFunction<Iterable<T>, boolean>;