|
|
|
|
@ -239,13 +239,13 @@ define([
|
|
|
|
|
g = numbers.shift();
|
|
|
|
|
b = numbers.shift();
|
|
|
|
|
if ([r, g, b].some(function (c) { return c < 0 || 255 < c; })) {
|
|
|
|
|
throw new RangeError();
|
|
|
|
|
throw new RangeError("Invalid range for RGB colors");
|
|
|
|
|
}
|
|
|
|
|
} else if (n === 5 && numbers.length >= 1) {
|
|
|
|
|
// 256 colors
|
|
|
|
|
var idx = numbers.shift();
|
|
|
|
|
if (idx < 0) {
|
|
|
|
|
throw new RangeError();
|
|
|
|
|
throw new RangeError("Color index must be >= 0");
|
|
|
|
|
} else if (idx < 16) {
|
|
|
|
|
// 16 default terminal colors
|
|
|
|
|
return idx;
|
|
|
|
|
@ -261,10 +261,10 @@ define([
|
|
|
|
|
// grayscale, see http://stackoverflow.com/a/27165165/500098
|
|
|
|
|
r = g = b = (idx - 232) * 10 + 8;
|
|
|
|
|
} else {
|
|
|
|
|
throw new RangeError();
|
|
|
|
|
throw new RangeError("Color index must be < 256");
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
throw new RangeError();
|
|
|
|
|
throw new RangeError("Invalid extended color specification");
|
|
|
|
|
}
|
|
|
|
|
return [r, g, b];
|
|
|
|
|
}
|
|
|
|
|
|