npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@airtrafficcontrol/tower

v0.0.1

Published

Merge coordination for the ATC system. The Tower manages landing clearance requests, maintains a first-come-first-served merge queue, and handles emergency declarations. There is exactly one tower per repository.

Readme

@airtrafficcontrol/tower

Merge coordination for the ATC system. The Tower manages landing clearance requests, maintains a first-come-first-served merge queue, and handles emergency declarations. There is exactly one tower per repository.

Installation

pnpm add @airtrafficcontrol/tower

This is an internal workspace package (workspace:*).

API Reference

Types

QueueEntry

A craft waiting in the merge queue. See RULE-TMRG-4.

| Property | Type | Description | |---|---|---| | craft | Craft | The craft awaiting merge | | requestedAt | Date | When the craft was added (used for FCFS ordering) |

ClearanceResult

Result of a landing clearance request. See RULE-TOWER-2, RULE-TMRG-1.

| Property | Type | Description | |---|---|---| | granted | boolean | Whether landing clearance was granted | | reason | string? | If denied, the reason clearance was not granted |

EmergencyReport

Data provided to the origin airport when a craft is returned on emergency. See RULE-ORIG-2, RULE-EMER-4.

| Property | Type | Description | |---|---|---| | callsign | string | The craft's unique identifier | | cargo | string | Description of the change and its scope | | flightPlan | FlightPlan | The ordered sequence of vectors | | blackBox | readonly BlackBoxEntry[] | The complete append-only event log |

Tower Class

The centralized merge coordination agent. See RULE-TOWER-1.

requestClearance(craft: Craft): ClearanceResult

Requests landing clearance. Verifies all vectors in the flight plan have Passed status. If granted, the craft is automatically enqueued for merge.

See RULE-TOWER-2, RULE-TMRG-1, RULE-TMRG-4.

enqueue(craft: Craft): void

Adds a craft to the merge queue. Throws TowerError if the craft is already queued.

See RULE-TMRG-4.

dequeue(callsign: string): Craft | undefined

Removes a craft from the queue by callsign. Returns the removed craft, or undefined if not found.

peek(): QueueEntry | undefined

Returns the next craft in the queue without removing it (FCFS ordering).

See RULE-TMRG-4.

queueSize: number (getter)

The number of crafts currently in the merge queue.

declareEmergency(craft: Craft, captainId: string, reason: string): EmergencyReport

Declares an emergency for a craft. Only the captain may declare. Appends an EmergencyDeclaration entry to the black box, removes the craft from the queue if present, and returns an EmergencyReport for the origin airport.

Throws EmergencyError if captainId does not match the craft's captain.

See RULE-EMER-1 through RULE-EMER-4, RULE-ORIG-2.

Factory Function

createTower(): Tower

Creates a new Tower instance with an empty merge queue. See RULE-TOWER-1.

Utility

createEmergencyReport(craft: Craft): EmergencyReport

Extracts callsign, cargo, flight plan, and black box into an immutable report for the origin airport.

See RULE-ORIG-2, RULE-EMER-4, RULE-BBOX-4.

Usage

import { createTower } from "@airtrafficcontrol/tower";

const tower = createTower();

// Request landing clearance
const result = tower.requestClearance(craft);
if (result.granted) {
  console.log(`Craft ${craft.callsign} cleared to land (queue position: ${tower.queueSize})`);
} else {
  console.log(`Clearance denied: ${result.reason}`);
}

// Process the merge queue
const next = tower.peek();
if (next) {
  // Merge the craft's branch, then dequeue
  tower.dequeue(next.craft.callsign);
}

// Declare an emergency
const report = tower.declareEmergency(craft, "captain-1", "Repeated test failures after 3 go-arounds");

Dependencies

| Package | Purpose | |---|---| | @airtrafficcontrol/types | Craft, FlightPlan, BlackBoxEntry, VectorStatus, BlackBoxEntryType | | @airtrafficcontrol/errors | TowerError, EmergencyError | | @airtrafficcontrol/core | Core runtime functions | | @airtrafficcontrol/checklist | Checklist types |

Related Packages