Skip to the content

Hoshi Stars星

The stars you can see without a telescope, with names, colours and distances; the 88 constellations with their lines and boundaries; the Messier objects; and seven map projections to draw them on.

Hoshi is the Japanese word 星 for a star. About the name

Contents

Reference · The data door: hand the package your own stars or objects as a source with its own licence and credit, and see whose data is on the screen

TileStoretype

A tile store: tiles by source and key, under one byte budget.

Import it

import type { TileStore } from "@johnmorrisdotca/hoshi-stars/door";

Definition

interface TileStore<Tile> {
    want(source: TileLoader<Tile>, keys: readonly string[], again?: boolean): ReadonlyMap<string, Tile>;
    get(sourceId: string, key: string): Tile | undefined;
    drop(sourceId: string): void;
    stats(): TileStats;
    idle(): Promise<void>;
}

Members

NameTypeDescription
want(source: TileLoader<Tile>, keys: readonly string[], again?: boolean): ReadonlyMap<string, Tile>

Tells the store which tiles source needs now, and returns the ones it holds. When the keys are the same as the last call it does nothing, so a view that asks again at rest sends nothing; when they changed, the missing ones load (a tile that failed is tried again only now), the loads of tiles no longer needed are aborted, and the held ones are marked used. again: true is for a caller that means "try what is missing once more" with the same keys: it starts the missing tiles that are not already loading or waiting, and nothing else changes.

get(sourceId: string, key: string): Tile | undefined

One held tile, or undefined.

drop(sourceId: string): void

Forgets a source: aborts its loads, frees its tiles. The source is switched off.

stats(): TileStats
idle(): Promise<void>

Resolves when no load is running or waiting.

Examples

import type { TileStore } from "./data-door.ts";

const held = (store: TileStore<Uint8Array>): number => store.stats().held;

View sourceEdit on GitHubMade from the source of @johnmorrisdotca/hoshi-stars 0.47.0.