scttcper / tinycolor

🎨 Color manipulation and conversion

Home Page:https://tinycolor.vercel.app

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Question about class usage

ewolfe opened this issue · comments

It feels a little weird or unnecessary to new up an instance. I was wondering why that design decision was made? What are your thoughts on exposing a function as well, the way @bgrins does in the original repo?

Also & aside from that, great work breathing new life into this! 👏

you bring up a good point. I'm working with bgrins on putting the updates back into the original project and one of the changes requested was exactly that. Backwards compatibility with v1 function or new creation of instances. I'll try to update this branch with those changes soon, as the other isn't on npm yet

It looks like its already there. The default export can be used as a function or a class.

const tinycolor = require('@ctrl/tinycolor')
tinycolor('red')