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;
​
Copy link