astro.Function.toSystemAddress - Elite-Dangerous-Almanac/Almanac-Core GitHub Wiki

@elite-dangerous-almanac/core / astro / toSystemAddress

Function: toSystemAddress()

toSystemAddress(address): bigint

Defined in: src/astro/system-address-input.ts:88

Convert a supported address representation to a bigint, or throw.

Use this at the edge of your own code when you want the failure to be loud; the library's address entry points call it for you, so decodeSystemAddress(event.SystemAddress) and ProceduralSystem.fromSystemAddress(event.SystemAddress) accept a journal number directly.

Parameters

address

SystemAddressInput

A bigint, a non-negative safe-integer number (a normally parsed journal address), or a decimal digit string.

Returns

bigint

The address as a bigint.

Throws

If the value cannot be converted: a non-integer, a negative number, a number beyond 2^53 - 1 (already rounded, so the identity is lost), or a non-numeric string. The message names the offending value. A bigint outside the 64-bit range is not a conversion failure — the decoder rejects it with a RangeError.

Example

import { toSystemAddress } from '@elite-dangerous-almanac/core/astro/system-address-input';
declare const event: { SystemAddress: number }; // an `FSDJump` line, parsed

toSystemAddress(event.SystemAddress); // journal number -> bigint
toSystemAddress('3309179996515');     // -> 3309179996515n
⚠️ **GitHub.com Fallback** ⚠️