Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inconsistent colorthief imports leads to crash in tests #248

Open
tbragaf opened this issue Sep 13, 2023 · 0 comments
Open

Inconsistent colorthief imports leads to crash in tests #248

tbragaf opened this issue Sep 13, 2023 · 0 comments

Comments

@tbragaf
Copy link

tbragaf commented Sep 13, 2023

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant