From 244b46e1cf5b2b4645c4bbf6193f8dbbf7502c2c Mon Sep 17 00:00:00 2001 From: Pridon Tetradze Date: Tue, 20 Dec 2022 19:32:07 +0400 Subject: linting, type definitions & cleanup (#12) --- src/util/cache.ts | 10 ++++++---- src/util/logger.ts | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) (limited to 'src/util') diff --git a/src/util/cache.ts b/src/util/cache.ts index df52f89..75a91b9 100644 --- a/src/util/cache.ts +++ b/src/util/cache.ts @@ -4,11 +4,13 @@ import { existsSync, } from "https://deno.land/std@0.78.0/fs/mod.ts"; import { environment } from "../environment/environment.ts"; +import { Country } from "../models/country.model.ts"; +import { FlagAscii } from "../models/flag-ascii.model.ts"; export class Cache { path = environment.cacheDir; - public saveJson(name: string, data: {}) { + public saveJson(name: string, data: Country[] | FlagAscii[]) { ensureDirSync(this.path); Deno.writeTextFileSync( @@ -22,11 +24,11 @@ export class Cache { Deno.writeTextFileSync(join(this.path, `${name}.txt`), value); } - public readJson(name: string): {} | [] | undefined { + public readJson(name: string): any { let data; try { data = Deno.readTextFileSync(join(this.path, `${name}.json`)); - } catch (err) { + } catch { return undefined; } return JSON.parse(data); @@ -35,7 +37,7 @@ export class Cache { public readTxt(name: string) { try { return Deno.readTextFileSync(join(this.path, `${name}.txt`)); - } catch (err) { + } catch { return undefined; } } diff --git a/src/util/logger.ts b/src/util/logger.ts index 49dcd86..34de473 100644 --- a/src/util/logger.ts +++ b/src/util/logger.ts @@ -21,7 +21,7 @@ export class Logger { public progress( current: number, total: number, - config?: { title: string; description: string } + config?: { title?: string; description: string } ) { console.clear(); if (config?.title) { -- cgit v1.2.3