Skip to content

Instantly share code, notes, and snippets.

View oleggrishechkin's full-sized avatar

Oleg Grishechkin oleggrishechkin

View GitHub Profile
const colorToHEX = (colorString) => {
if (colorString.startsWith('rgba(')) {
const rgba = colorString
.slice(5, colorString.length - 1)
.split(',')
.map((item) => +item.trim());
const background = [255, 255, 255];
const hex = [
Math.round((rgba[3] * (rgba[0] / 255) + (1 - rgba[3]) * (background[0] / 255)) * 255),
Math.round((rgba[3] * (rgba[1] / 255) + (1 - rgba[3]) * (background[1] / 255)) * 255),
const stringCheck = (keyToOmit) => (value, key) => keyToOmit === key;
const arrayOfStringCheck = (keysToOmit) => (value, key) => keysToOmit.includes(key);
const omit = (targetObject, options) => {
const check = typeof options === 'function' ? options : Array.isArray(options) ? arrayOfStringCheck : stringCheck;
return Object.keys(targetObject).reduce((result, key) => {
if (!check(targetObject[key], key, targetObject)) {
result[key] = targetObject[key];
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
# dependencies
/node_modules
/.pnp
.pnp.js
# testing
/coverage