mirror of
https://github.com/oven-sh/bun
synced 2026-02-02 15:08:46 +00:00
26 lines
580 B
JavaScript
26 lines
580 B
JavaScript
import Color from "color";
|
|
import tinycolor from "tinycolor2";
|
|
import { bench, group, run } from "../runner.mjs";
|
|
|
|
const inputs = ["#f00", "rgb(255, 0, 0)", "rgba(255, 0, 0, 1)", "hsl(0, 100%, 50%)"];
|
|
|
|
for (const input of inputs) {
|
|
group(`${input}`, () => {
|
|
if (typeof Bun !== "undefined") {
|
|
bench(`Bun.color() (${input})`, () => {
|
|
Bun.color(input, "css");
|
|
});
|
|
}
|
|
|
|
bench(`color (${input})`, () => {
|
|
Color(input).hex();
|
|
});
|
|
|
|
bench(`'tinycolor2' (${input})`, () => {
|
|
tinycolor(input).toHexString();
|
|
});
|
|
});
|
|
}
|
|
|
|
await run();
|