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

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

Function: toSlef()

toSlef(data, header): Slef

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

Wrap one or more loadouts in SLEF envelopes.

Parameters

data

LoadoutEvent | readonly LoadoutEvent[]

A single Loadout event or several. Several travel in one export as separate entries, which is what the format's array top level is for.

header

SlefHeader

Which exporting app to credit. SLEF attribution belongs to the application producing the export, so callers must provide its name and version.

Returns

Slef

The export, one entry per loadout, in the order given.

Throws

If data is empty, or the header or any loadout does not match the record shape. Every entry is checked with the same guards parseSlef applies, so anything this returns is guaranteed to parse back.

Example

import type { ShipLoadout } from '@elite-dangerous-almanac/core/ships/ship-loadout';
import { stringifySlef, toSlef } from '@elite-dangerous-almanac/core/ships/slef';

declare const build: ShipLoadout;

const slef = toSlef(build.toLoadoutEvent(), { appName: 'MyApp', appVersion: '1.2.0' });
stringifySlef(slef); // -> '[{"header":{...},"data":{...}}]'
⚠️ **GitHub.com Fallback** ⚠️