Skip to content

pantoken-root / 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)