helper.esm.js 762 B

12345678910111213141516171819202122
  1. const empty = obj => Object.keys(obj).length === 0;
  2. const extend = (listToExtend, list) =>
  3. // eslint-disable-next-line prefer-spread
  4. listToExtend.push.apply(listToExtend, list);
  5. const translate = (string, chrMap) => {
  6. const tempArray = string.split('');
  7. return tempArray.map(char => chrMap[char] || char).join('');
  8. };
  9. // sort on i primary, j secondary
  10. const sorted = matches => matches.sort((m1, m2) => m1.i - m2.i || m1.j - m2.j);
  11. const buildRankedDictionary = orderedList => {
  12. const result = {};
  13. let counter = 1; // rank starts at 1, not 0
  14. orderedList.forEach(word => {
  15. result[word] = counter;
  16. counter += 1;
  17. });
  18. return result;
  19. };
  20. export { buildRankedDictionary, empty, extend, sorted, translate };
  21. //# sourceMappingURL=helper.esm.js.map