UNPKG

@yookue/ts-lang-utils

Version:

Common lang utilities for typescript

44 lines (42 loc) 1.67 kB
var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __hasOwnProp = Object.prototype.hasOwnProperty; var __export = (target, all) => { for (var name in all) __defProp(target, name, { get: all[name], enumerable: true }); }; var __copyProps = (to, from, except, desc) => { if (from && typeof from === "object" || typeof from === "function") { for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); } return to; }; var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); // src/util/ColorUtils/reverseHex.ts var reverseHex_exports = {}; __export(reverseHex_exports, { reverseHex: () => reverseHex }); module.exports = __toCommonJS(reverseHex_exports); function reverseHex(hex) { if (!hex) { return void 0; } const rgx = /^#?([a-f\d])([a-f\d])([a-f\d])$/i; const rep = hex.replace(rgx, (m, r, g, b) => r + r + g + g + b + b); const arr = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(rep); if (!arr || arr.length !== 4) { return void 0; } const hexR = (255 - Number.parseInt(arr[1], 16)).toString(16).padStart(2, "0"); const hexG = (255 - Number.parseInt(arr[2], 16)).toString(16).padStart(2, "0"); const hexB = (255 - Number.parseInt(arr[3], 16)).toString(16).padStart(2, "0"); return `#${hexR}${hexG}${hexB}`; } // Annotate the CommonJS export names for ESM import in node: 0 && (module.exports = { reverseHex });