commodities.Function.getCommodityByName - Elite-Dangerous-Almanac/Almanac-Core GitHub Wiki
@elite-dangerous-almanac/core / commodities / getCommodityByName
getCommodityByName(
name,commodities?):Commodity|null
Defined in: src/commodities/commodities.ts:169
Look up a commodity by its display name (case-insensitive).
string
The display name as the market spells it, e.g. "Lavian Brandy".
Leading/trailing whitespace and case are ignored, but matching is otherwise exact.
readonly Commodity[] = ALL_COMMODITIES
Optional subset to search (see getCommodityBySymbol).
Commodity | null
The matching Commodity, or null if no commodity has that name.
If name is present and not a string. A nullish
name is a miss, answered the way an unrecognised one is.
import { getCommodityByName } from '@elite-dangerous-almanac/core/commodities/commodities';
getCommodityByName('platinum')?.category; // -> 'Metals'