From 9a1e9f7231573064029a308bc3a04371f71b7877 Mon Sep 17 00:00:00 2001 From: sunilyadav840 Date: Tue, 5 Oct 2021 15:32:01 +0530 Subject: [PATCH] fixed eslint issue of ArrayByCache and ArrayByCache.test.ts --- .eslintignore | 2 -- .../GraphExplorerComponent/ArraysByKeyCache.test.ts | 10 +++++----- .../Graph/GraphExplorerComponent/ArraysByKeyCache.ts | 6 +++--- 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/.eslintignore b/.eslintignore index 3de1fdee0..479418ae7 100644 --- a/.eslintignore +++ b/.eslintignore @@ -44,8 +44,6 @@ src/Explorer/DataSamples/ContainerSampleGenerator.test.ts src/Explorer/DataSamples/ContainerSampleGenerator.ts src/Explorer/DataSamples/DataSamplesUtil.test.ts src/Explorer/DataSamples/DataSamplesUtil.ts -src/Explorer/Graph/GraphExplorerComponent/ArraysByKeyCache.test.ts -src/Explorer/Graph/GraphExplorerComponent/ArraysByKeyCache.ts src/Explorer/Graph/GraphExplorerComponent/D3ForceGraph.test.ts src/Explorer/Graph/GraphExplorerComponent/D3ForceGraph.ts src/Explorer/Graph/GraphExplorerComponent/EdgeInfoCache.ts diff --git a/src/Explorer/Graph/GraphExplorerComponent/ArraysByKeyCache.test.ts b/src/Explorer/Graph/GraphExplorerComponent/ArraysByKeyCache.test.ts index 78a835244..6dd526862 100644 --- a/src/Explorer/Graph/GraphExplorerComponent/ArraysByKeyCache.test.ts +++ b/src/Explorer/Graph/GraphExplorerComponent/ArraysByKeyCache.test.ts @@ -6,7 +6,7 @@ describe("Cache arrays by key", () => { const key = "key"; cache.insert(key, 1, 0); cache.clear(); - expect(cache.retrieve(key, 0, 1)).toBe(null); + expect(cache.retrieve(key, 0, 1)).toBe(undefined); }); it("should invalidate oldest key to keep cache size under maximum", () => { @@ -21,7 +21,7 @@ describe("Cache arrays by key", () => { cache.insert(key1, 2, 4); expect(cache.retrieve(key1, 0, 3)).toEqual([0, 2, 4]); - expect(cache.retrieve(key2, 1, 1)).toEqual(null); + expect(cache.retrieve(key2, 1, 1)).toEqual(undefined); }); it("should cache and retrieve cached page within boundaries", () => { @@ -39,7 +39,7 @@ describe("Cache arrays by key", () => { const key = "key"; cache.insert(key, 0, 0); cache.insert(key, 1, 1); - expect(cache.retrieve(key, 2, 1)).toEqual(null); + expect(cache.retrieve(key, 2, 1)).toEqual(undefined); }); it("should not retrieve cached page overlapping boundaries", () => { @@ -48,7 +48,7 @@ describe("Cache arrays by key", () => { cache.insert(key, 0, 0); cache.insert(key, 1, 1); cache.insert(key, 2, 2); - expect(cache.retrieve(key, 2, 4)).toEqual(null); + expect(cache.retrieve(key, 2, 4)).toEqual(undefined); }); it("should not insert non-contiguous element", () => { @@ -57,7 +57,7 @@ describe("Cache arrays by key", () => { cache.insert(key, 0, 0); cache.insert(key, 1, 1); cache.insert(key, 3, 3); - expect(cache.retrieve(key, 3, 1)).toEqual(null); + expect(cache.retrieve(key, 3, 1)).toEqual(undefined); }); it("should cache multiple keys", () => { diff --git a/src/Explorer/Graph/GraphExplorerComponent/ArraysByKeyCache.ts b/src/Explorer/Graph/GraphExplorerComponent/ArraysByKeyCache.ts index 0a4d8fd85..bc0ccc2f1 100644 --- a/src/Explorer/Graph/GraphExplorerComponent/ArraysByKeyCache.ts +++ b/src/Explorer/Graph/GraphExplorerComponent/ArraysByKeyCache.ts @@ -61,12 +61,12 @@ export class ArraysByKeyCache { * @param pageSize */ public retrieve(key: string, startIndex: number, pageSize: number): T[] | null { - if (!this.cache.hasOwnProperty(key)) { - return null; + if (!Object.prototype.hasOwnProperty.call(this.cache, key)) { + return undefined; } const elements = this.cache[key]; if (startIndex + pageSize > elements.length) { - return null; + return undefined; } return elements.slice(startIndex, startIndex + pageSize);