Skip to content

pantoken / packages/core/src / dedupeByName

دالة: dedupeByName()

dedupeByName(tokens): Token[]

بيتا

إزالة التكرارات من الرموز حسب الاسم مع الاحتفاظ بآخر تكرار (حتى تفوز الإضافات الأحدث).

المعلمات

tokens

Token[]

القيم المرجعة

Token[]

مثال

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)