mirror of
https://github.com/jakejarvis/jarv.is.git
synced 2025-09-16 17:55:32 -04:00
cache hex-to-rgba outputs
This commit is contained in:
9
lib/styles/utils/hex-to-rgba.ts
Normal file
9
lib/styles/utils/hex-to-rgba.ts
Normal file
@@ -0,0 +1,9 @@
|
||||
import hexToRgba from "hex-to-rgba";
|
||||
import mem from "mem";
|
||||
|
||||
// removes spaces from default hex-to-rgba output and caches the result
|
||||
const memoized = mem((color: string, alpha?: number) => hexToRgba(color, alpha).replace(/\s/g, ""), {
|
||||
cacheKey: (arguments_) => arguments_.join(","), // https://github.com/sindresorhus/mem#caching-strategy
|
||||
});
|
||||
|
||||
export default memoized;
|
Reference in New Issue
Block a user