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

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

Function: tryToSystemAddress()

tryToSystemAddress(address): bigint | null

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

Convert a supported address representation to a bigint, without accepting a value that may already have lost precision.

Parameters

address

SystemAddressInput

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

Returns

bigint | null

The address as a bigint, or null when the input cannot be converted to one: a non-integer or unsafe number (beyond 2^53 - 1, where the value has already been rounded), a negative number, or a string that is not all decimal digits. A bigint always passes through unchanged — whether it fits the 64-bit address layout is the decoder's RangeError to raise, not a conversion failure.

Example

import { tryToSystemAddress } from '@elite-dangerous-almanac/core/astro/system-address-input';

tryToSystemAddress(10477373803);   // -> 10477373803n
tryToSystemAddress('10477373803'); // -> 10477373803n
tryToSystemAddress(1.5);           // -> null
⚠️ **GitHub.com Fallback** ⚠️