commodities.Function.getCommodityBySymbol - Elite-Dangerous-Almanac/Almanac-Core GitHub Wiki
@elite-dangerous-almanac/core / commodities / getCommodityBySymbol
getCommodityBySymbol(
symbol,commodities?):Commodity|null
Defined in: src/commodities/commodities.ts:144
Look up a commodity by its Frontier symbol / journal id (case-insensitive).
Here, symbol is Frontier's internal item id for the commodity.
string
The internal symbol, e.g. "Platinum", or the lower-cased form the
market/journal reports ("platinum"). Leading/trailing whitespace is ignored.
readonly Commodity[] = ALL_COMMODITIES
Optional subset to search instead of every commodity —
COMMODITIES (standard only), RARE_COMMODITIES, or any array you have filtered
yourself. Omit it unless you specifically want to exclude the other registry: the
indexed O(1) path is taken only when the argument is omitted or is ALL_COMMODITIES
by reference, and every other array — a copy of that same catalogue included —
is scanned.
Commodity | null
The matching Commodity, or null if no commodity has that symbol.
If symbol is present and not a string. A nullish
symbol is a miss, answered the way an unrecognised one is.
import { getCommodityBySymbol } from '@elite-dangerous-almanac/core/commodities/commodities';
getCommodityBySymbol('lavianbrandy')?.name; // -> 'Lavian Brandy'