Skip to content

Commit

Permalink
style(layered-storage): unify the way existence is checked in core
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomaash committed Jan 26, 2020
1 parent fd2a42e commit 84a0144
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/layered-storage/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,13 +184,13 @@ export class LayeredStorageCore<

// Return cached value if it exists.
const cached = segmentCache.get(key);
if (cached) {
if (typeof cached !== "undefined") {
return cached;
}

// Search the layers from highest to lowest priority.
for (const layerData of this._layerDatas) {
if (layerData == null) {
if (typeof layerData === "undefined") {
// Empty layer.
continue;
}
Expand Down Expand Up @@ -249,7 +249,7 @@ export class LayeredStorageCore<
): { layerData: LayerData<KV>; segmentData: SegmentData<KV> } {
// Get or create the requested layer.
let layerData = this._data.get(layer);
if (layerData == null) {
if (typeof layerData === "undefined") {
layerData = new Map();
this._data.set(layer, layerData);

Expand All @@ -260,7 +260,7 @@ export class LayeredStorageCore<

// Get or create the requested segment on the layer.
let segmentData = layerData.get(segment);
if (segmentData == null) {
if (typeof segmentData === "undefined") {
segmentData = new Map();
layerData.set(segment, segmentData);

Expand Down

0 comments on commit 84a0144

Please sign in to comment.