more lint (#291)

* disable function-paren-newline warning

* fix misc lint

* lint

* remove noop exponentiation
This commit is contained in:
Bruce Martin
2018-10-03 09:18:02 -07:00
committed by GitHub
parent d09c820c1b
commit 467ae94faf
14 changed files with 40 additions and 262 deletions
+10 -11
View File
@@ -1,28 +1,27 @@
// jshint esversion: 6
import { scaleRGB } from "./scaleRGB";
import scaleRGB from "./scaleRGB";
// maintain a cache of already parsed RGB names, as it is reasonably expensive
// to do this operation. This lets us have speed, but keep the pleasant ability
// to talk about colors by their text description eg, 'rgb(0,0,1)'
//
const colorCache = new Object(null); // no prototype
const colorCache = {};
function parseColorName(c) {
if (c[0] !== "#") {
const _c = c.replace(/[^\d,.]/g, "").split(",");
return [scaleRGB(+_c[0]), scaleRGB(+_c[1]), scaleRGB(+_c[2])];
} else {
var parsedHex = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(c);
return [
scaleRGB(parseInt(parsedHex[1], 16)),
scaleRGB(parseInt(parsedHex[2], 16)),
scaleRGB(parseInt(parsedHex[3], 16))
];
}
const parsedHex = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(c);
return [
scaleRGB(parseInt(parsedHex[1], 16)),
scaleRGB(parseInt(parsedHex[2], 16)),
scaleRGB(parseInt(parsedHex[3], 16))
];
}
export const parseRGB = c => {
var cv = colorCache[c];
export default c => {
let cv = colorCache[c];
if (!cv) {
cv = parseColorName(c);
colorCache[c] = cv;