/**
* 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.
*/
function makeMap(str, expectsLowerCase) {
const map = Object.create(null);
const list = str.split(',');
for (let i = 0; i < list.length; i++) {
map[list[i]] = true;
}
return expectsLowerCase ? val => !!map[val.toLowerCase()] : val => !!map[val];
}
通过创建map,将传入的关键词str用,分隔生成一个数组,遍历这个数组,将数组的每个元素作为map键值对的键值,赋值为true,expectsLowerCase传入true代表需要将key转为小写字母,否则就不需要转