ships.Function.parseSlef - Elite-Dangerous-Almanac/Almanac-Core GitHub Wiki

@elite-dangerous-almanac/core / ships / parseSlef

Function: parseSlef()

parseSlef(input): SlefEntry[]

Defined in: src/ships/slef.ts:572

Parse a SLEF export into its entries.

Parameters

input

unknown

Either the SLEF JSON string or an already-parsed object. Accepted shapes, in order of leniency:

  • the standard array [{ header, data }, ...];
  • a single { header, data } object;
  • a bare journal Loadout event ({ Ship, Modules, ... }) — wrapped in an entry with an empty synthetic header. Every returned header, loadout, module and engineering modifier is runtime-checked against the public record shape. Parsing is strict: one malformed entry rejects the whole payload. Use inspectSlef to recover valid entries from a mixed payload.

Returns

SlefEntry[]

The entries, in export order — never empty (a parse that finds no valid entry throws instead).

Throws

If input is a string that is not valid JSON.

Throws

If the payload is empty or any entry, header, loadout, module or engineering field is malformed.

Example

import { parseSlef } from '@elite-dangerous-almanac/core/ships/slef';

declare const slefJsonString: string;

const [entry] = parseSlef(slefJsonString);
entry?.data.Ship; // -> 'explorer_nx'
⚠️ **GitHub.com Fallback** ⚠️