2020-06-10 05:02:27 +08:00
|
|
|
/**
|
|
|
|
* Make a map and return a function for checking if a key
|
|
|
|
* is in that map.
|
|
|
|
* IMPORTANT: all calls of this function must be prefixed with
|
|
|
|
* \/\*#\_\_PURE\_\_\*\/
|
|
|
|
* So that rollup can tree-shake them if necessary.
|
|
|
|
*/
|
2024-03-13 21:48:45 +08:00
|
|
|
|
|
|
|
/*! #__NO_SIDE_EFFECTS__ */
|
2019-10-16 00:11:08 +08:00
|
|
|
export function makeMap(
|
|
|
|
str: string,
|
|
|
|
expectsLowerCase?: boolean,
|
|
|
|
): (key: string) => boolean {
|
2023-11-16 17:02:17 +08:00
|
|
|
const set = new Set(str.split(','))
|
|
|
|
return expectsLowerCase
|
|
|
|
? val => set.has(val.toLowerCase())
|
|
|
|
: val => set.has(val)
|
2019-10-16 00:11:08 +08:00
|
|
|
}
|