UNPKG

color-fns

Version:

Modern JavaScript color utility library.

21 lines 607 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var expandHexShorthand_1 = require("./expandHexShorthand"); function parseHex(hex) { if (!hex) { return null; } var expanded = expandHexShorthand_1.expandHexShorthand(hex); var match = expanded.match(/^#([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})*/i); if (!match || match.length < 4) { return null; } return { alpha: match[4], blue: match[3], green: match[2], red: match[1], }; } exports.parseHex = parseHex; //# sourceMappingURL=parseHex.js.map