materials.Function.materialsByGrade - Elite-Dangerous-Almanac/Almanac-Core GitHub Wiki

@elite-dangerous-almanac/core / materials / materialsByGrade

Function: materialsByGrade()

materialsByGrade(grade): Material[]

Defined in: src/materials/materials.ts:307

Every material of a given grade, across all three categories, in catalogue order.

Parameters

grade

MaterialGrade

The grade to match, 1–5 (or a MaterialGrade member). A grade no material carries matches nothing, the way an unrecognised symbol does.

Returns

Material[]

A new array of matches (possibly empty).

Throws

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

Example

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
⚠️ **GitHub.com Fallback** ⚠️