Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
!function() {
function n() {
for (var n = arguments.length, e = Array(n), r = 0; r < n; r++) e[r] = arguments[r];
return "(s*(" + e.join(")s*,s*(") + ")s*)";
}
new RegExp("rgb" + n()), new RegExp("rgba" + n()), new RegExp("hsl" + n()), new RegExp("hsla" + n());
}();
var u = require('uglify-es');
var code = `
(function() {
var NUMBER = '[-+]?\\d*\\.?\\d+';
var PERCENTAGE = NUMBER + '%';
function call() {
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
return '\\(\\s*(' + args.join(')\\s*,\\s*(') + ')\\s*\\)';
}
var matchers = {
rgb: new RegExp('rgb' + call(NUMBER, NUMBER, NUMBER)),
rgba: new RegExp('rgba' + call(NUMBER, NUMBER, NUMBER, NUMBER)),
hsl: new RegExp('hsl' + call(NUMBER, PERCENTAGE, PERCENTAGE)),
hsla: new RegExp('hsla' + call(NUMBER, PERCENTAGE, PERCENTAGE, NUMBER)),
hex3: /^#([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,
hex4: /^#([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,
hex6: /^#([0-9a-fA-F]{6})$/,
hex8: /^#([0-9a-fA-F]{8})$/
};
}());
`;
var r = u.minify(code);
console.log(r.code);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.