UNPKG

color-shorthand-hex-to-six-digit

Version:

Convert shorthand hex color codes into full

11 lines (9 loc) 829 B
/** * @name color-shorthand-hex-to-six-digit * @fileoverview Convert shorthand hex color codes into full * @version 5.0.20 * @author Roy Revelt, Codsen Ltd * @license MIT * {@link https://codsen.com/os/color-shorthand-hex-to-six-digit/} */ import p from"hex-color-regex";import{isPlainObject as o}from"codsen-utils";import a from"rfdc";var s="5.0.20";var m=a(),y=s;function n(t){if(typeof t!="string"&&!Array.isArray(t)&&!o(t))return t;function i(e,r,c,l){return l[c-1]!=="&"&&e.length===4&&e.charAt(0)==="#"?`#${e.charAt(1)}${e.charAt(1)}${e.charAt(2)}${e.charAt(2)}${e.charAt(3)}${e.charAt(3)}`.toLowerCase():e.toLowerCase()}if(typeof t=="string")return t.replace(p(),i);if(Array.isArray(t))return t.map(n);if(o(t)){let e=m(t);return Object.keys(e).forEach(r=>{e[r]=n(e[r])}),e}return t}export{n as conv,y as version};