mrkeyoor.com_
Wed 23 Sept 00:37 UTC
npmUtilsupdated 22 Sept 2026

hsl-to-rgb-for-reals review

hsl-to-rgb-for-reals 1.1.1 is one CommonJS function: pass a hue from 0 up to but excluding 360, then saturation and lightness as fractions from 0 to 1, and it returns three rounded RGB channel values. The README example converts (223, 0.44, 0.56) to [93, 121, 192]. Version 1.1.1 fixes the missing module export in 1.0.0. Our browser build measured 0.9 KB minified and 0.5 KB gzipped. There is no CSS parser, alpha channel, formatting API, input validation, or TypeScript declaration.

Verdict

hsl-to-rgb-for-reals 1.1.1 installed in 0.6 seconds, used 1 MB on disk, bundled to 0.5 KB gzipped, and had 0 audit findings in our sandbox. Keep it when clean numeric HSL input and its exact rounded array are already part of the contract; new typed code can write this small conversion locally or choose color-convert.

We installed it

Lab card: what happened when we installed hsl-to-rgb-for-realsScreenshot of hsl-to-rgb-for-reals documentation
Install✓ · 0.6s1 package on disk · 1 MB
ImportESM import works · require() works · CommonJS package
Browser0.5 KBgzipped (0.9 KB minified), bundled with esbuild
Typesno TypeScript types found
Known vulns00 critical · 0 high · 0 moderate · 0 low (npm audit)

Answers from our run

Does hsl-to-rgb-for-reals install cleanly?

Yes. In a fresh container with an empty cache, npm install hsl-to-rgb-for-reals finished in 0.6s, leaving 1 package and 1 MB on disk. npm audit reported no known vulnerabilities.

How much does hsl-to-rgb-for-reals add to a browser bundle?

0.5 KB gzipped (0.9 KB minified) when the whole package is bundled for the browser with esbuild. Importing only part of it is usually smaller.

Does hsl-to-rgb-for-reals work with both ESM and CommonJS?

Yes. Both import 'hsl-to-rgb-for-reals' and require('hsl-to-rgb-for-reals') worked in Node 22 in our run. The package is published as CommonJS.

Does hsl-to-rgb-for-reals include TypeScript types?

No type declarations were found in our install, so TypeScript users need their own declarations.

hsl-to-rgb-for-reals or color-convert: which should you use?

color-convert: Use it for maintained conversions among many color models, including rounded and raw results. hsl-to-rgb-for-reals 1.1.1 installed in 0.6 seconds, used 1 MB on disk, bundled to 0.5 KB gzipped, and had 0 audit findings in our sandbox.

When should you not use hsl-to-rgb-for-reals?

You receive CSS strings such as hsl(223 44% 56%). The package accepts three numbers and contains no parser.

API stability5/5Version 1.1.1 exposes one positional function, and converter.js matches the README's contract: hue is measured in degrees, saturation and lightness are fractions, and the result is a rounded three-channel array. The release has remained unchanged since September 2019. That makes accidental API churn unlikely, although it also freezes the missing validation, unusual undefined-hue case, and CommonJS packaging.
Docs2/5The README states all 3 input ranges, supplies one checked conversion example, and warns that 1.0.0 forgot module.exports. That is enough for the intended call. It does not document the result of hue 360, out-of-range fractions, NaN, strings, the special [0, 0, 0] result for undefined hue, rounding at channel boundaries, ESM interoperability, CSS percentage conversion, or the absence of alpha and formatting support.
Maintenance1/5npm published 1.1.1 on September 24, 2019, and GitHub reports the repository's last push on the same date. The repository remains unarchived. It has 0 stars, 2 open issues and pull requests, and no later release. Consumers should plan to own any fixes, declarations, packaging changes, or validation wrappers they require rather than expect another upstream version.
Ecosystem2/5npm counted 5,154,844 downloads from August 18 through August 24, 2026, despite the repository having 0 stars. The package has 0 direct dependencies and fits almost any JavaScript build through its CommonJS export. Its surrounding ecosystem is minimal: there are no declarations, plugins, adapters, documentation site, companion packages, parsing helpers, or additional color-model conversions.

Use it if

  • Your code already holds HSL as three numbers and needs a rounded RGB array.
  • A 0.5 KB gzipped conversion function is preferable to a color toolkit with parsing and manipulation APIs.
  • The call site can enforce hue, saturation, and lightness ranges before conversion.
  • An existing application depends on the exact rounding and array output of version 1.1.1.
Skip it if

Setup reality

We installed hsl-to-rgb-for-reals 1.1.1 in a fresh Node 22 Bookworm container. npm finished in 0.6 seconds, left 1 package, and used 1 MB on disk. npm audit found 0 vulnerabilities at every severity. The published package is 48 KB unpacked, declares 0 direct and 0 peer dependencies, and uses the ISC license. Our esbuild check produced 0.9 KB minified and 0.5 KB gzipped.

The package is CommonJS with no exports map. require('hsl-to-rgb-for-reals') worked, and ESM import also worked through Node interoperability in our sandbox. No TypeScript declarations were present, so typed projects need a local declaration or an untyped boundary. There are no credentials, configuration files, native builds, install scripts, or runtime services. Version 1.1.1 exists because 1.0.0 forgot to export the function; the README says not to use that first release.

Callers must normalize inputs themselves. Hue uses the half-open interval [0, 360), while saturation and lightness use [0, 1]. The source does not parse percentages, clamp values, wrap 360 to 0, or reject NaN. An undefined hue returns [0, 0, 0], but other malformed input is not handled consistently. The returned three-item array is mutable and contains rounded channel numbers. Formatting rgb(), hexadecimal, or alpha values belongs in your wrapper.

Patterns

Convert HSL fractions to RGB convert-hsl

const hslToRgb = require('hsl-to-rgb-for-reals');

const rgb = hslToRgb(223, 0.44, 0.56);
console.log(rgb); // [93, 121, 192]

Saturation and lightness use 0 to 1 fractions. The function does not accept CSS percentage numbers.

Call the CommonJS export from ESM import-from-esm

import hslToRgb from 'hsl-to-rgb-for-reals';

console.log(hslToRgb(223, 0.44, 0.56));

ESM import worked through CommonJS interoperability in our Node 22 check. The package has no native ESM build or exports map.

Convert percentage components convert-percentages

const hslToRgb = require('hsl-to-rgb-for-reals');

function fromPercent(hue, saturation, lightness) {
  return hslToRgb(hue, saturation / 100, lightness / 100);
}

console.log(fromPercent(223, 44, 56));

Dividing by 100 adapts numeric percentages. This wrapper still does not parse an hsl(...) string.

Reject malformed HSL values validate-components

const hslToRgb = require('hsl-to-rgb-for-reals');

function convertChecked(h, s, l) {
  if (![h, s, l].every(Number.isFinite)) {
    throw new TypeError('HSL components must be finite numbers');
  }
  if (h < 0 || h >= 360 || s < 0 || s > 1 || l < 0 || l > 1) {
    throw new RangeError('HSL component outside supported range');
  }
  return hslToRgb(h, s, l);
}

converter.js performs no range check. Validate before calling it when values cross a trust boundary.

Normalize hue to 0 through 359 wrap-hue

const hslToRgb = require('hsl-to-rgb-for-reals');

const wrapHue = (degrees) => ((degrees % 360) + 360) % 360;
const rgb = hslToRgb(wrapHue(420), 0.8, 0.5);

Hue 360 is outside the documented interval. Wrapping converts both 360 and negative angles to an implemented branch.

Build a CSS rgb() value format-css-rgb

const hslToRgb = require('hsl-to-rgb-for-reals');

const [red, green, blue] = hslToRgb(223, 0.44, 0.56);
const css = `rgb(${red} ${green} ${blue})`;

The package returns numbers only. CSS formatting is caller code and requires valid channel values.

Build a hexadecimal color format-hex

const hslToRgb = require('hsl-to-rgb-for-reals');

function toHex(h, s, l) {
  const channels = hslToRgb(h, s, l);
  return `#${channels.map((n) => n.toString(16).padStart(2, '0')).join('')}`;
}

console.log(toHex(223, 0.44, 0.56)); // #5d79c0

Two-digit hex assumes each channel is an integer from 0 through 255. Validate inputs before formatting.

Append alpha in CSS add-alpha

const hslToRgb = require('hsl-to-rgb-for-reals');

function toCss(h, s, l, alpha) {
  if (!Number.isFinite(alpha) || alpha < 0 || alpha > 1) {
    throw new RangeError('alpha must be between 0 and 1');
  }
  const [r, g, b] = hslToRgb(h, s, l);
  return `rgb(${r} ${g} ${b} / ${alpha})`;
}

Alpha is absent from the converter API. This wrapper validates and adds it only during CSS formatting.

Convert an achromatic color convert-gray

const hslToRgb = require('hsl-to-rgb-for-reals');

const gray = hslToRgb(0, 0, 0.5);
console.log(gray); // [128, 128, 128]

Saturation 0 produces gray. A valid hue is still safer because malformed hue handling is inconsistent.

Map a palette to RGB convert-palette

const hslToRgb = require('hsl-to-rgb-for-reals');

const hsl = [
  [0, 0.8, 0.5],
  [120, 0.8, 0.5],
  [240, 0.8, 0.5],
];
const rgb = hsl.map((color) => hslToRgb(...color));

Every call returns a new mutable three-item array. Freeze results if shared palette entries must stay unchanged.

Add a local TypeScript declaration declare-types

declare module 'hsl-to-rgb-for-reals' {
  export default function hslToRgb(
    hue: number,
    saturation: number,
    lightness: number
  ): [number, number, number];
}

No TypeScript declarations were present in 1.1.1. A local declaration describes the call but cannot enforce numeric ranges.

Protect a cached conversion copy-result

const hslToRgb = require('hsl-to-rgb-for-reals');

const stored = Object.freeze(hslToRgb(223, 0.44, 0.56));
const forCaller = [...stored];

The result is a mutable Array with 3 entries. Freeze or copy it when multiple callers share a cached value.

Alternatives

PackageRegistryPick it when
color-convertnpmUse it for maintained conversions among many color models, including rounded and raw results.
tinycolor2npmUse it when input parsing, alpha, manipulation, and several output formats belong in one API.
chroma-jsnpmUse it for scales, interpolation, contrast calculations, or perceptual color spaces.
hsl-to-rgbnpmUse it only when reproducing the upstream package's old behavior and after testing its export in your runtime.

More utils guides

lru-cache · ajv · type-fest · p-limit · find-up · js-yaml · the whole shelf →

How this guide is made: grounded in the library's documentation, release notes, changelog, and issue history, on a fixed rubric — not a hands-on install of every release. The 50 most-downloaded entries are additionally install-verified in clean containers. Corrections: contact the desk.