Skip to content

Commit 6b54010

Browse files
committed
chore lint
1 parent 4e12847 commit 6b54010

4 files changed

Lines changed: 39 additions & 29 deletions

File tree

src/compute-engine/compilation/javascript-target.ts

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ import {
2121
hslToRgb,
2222
apca,
2323
contrastingColor,
24-
asRgb,
2524
} from '../../color';
2625
import {
2726
gamma,
@@ -630,9 +629,12 @@ function toRI(c: Complex): { re: number; im: number } {
630629
* Normalize a color input (string or [r, g, b, a?] array with 0-1 values)
631630
* to an RgbColor {r, g, b, alpha?} with 0-255 r/g/b values.
632631
*/
633-
function toRgb255(
634-
input: string | number[]
635-
): { r: number; g: number; b: number; alpha?: number } {
632+
function toRgb255(input: string | number[]): {
633+
r: number;
634+
g: number;
635+
b: number;
636+
alpha?: number;
637+
} {
636638
if (typeof input === 'string') {
637639
const c = parseColor(input);
638640
return {
@@ -665,10 +667,7 @@ const colorHelpers = {
665667
color(input: string): number[] {
666668
return packedToArray(parseColor(input));
667669
},
668-
colorToString(
669-
input: string | number[],
670-
format?: string
671-
): string {
670+
colorToString(input: string | number[], format?: string): string {
672671
const rgb = toRgb255(input);
673672
const fmt = (format ?? 'hex').toLowerCase();
674673
switch (fmt) {
@@ -743,10 +742,7 @@ const colorHelpers = {
743742
const alpha = a1 + (a2 - a1) * ratio;
744743
return Math.abs(alpha - 1) > 1e-4 ? [r, g, b, alpha] : [r, g, b];
745744
},
746-
colorContrast(
747-
bg: string | number[],
748-
fg: string | number[]
749-
): number {
745+
colorContrast(bg: string | number[], fg: string | number[]): number {
750746
return apca(toRgb255(bg), toRgb255(fg));
751747
},
752748
contrastingColor(
@@ -762,10 +758,7 @@ const colorHelpers = {
762758
}
763759
return packedToArray(contrastingColor(bgRgb));
764760
},
765-
colorToColorspace(
766-
input: string | number[],
767-
space: string
768-
): number[] {
761+
colorToColorspace(input: string | number[], space: string): number[] {
769762
const rgb = toRgb255(input);
770763
const alpha = rgb.alpha;
771764
let result: number[];
@@ -795,10 +788,7 @@ const colorHelpers = {
795788
if (alpha !== undefined && Math.abs(alpha - 1) > 1e-4) result.push(alpha);
796789
return result;
797790
},
798-
colorFromColorspace(
799-
components: number[],
800-
space: string
801-
): number[] {
791+
colorFromColorspace(components: number[], space: string): number[] {
802792
const c0 = components[0];
803793
const c1 = components[1];
804794
const c2 = components[2];

src/compute-engine/library/arithmetic.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2077,4 +2077,3 @@ function evaluateGcdLcm(
20772077
if (result === null) return ce._fn(mode, rest);
20782078
return ce._fn(mode, [ce.number(result), ...rest]);
20792079
}
2080-

src/compute-engine/library/quantity-arithmetic.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -259,10 +259,7 @@ function simplifyQuantityUnit(
259259
// the compound unit's scale to get the magnitude in the named unit.
260260
const scale = getExpressionScale(ue);
261261
if (scale !== null)
262-
return ce._fn('Quantity', [
263-
ce.number(mag * scale),
264-
ce.symbol(match),
265-
]);
262+
return ce._fn('Quantity', [ce.number(mag * scale), ce.symbol(match)]);
266263
}
267264
}
268265
}

src/compute-engine/numerics/unit-data.ts

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -324,12 +324,36 @@ export function areCompatibleUnits(a: string, b: string): boolean {
324324
return dimensionsEqual(da, db);
325325
}
326326

327-
/** Map from dimension-vector key to named derived SI unit symbol. */
327+
/**
328+
* Map from dimension-vector key to the preferred named derived SI unit.
329+
*
330+
* Some dimensions are shared by multiple SI units:
331+
* - `[0,0,-1,…]` → Hz (frequency) and Bq (radioactive decay)
332+
* - `[2,0,-2,…]` → Gy (absorbed dose) and Sv (dose equivalent)
333+
*
334+
* We keep only the more general unit (Hz, Gy). Domain-specific aliases
335+
* (Bq, Sv) are still in UNIT_TABLE for conversion and display; they're
336+
* just not the automatic simplification targets.
337+
*/
328338
const NAMED_UNIT_BY_DIMENSION: Map<string, string> = new Map(
329339
[
330-
'N', 'J', 'W', 'Pa', 'Hz', 'C', 'V', 'F',
331-
'ohm', 'S', 'Wb', 'T', 'H', 'lm', 'lx',
332-
'Bq', 'Gy', 'Sv', 'kat',
340+
'N',
341+
'J',
342+
'W',
343+
'Pa',
344+
'Hz',
345+
'C',
346+
'V',
347+
'F',
348+
'ohm',
349+
'S',
350+
'Wb',
351+
'T',
352+
'H',
353+
'lm',
354+
'lx',
355+
'Gy',
356+
'kat',
333357
].map((unit) => [UNIT_TABLE[unit].dimension.join(','), unit])
334358
);
335359

0 commit comments

Comments
 (0)