@yoroi/common
Version:
The Common package of Yoroi SDK
28 lines (27 loc) • 663 B
JavaScript
;
import { isExpired } from './is-expired';
import { recordWithETag } from './record-with-etag';
export const cacheResolveRecordsSource = ({
ids,
cachedInfosWithoutRecord
}) => {
const toFetch = [];
const fromCache = [];
ids.forEach(id => {
const cachedRecord = cachedInfosWithoutRecord.get(id);
if (cachedRecord) {
if (isExpired(cachedRecord)) {
toFetch.push(recordWithETag(id, cachedRecord.hash));
} else {
fromCache.push(id);
}
} else {
toFetch.push(recordWithETag(id));
}
});
return {
toFetch,
fromCache
};
};
//# sourceMappingURL=cache-resolve-records-source.js.map