All files includes.ts

100% Statements 15/15
100% Branches 4/4
100% Functions 4/4
100% Lines 13/13

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 618x         9x 9x 3x     2x                                   8x 5x         9x 9x 4x     2x                                     8x 6x  
import { purry } from "./purry";
 
 
 
function _includesAny<T>(data: ReadonlyArray<T>, includes: ReadonlyArray<T>) {
    for (const i of includes) {
        if (data.indexOf(i) !== -1) {
            return true
        }
    }
    return false
}
 
/**
 * Checks if @param data contains any element of @param includes and returns boolean
 * @param data - Value to check
 * @param includes - Provided list
 * @signature
 *    P.includesAny(sourceList, includeList)
 * @signature
 *    P.includesAny(includeList)(sourceList)
 * @example
 *    P.includesAny(['apple','microsoft','tesla','samsung'],['apple', 'xiomi']) //=> true; Source list contains "apple"
 *    P.includesAny(['apple', 'microsoft'])(['samsung', 'tesla']) //=> false // Source list does not include any of options
 * @category Array, Pipe
 */
export function includesAny<T>(data: ReadonlyArray<T>, includes: ReadonlyArray<T>): boolean
export function includesAny<T>(includes: ReadonlyArray<T>): (data: ReadonlyArray<T>) => boolean
export function includesAny() {
    return purry(_includesAny, arguments);
}
 
 
function _includesEvery<T>(data: ReadonlyArray<T>, includes: ReadonlyArray<T>) {
    for (const i of includes) {
        if (data.indexOf(i) === -1) {
            return false
        }
    }
    return true
}
 
 
/**
 * Checks if @param data contains every element of @param includes and returns boolean
 * @param data - Value to check
 * @param includes - Provided list
 * @signature
 *    P.includesEvery(sourceList, includeList)
 * @signature
 *    P.includesEvery(includeList)(sourceList)
 * @example
 *    P.includesEvery(['apple','microsoft','tesla','samsung'],['apple', 'microsoft']) //=> true; Source list contains "apple" and 'microsoft'
 *    P.includesEvery(['apple', 'microsoft'])(['samsung', 'tesla', 'apple']) //=> false // Source list does not include every of options
 * @category Array, Pipe
 */
export function includesEvery<T>(data: ReadonlyArray<T>, includes: ReadonlyArray<T>): boolean
export function includesEvery<T>(includes: ReadonlyArray<T>): (data: ReadonlyArray<T>) => boolean
export function includesEvery() {
    return purry(_includesEvery, arguments);
}