UNPKG

object-str-find

Version:

Find substring or match regexp in the object and his inner objects.

14 lines (11 loc) 332 B
const { isRegExp } = require('./utils') const matchValue = (objectValue, searchValue) => { if (typeof searchValue === 'string') { return objectValue.toLowerCase().includes(searchValue.toLowerCase()) } if (isRegExp(searchValue)) { return searchValue.test(objectValue) } return false } module.exports = matchValue