UNPKG

@delirius/welcard

Version:

WelCard is a lightweight and futuristic welcome card library designed for WhatsApp Bots.

40 lines (39 loc) 1.77 kB
"use strict"; var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; Object.defineProperty(exports, "__esModule", { value: true }); exports.rgbToHex = void 0; /** * Converts RGB color values to their hexadecimal representation. * * @param r - The red component of the color (0-255). * @param g - The green component of the color (0-255). * @param b - The blue component of the color (0-255). * @returns A string representing the hexadecimal color value in the format "#RRGGBB". */ function rgbToHex(r, g, b) { return __awaiter(this, void 0, void 0, function* () { /** * Converts a number to a two-digit hexadecimal string. * * @param value - The number to convert (0-255). * @returns A two-digit hexadecimal string. */ const toHex = (value) => { const hex = value.toString(16); return hex.length === 1 ? "0" + hex : hex; }; const hexR = toHex(r); const hexG = toHex(g); const hexB = toHex(b); return `#${hexR}${hexG}${hexB}`; }); } exports.rgbToHex = rgbToHex;