ujh/fountainpencompanion

View on GitHub
app/javascript/src/currently_inked/table/match.js

Summary

Maintainability
A
1 hr
Test Coverage
import { matchSorter } from "match-sorter";

/**
 * @param {any[]} rows
 * @param {string} id
 * @param {string} filterValue
 * @returns {any[]}
 */
export function fuzzyMatch(rows, _, filterValue) {
  const attrs = ["ink_name", "pen_name", "comment"];
  return matchSorter(rows, filterValue.replace(/\s+/gi, ""), {
    keys: [(row) => attrs.map((a) => row.values[a]).join("")]
  });
}