diff --git a/src/plugin/getLuminance/index.ts b/src/plugin/getLuminance/index.ts index cae9f82..5a9f9e8 100644 --- a/src/plugin/getLuminance/index.ts +++ b/src/plugin/getLuminance/index.ts @@ -12,8 +12,8 @@ const f = (x: number) => { const channel = x / 255; return channel <= 0.040_45 ? channel / 12.92 - : Math.pow(((channel + 0.055) / 1.055), 2.4); -} + : Math.pow((channel + 0.055) / 1.055, 2.4); +}; /** * Returns a number (float) representing the luminance of a color. @@ -21,12 +21,12 @@ const f = (x: number) => { export const getLuminance: MyColorPlugin = (_, c, cf) => { const proto = c.prototype as OhColorClass; const getRGB = proto.rgba; - proto.getLuminance = function() { + proto.getLuminance = function () { const [r, g, b] = getRGB.bind(this)(); return 0.2126 * f(r) + 0.7152 * f(g) + 0.0722 * f(b); - } + }; return cf as OhColorFactory; -} +}; -export default getLuminance +export default getLuminance; diff --git a/src/plugin/index.ts b/src/plugin/index.ts index 31ed03a..faab6c8 100644 --- a/src/plugin/index.ts +++ b/src/plugin/index.ts @@ -1,4 +1,4 @@ export { inputHex } from "./inputHex"; export { outputHex } from "./outputHex"; -export { inputNamed } from './inputNamed'; -export { getLuminance } from './getLuminance'; +export { inputNamed } from "./inputNamed"; +export { getLuminance } from "./getLuminance"; diff --git a/test/index.test.ts b/test/index.test.ts index e6e22c1..cd5f7bd 100644 --- a/test/index.test.ts +++ b/test/index.test.ts @@ -27,7 +27,7 @@ describe("mycolor", () => { const { inputHex, getLuminance } = await import("../src/plugin"); const mycolor2 = mycolor.extend(inputHex).extend(getLuminance); expect(mycolor2("red").getLuminance()).toBe(0.2126); - }) + }); }); describe("mycolor built-in plugins", () => { diff --git a/test/plugin/get-luminance.test.ts b/test/plugin/get-luminance.test.ts index 71c3470..fb9e7b4 100644 --- a/test/plugin/get-luminance.test.ts +++ b/test/plugin/get-luminance.test.ts @@ -1,6 +1,6 @@ import { expect, it, describe } from "vitest"; import { mycolor } from "../../src"; -import { getLuminance } from "../../src/plugin" +import { getLuminance } from "../../src/plugin"; describe("mycolor plugin: getLuminance", () => { it("should get luminance", () => { @@ -8,4 +8,4 @@ describe("mycolor plugin: getLuminance", () => { expect(mycolor2(255, 255, 0, 1).getLuminance()).toBe(0.9278); }); -}) +});