1
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:
2022-10-05 15:26:37 -04:00
parent b64795ae57
commit a2ac54d6a7
6 changed files with 281 additions and 267 deletions

View 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;