Skip to content

Commit

Permalink
Change KeywordSet to use Set().has(item.toLowerCase())
Browse files Browse the repository at this point in the history
  • Loading branch information
Bart Veneman committed Aug 6, 2024
1 parent 3088ea1 commit 491cd80
Showing 1 changed file with 3 additions and 12 deletions.
15 changes: 3 additions & 12 deletions src/keyword-set.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,16 @@
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
/** @type {Set<string>} */
this.set = new 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
return this.set.has(item.toLowerCase())
}
}

0 comments on commit 491cd80

Please sign in to comment.