-
-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
use case-insensitive Set-like construct to avoid lot of toLowerCase() (…
- Loading branch information
1 parent
5644203
commit b7f2fa5
Showing
6 changed files
with
73 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { strEquals } from "./string-utils.js" | ||
|
||
/** | ||
* @description A Set-like construct to search CSS keywords in a case-insensitive way | ||
*/ | ||
export class KeywordSet { | ||
|
||
/** @param {string[]} items */ | ||
constructor(items) { | ||
/** @type {string[]} */ | ||
this.set = items | ||
} | ||
|
||
/** @param {string} item */ | ||
has(item) { | ||
let len = this.set.length | ||
|
||
for (let index = 0; index < len; index++) { | ||
if (strEquals(this.set[index], item)) { | ||
return true | ||
} | ||
} | ||
return false | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters