makeMap.ts 431 B

1234567891011121314
  1. /**
  2. * Make a map and return a function for checking if a key
  3. * is in that map.
  4. * IMPORTANT: all calls of this function must be prefixed with
  5. * \/\*#\_\_PURE\_\_\*\/
  6. * So that rollup can tree-shake them if necessary.
  7. */
  8. /*! #__NO_SIDE_EFFECTS__ */
  9. export function makeMap(str: string): (key: string) => boolean {
  10. const map = Object.create(null)
  11. for (const key of str.split(',')) map[key] = 1
  12. return val => val in map
  13. }