createMapWithSet.cjs 612 B

12345678910111213141516171819202122232425
  1. // NOTICE: This file is generated by Rollup. To modify it,
  2. // please instead edit the ESM counterpart and rebuild with Rollup (npm run build).
  3. 'use strict';
  4. /**
  5. * Create a map with unique sets of values from a record.
  6. *
  7. * @template T
  8. * @param {Record<string, T | T[]>} record
  9. * @returns {Map<string, Set<T>>}
  10. */
  11. function createMapWithSet(record) {
  12. /** @type {Map<string, Set<T>>} */
  13. const map = new Map();
  14. for (const [key, value] of Object.entries(record)) {
  15. const list = Array.isArray(value) ? value : [value];
  16. map.set(key, new Set(list));
  17. }
  18. return map;
  19. }
  20. module.exports = createMapWithSet;