contains

contains :: a → [ b ] → Boolean

Evaluates whether the defined value equals at least one of the elements of the given array. If a string is provided instead, it makes sure that value is its sub-string.

import contains from 'deep-waters/contains';

// works both with primitives
const isSubstring = contains('pre'); 

isSubstring('pre-something'); // → true
isSubstring('foo'); // → false

// or plain and nested objects
const containsObj = contains({  foo: 'bar', deep: { bar: 'foo' } });

containsObj([1, 2, 3, 'str', {  foo: 'bar', deep: { bar: 'foo' } }]); // → true;

Last updated