Additional derive cleanups (#4308)

* Additional derive cleanups

* unwrapNumber

* Adjust
This commit is contained in:
Jaco
2021-12-09 12:54:51 +02:00
committed by GitHub
parent 23717bb180
commit 969151c4a7
8 changed files with 48 additions and 62 deletions
+6
View File
@@ -26,6 +26,12 @@ export function getEraMultiCache <T> (CACHE_KEY: string, eras: EraIndex[], withA
return cached;
}
export function setEraCache <T extends { era: EraIndex }> (cacheKey: string, withActive: boolean, value: T): T {
!withActive && deriveCache.set(cacheKey, value);
return value;
}
export function setEraMultiCache <T extends { era: EraIndex }> (CACHE_KEY: string, withActive: boolean, values: T[]): T[] {
!withActive && values.forEach((v) => deriveCache.set(`${CACHE_KEY}-${v.era.toString()}`, v));