From 7d874b0862325a96ff506340486f2db39e37f53a Mon Sep 17 00:00:00 2001 From: Angelos Chalaris Date: Fri, 15 Dec 2017 14:37:51 +0200 Subject: [PATCH] Tag and build --- README.md | 12 ++++++++++++ tag_database | 1 + 2 files changed, 13 insertions(+) diff --git a/README.md b/README.md index 4dc791572..776d746ef 100644 --- a/README.md +++ b/README.md @@ -104,6 +104,7 @@ ### Utility * [Escape regular expression](#escape-regular-expression) * [Get native type of value](#get-native-type-of-value) +* [Hexcode to RGB](#hexcode-to-rgb) * [Is array](#is-array) * [Is boolean](#is-boolean) * [Is function](#is-function) @@ -1136,6 +1137,17 @@ const getType = v => [⬆ back to top](#table-of-contents) +### Hexcode to RGB + +Use `Array.slice()`, `Array.map()` and `match()` to convert a hexadecimal colorcode (prefixed with `#`) to a string with the RGB values. + +```js +const hexToRgb = hex => `rgb(${hex.slice(1).match(/.{2}/g).map(x => parseInt(x, 16)).join()})` +// hexToRgb('#27ae60') -> 'rgb(39,174,96)' +``` + +[⬆ back to top](#table-of-contents) + ### Is array Use `Array.isArray()` to check if a value is classified as an array. diff --git a/tag_database b/tag_database index 20b8fe94a..3acb709f1 100644 --- a/tag_database +++ b/tag_database @@ -42,6 +42,7 @@ greatest-common-divisor-(GCD):math group-by:array hamming-distance:math head-of-list:array +hexcode-to-RGB:utility initial-of-list:array initialize-array-with-range:array initialize-array-with-values:array