diff --git a/src/HashImage.js b/src/HashImage.js index 948f028..3f71369 100644 --- a/src/HashImage.js +++ b/src/HashImage.js @@ -7,7 +7,7 @@ export class HashImage { constructor(buffer) { if (!(buffer instanceof Uint8Array)) { throw new Error( - "Invalid parameter, please use a buffer or an instance of Uint8Array" + "Invalid parameter, please use a buffer or an instance of Uint8Array", ); } this.buffer = buffer; @@ -19,14 +19,14 @@ export class HashImage { return new HashImage(buffer); } catch (err) { throw new Error( - "Error on image download, make sure you are passing a valid string url" + "Error on image download, make sure you are passing a valid string url", ); } } async phash() { const data = await imageFromBuffer(this.buffer); - const hexHash = await blockhash.bmvbhash(getImageData(data), 8); + const hexHash = blockhash.bmvbhash(getImageData(data), 8); const hash = hexToBin(hexHash); return new PHash(hash); } diff --git a/src/PHash.js b/src/PHash.js index e6b26f6..e3105ab 100644 --- a/src/PHash.js +++ b/src/PHash.js @@ -2,7 +2,7 @@ export class PHash { constructor(hash) { if (typeof hash !== "string") { throw new Error( - "Can't construct a PHash instance with a non-string value" + "Can't construct a PHash instance with a non-string value", ); } const isNonBinary = hash @@ -11,7 +11,7 @@ export class PHash { .some((chr) => chr !== "0" && chr !== "1"); if (isNonBinary) { throw new Error( - "Can't construct a PHash instance with a non-binary string value" + "Can't construct a PHash instance with a non-binary string value", ); } this.hash = hash.trim(); diff --git a/src/lib.js b/src/lib.js index 51d9a93..494456d 100644 --- a/src/lib.js +++ b/src/lib.js @@ -1,4 +1,4 @@ -import HashImage from "./HashImage.js"; -import PHash from "./PHash.js"; +import { HashImage } from "./HashImage.js"; +import { PHash } from "./PHash.js"; export default { HashImage, PHash }; diff --git a/test/index.test.js b/test/index.test.js index d84c59f..866bf73 100644 --- a/test/index.test.js +++ b/test/index.test.js @@ -28,7 +28,7 @@ describe("Test HashImage", () => { it("Can't create an instance from an invalid url", async () => { expect.assertions(1); await expect(HashImage.fromUrl("invalid-url")).rejects.toThrowError( - "Error on image download, make sure you are passing a valid string url" + "Error on image download, make sure you are passing a valid string url", ); }); @@ -51,7 +51,7 @@ describe("Test HashImage", () => { expect.assertions(1); const image = new HashImage(testBuffer); await expect(image.compare("asdfsdf")).rejects.toThrowError( - "Can't compare with a non HashImage value" + "Can't compare with a non HashImage value", ); }); }); @@ -69,7 +69,7 @@ describe("Test PHash", () => { new PHash(2); } catch (err) { expect(err.message).toBe( - "Can't construct a PHash instance with a non-string value" + "Can't construct a PHash instance with a non-string value", ); } }); @@ -80,7 +80,7 @@ describe("Test PHash", () => { new PHash("dfgdfg"); } catch (err) { expect(err.message).toBe( - "Can't construct a PHash instance with a non-binary string value" + "Can't construct a PHash instance with a non-binary string value", ); } });