jobiqo-cl
Version:
[](https://circleci.com/gh/jobiqo/jobiqo-cl)
25 lines (19 loc) • 945 B
JavaScript
;
Object.defineProperty(exports, '__esModule', { value: true });
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
var React = require('react');
var React__default = _interopDefault(React);
var matchSorter_esm = require('../../node_modules/match-sorter/dist/match-sorter.esm.js');
var index = require('../../node_modules/use-throttle/lib/index.js');
/**
* @file index.tsx
*
* @fileoverview Helper hook to match characters in a list of items.
* Taken a list and a word it will find elements
* of the list that match the word. Also can take a pattern for how to match the word to the items.
*/
const useMatch = (data, term, pattern) => {
const throttledTerm = index.useThrottle(term, 100);
return React.useMemo(() => (term.trim() === '' ? [] : matchSorter_esm.default(data, term, pattern)), [throttledTerm]);
};
exports.useMatch = useMatch;