Skip to content

ships.Function.toSlef

github-actions[bot] edited this page Aug 26, 2026 · 73 revisions

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

Function: toSlef()

toSlef(data, header): Slef

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

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":{...}}]'

API

Guides
astro
Classes (1)
ProceduralSystem

Properties

Accessors

Methods

Interfaces (16)
Type Aliases (3)
Variables (11)
Functions (37)
Subpath modules (3)
commodities
Interfaces (1)
Type Aliases (1)
Variables (3)
Functions (3)
equipment
Interfaces (6)
Type Aliases (8)
Variables (3)
Functions (10)
Subpath modules (2)
i18n
Interfaces (1)
Type Aliases (1)
Functions (17)
materials
Enumerations (2)
Interfaces (2)
Type Aliases (2)
Variables (9)
Functions (9)
ships
Classes (3)
BuildMetrics

Methods

LoadoutEditError

Constructors

Properties

Methods

ShipLoadout

Accessors

Methods

Interfaces (125)
Type Aliases (44)
Variables (10)
Functions (85)
Subpath modules (8)

Clone this wiki locally