Skip to content

pantoken / packages/core/src / dedupeByName

Függvény: dedupeByName()

dedupeByName(tokens): Token[]

Béta

Deduplikálja a tokeneket név szerint, az utolsó előfordulást megtartva (így az később megjelenő pluginok nyernek).

Paraméterek

tokens

Token[]

Visszatérés

Token[]

Példa

ts
import { dedupeByName } from "@pantoken/core";
import type { Token } from "@pantoken/model";

const tokens: Token[] = [
  { name: "--instui-x", syntax: "<color>", inherits: true, value: "#fff" },
  { name: "--instui-x", syntax: "<color>", inherits: true, value: "#000" },
];
dedupeByName(tokens); // → one token, value "#000" (the later wins)