commodities.Function.getCommodityByName - Elite-Dangerous-Almanac/Almanac-Core GitHub Wiki

@elite-dangerous-almanac/core / commodities / getCommodityByName

Function: getCommodityByName()

getCommodityByName(name, commodities?): Commodity | null

Defined in: src/commodities/commodities.ts:169

Look up a commodity by its display name (case-insensitive).

Parameters

name

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.

commodities?

readonly Commodity[] = ALL_COMMODITIES

Optional subset to search (see getCommodityBySymbol).

Returns

Commodity | null

The matching Commodity, or null if no commodity has that name.

Throws

If name is present and not a string. A nullish name is a miss, answered the way an unrecognised one is.

Example

import { getCommodityByName } from '@elite-dangerous-almanac/core/commodities/commodities';

getCommodityByName('platinum')?.category; // -> 'Metals'
⚠️ **GitHub.com Fallback** ⚠️