Skip to content

Commit 4e16425

Browse files
committed
util: remove class
1 parent f4f71de commit 4e16425

1 file changed

Lines changed: 3 additions & 15 deletions

File tree

lib/util.js

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -122,24 +122,10 @@ let styleCache;
122122

123123
const kHexStyleCacheMax = 256;
124124

125-
class HexStyleFIFOCache {
126-
#cache = new SafeMap();
127-
128-
get(key) {
129-
return this.#cache.get(key);
130-
}
131-
132-
set(key, value) {
133-
if (this.#cache.size >= kHexStyleCacheMax)
134-
this.#cache.delete(this.#cache.keys().next().value);
135-
this.#cache.set(key, value);
136-
}
137-
}
138-
139125
let hexStyleCache;
140126

141127
function getHexStyleCache() {
142-
hexStyleCache ??= new HexStyleFIFOCache();
128+
hexStyleCache ??= new SafeMap();
143129
return hexStyleCache;
144130
}
145131

@@ -180,6 +166,8 @@ function getHexStyle(hex) {
180166
openSeq: kEscape + rgbToAnsi24Bit(r, g, b) + kEscapeEnd,
181167
closeSeq: kHexCloseSeq,
182168
};
169+
if (cache.size >= kHexStyleCacheMax)
170+
cache.delete(cache.keys().next().value);
183171
cache.set(hex, style);
184172
return style;
185173
}

0 commit comments

Comments
 (0)