vue3-core/packages/shared/src/makeMap.ts

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

17 lines
457 B
TypeScript
Raw Normal View History

/**
* 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.
*/
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)
}