Skip to content

Instantly share code, notes, and snippets.

@davidaurelio
Created June 14, 2017 16:11
Show Gist options
  • Save davidaurelio/fd01b9bf842f1ee68f453d79c91dc259 to your computer and use it in GitHub Desktop.
Save davidaurelio/fd01b9bf842f1ee68f453d79c91dc259 to your computer and use it in GitHub Desktop.
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