You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 73d888d
Browse filesBrowse the repository at this point in the historyBrowse files
Copy file name to clipboardExpand all lines: src/codecs/quantize.ts
+4-1Lines changed: 4 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -1,4 +1,5 @@
1
1
importtype{DitherMethod}from'../image.ts';
2
+
import{oneOf}from'../util/options.ts';
2
3
3
4
// perceptual channel weights for squared color distances
4
5
constWR=3,WG=4,WB=2;
@@ -27,11 +28,13 @@ export function paletteOptions(colors: number | undefined, dither: unknown, dith
27
28
letcount: number|undefined;
28
29
if(colors!==undefined){
29
30
count=Number(colors);
31
+
// eslint-disable-next-line no-restricted-syntax -- the palette size is only checked here
30
32
if(!Number.isInteger(count)||count<2||count>256)thrownewRangeError(`colors must be an integer from 2 to 256, not ${colors}`);
31
33
}
32
-
if(!(DITHER_METHODSasreadonlyunknown[]).includes(dither))thrownewTypeError(`dither must be one of ${DITHER_METHODS.map(name=>`'${name}'`).join(', ')}, not ${String(dither)}`);
0 commit comments