@yoroi/common
Version:
The Common package of Yoroi SDK
34 lines (33 loc) • 909 B
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.cacheResolveRecordsSource = void 0;
var _recordWithEtag = require("./record-with-etag");
var _isExpired = require("./is-expired");
const cacheResolveRecordsSource = _ref => {
let {
ids,
cachedInfosWithoutRecord
} = _ref;
const toFetch = [];
const fromCache = [];
ids.forEach(id => {
const cachedRecord = cachedInfosWithoutRecord.get(id);
if (cachedRecord) {
if ((0, _isExpired.isExpired)(cachedRecord)) {
toFetch.push((0, _recordWithEtag.recordWithETag)(id, cachedRecord.hash));
} else {
fromCache.push(id);
}
} else {
toFetch.push((0, _recordWithEtag.recordWithETag)(id));
}
});
return {
toFetch,
fromCache
};
};
exports.cacheResolveRecordsSource = cacheResolveRecordsSource;
//# sourceMappingURL=cache-resolve-records-source.js.map