Documentation / @interstellar-tools/constants / withDisplay
Function: withDisplay()
ts
function withDisplay<
B extends {
display?: object;
id: string;
}
>(
bodies: readonly B[],
...groups: Readonly<Record<string, Partial<NonNullable<B['display']>>>>[]
): B[];Defined in: bodies/with-observations.ts:81
The bodies, with drawing groups kept apart put on them: each body's entry in each group is merged into its display, beside its colour.
Type Parameters
| Type Parameter |
|---|
B extends { display?: object; id: string; } |
Parameters
| Parameter | Type | Description |
|---|---|---|
bodies | readonly B[] | The bodies, such as PLANETS. |
...groups | Readonly<Record<string, Partial<NonNullable<B["display"]>>>>[] | Groups keyed by body id, each a part of the bodies' display, such as RING_DISPLAY. |
Returns
B[]
The bodies, with their display filled in.
Example
ts
const planets = withDisplay(PLANETS, RING_DISPLAY);
planets.find(({ id }) => id === 'saturn')?.display?.rings?.color; // '#cabcba'See
withObservations