Open tbragaf opened 1 year ago
I'm creating my own function which internally uses the GetPalette function. When using it in development mode, I can make it work simply by:
import Colorthief from "colorthief"; function getPaletteFromImage(img: HTMLImageElement, colorsCount: number, quality: number): string[] { const colorthief = new Colorthief(); var palette = colorthief.getPalette(img, colorsCount, quality); // ... }
However, this fails when running tests stating the Colorthief is not defined .
I noticed that you export the ColorThief function as a default in https://github.com/lokesh/color-thief/blob/master/src/color-thief.js#L147. You then use it by creating an object in https://github.com/lokesh/color-thief/blob/master/examples/js/demo.js#L1.
But in your tests, you don't create any object, and simply use a function. https://github.com/lokesh/color-thief/blob/master/test/node-test.js#L17
Why is that?
Thank you, Tiago
I'm creating my own function which internally uses the GetPalette function. When using it in development mode, I can make it work simply by:
However, this fails when running tests stating the Colorthief is not defined .
I noticed that you export the ColorThief function as a default in https://github.com/lokesh/color-thief/blob/master/src/color-thief.js#L147. You then use it by creating an object in https://github.com/lokesh/color-thief/blob/master/examples/js/demo.js#L1.
But in your tests, you don't create any object, and simply use a function. https://github.com/lokesh/color-thief/blob/master/test/node-test.js#L17
Why is that?
Thank you, Tiago