closest_websafe
Version:
find the closest websafe color by hex value
22 lines (21 loc) • 662 B
Markdown
The Node.js package finds the closest websafe color based on a hexadecimal value.
```bash
npm install closest_websafe
```
The module expects a string containing a hexadecimal color and returns the nearest websafe hex string to the input as a string.
```js
const hex2websafe = require('closest_websafe');
let notWebsafeColor = "#DECADE";
let websafeColor = hex2websafe(notWebsafeColor);
// websafeColor now contains '#884444'
```
- Invalid input will throw an error message
- Library uses a linear searching algorithm.
- Self-contained, needs no dependencies.
ISC