materials.Function.materialsByGrade - Elite-Dangerous-Almanac/Almanac-Core GitHub Wiki
@elite-dangerous-almanac/core / materials / materialsByGrade
materialsByGrade(
grade):Material[]
Defined in: src/materials/materials.ts:307
Every material of a given grade, across all three categories, in catalogue order.
The grade to match, 1–5 (or a MaterialGrade member). A grade no material carries matches nothing, the way an unrecognised symbol does.
Material[]
A new array of matches (possibly empty).
If grade is present and not a number. A nullish grade is a
miss, answered the way an unrecognised one is.
import { MaterialGrade, materialsByGrade } from '@elite-dangerous-almanac/core/materials/materials';
import { RAW_MATERIALS } from '@elite-dangerous-almanac/core/materials/materials-raw';
materialsByGrade(MaterialGrade.VeryRare)[0]?.category; // -> 'manufactured'
RAW_MATERIALS.filter((m) => m.grade === MaterialGrade.Rare).length; // -> 7, one per raw line