From 2213fa761aa50701a8ed9a58893d9a7f2a00a2ac Mon Sep 17 00:00:00 2001 From: ful1e5 <24286590+ful1e5@users.noreply.github.com> Date: Tue, 26 Jan 2021 12:56:33 +0530 Subject: [PATCH] =?UTF-8?q?=E2=9A=A1=20Utils=20renamed?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/utils/matchImages.ts | 19 ------------------- src/utils/saveFrames.ts | 16 ---------------- src/utils/{htmlTemplate.ts => toHTML.ts} | 4 ++-- 3 files changed, 2 insertions(+), 37 deletions(-) delete mode 100644 src/utils/matchImages.ts delete mode 100644 src/utils/saveFrames.ts rename src/utils/{htmlTemplate.ts => toHTML.ts} (77%) diff --git a/src/utils/matchImages.ts b/src/utils/matchImages.ts deleted file mode 100644 index 3c584a1..0000000 --- a/src/utils/matchImages.ts +++ /dev/null @@ -1,19 +0,0 @@ -import { PNG } from "pngjs"; -import pixelmatch from "pixelmatch"; - -interface MatchImagesArgs { - img1Buff: Buffer; - img2Buff: Buffer; -} - -export const matchImages = ({ img1Buff, img2Buff }: MatchImagesArgs) => { - const img1 = PNG.sync.read(img1Buff); - const img2 = PNG.sync.read(img2Buff); - const { width, height } = img1; - - const diff = new PNG({ width, height }); - - return pixelmatch(img1.data, img2.data, diff.data, width, height, { - threshold: 0.1, - }); -}; diff --git a/src/utils/saveFrames.ts b/src/utils/saveFrames.ts deleted file mode 100644 index f3be527..0000000 --- a/src/utils/saveFrames.ts +++ /dev/null @@ -1,16 +0,0 @@ -import fs from "fs"; -import path from "path"; -import { bitmapsDir } from "../config"; - -export interface Frames { - [fileName: string]: { - buffer: Buffer; - }; -} - -export const saveFrames = (frames: Frames) => { - for (let [fileName, { buffer }] of Object.entries(frames)) { - const out_path = path.resolve(bitmapsDir, fileName); - fs.writeFileSync(out_path, buffer, { encoding: "binary" }); - } -}; diff --git a/src/utils/htmlTemplate.ts b/src/utils/toHTML.ts similarity index 77% rename from src/utils/htmlTemplate.ts rename to src/utils/toHTML.ts index 4224c27..e64ef19 100644 --- a/src/utils/htmlTemplate.ts +++ b/src/utils/toHTML.ts @@ -15,5 +15,5 @@ export const template = ` `; -export const htmlTemplate = (svg: string) => - template.replace("", svg); +export const toHTML = (svgData: string): string => + template.replace("", svgData);