f-hj/slsk-client

View on GitHub
lib/share/matches.js

Summary

Maintainability
A
0 mins
Test Coverage
module.exports = (str, query) => {
  let toBeMatched = str.toLowerCase()
  return query.toLowerCase().split(' ')
    .map(criterion => criterion.startsWith('-')
      ? toBeMatched.indexOf(criterion.substring(1)) === -1
      : toBeMatched.indexOf(criterion) !== -1)
    .reduce((a, b) => a && b, true)
}