Registry / data / chartjs-color-string

chartjs-color-string

JSON →
library0.6.0jsnpmunverified

This library, `chartjs-color-string`, provides utilities for parsing and generating CSS color strings in various formats, including named colors, hex, rgb(a), and hsl(a). It outputs color components as numerical arrays. While it is part of the Chart.js ecosystem, its latest version, 0.6.0, was published over seven years ago, indicating a mature and stable, but infrequently updated, project. It supports modern CSS color string formats like `#rgba` and `#rrggbbaa` since version 0.6.0 and case-insensitive parsing of RGB(A) strings since 0.5.0. Its primary differentiator is its lightweight focus on string conversion, making it suitable for environments where a full-featured color manipulation library is not needed. The package should be considered in maintenance mode.

npm install chartjs-color-string
INSTALL
IMPORT
SIG · CHARTJS-COLOR-STRI
C
chartjs-color-string
datajavascriptv0.6.0
Install
—
Import
—
Disk
—
Pass rate
0/ 6
Env Coverage0 / 6
glibc
18–22
musl
18–22
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18–226 runs
build_error
glibc
node 18–226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

colorString
✓ import * as colorString from 'chartjs-color-string';
✗ import colorString from 'chartjs-color-string';
The library exports its functions as properties of a single object, typically imported as a namespace.
colorString
✓ const colorString = require('chartjs-color-string');
CommonJS require is the historically common way to import this library.
getRgb
✓ import { getRgb } from 'chartjs-color-string'; /* NOT a direct export */
✗ import { getRgb } from 'chartjs-color-string';
Individual functions like `getRgb` are not direct named exports; they are accessed via the main `colorString` import, e.g., `colorString.getRgb`.

Demonstrates how to parse various CSS color strings into numerical arrays and how to generate CSS color strings from numerical arrays using the imported `colorString` object.

import * as colorString from 'chartjs-color-string'; // Parsing examples const blueRgb = colorString.getRgb('blue'); console.log('Blue (RGB):', blueRgb); // Expected: [0, 0, 255] const hexWithAlpha = colorString.getRgba('#FFFA'); console.log('Hex with Alpha (RGBA):', hexWithAlpha); // Expected: [255, 255, 255, 0.67] const rgbaString = colorString.getRgba('rgba(200, 60, 60, 0.3)'); console.log('RGBA String (RGBA):', rgbaString); // Expected: [200, 60, 60, 0.3] // Generation examples const whiteHex = colorString.hexString([255, 255, 255]); console.log('White Hex:', whiteHex); // Expected: "#FFFFFF" const blueRgbaString = colorString.rgbString([0, 0, 255, 0.4]); console.log('Blue RGBA String:', blueRgbaString); // Expected: "rgba(0, 0, 255, 0.4)" const yellowKeyword = colorString.keyword([255, 255, 0]); console.log('Yellow Keyword:', yellowKeyword); // Expected: "yellow"
Debug
Known issues
gotchaThe README and GitHub page for `chartjs-color-string` incorrectly instruct users to install `color-string` via `npm install color-string`. `color-string` is a different, unrelated package with a distinct API. Installing the wrong package will lead to module not found errors or unexpected API behavior.
fix
Always install the correct package using `npm install chartjs-color-string`.
affects: >=0.1.0
gotchaThis package, `chartjs-color-string`, has not been updated in over seven years (latest version 0.6.0 published March 7, 2019). While functional, it indicates a lack of active development and might not receive updates for newer CSS color specifications or critical bug fixes.
fix
Be aware of the package's maintenance status. For projects requiring active development, newer CSS color features, or more comprehensive color manipulation, consider alternative actively maintained libraries.
affects: >=0.6.0
Errors
Common errors & fixes
TypeError: colorString.getRgb is not a function
This error typically occurs if you installed the `color-string` package (the incorrect one as per the README's misleading instructions) instead of `chartjs-color-string`, as `color-string` has a different API (e.g., `colorString.get('#FFF')` returns an object, not an array directly).
fix
Uninstall the incorrect package (`npm uninstall color-string`) and install the correct one (`npm install chartjs-color-string`). Ensure your import statements are `import * as colorString from 'chartjs-color-string';` or `const colorString = require('chartjs-color-string');`.
Cannot find module 'chartjs-color-string'
This error means the package `chartjs-color-string` could not be found. This often happens if you followed the misleading `npm install color-string` instruction in the README, installing the wrong package.
fix
Verify that you have installed `chartjs-color-string` correctly. If not, run `npm install chartjs-color-string`. If `color-string` was installed by mistake, remove it (`npm uninstall color-string`) and install the correct package.
Upgrade
Version history
0.6.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
9 hits · last 30 days
node
8
OpenAI (training)
1
Resources
chartjs-color-string — npm install chartjs-color-string · libregistry