Skip to content

pantoken / packages/utils/src / resolveTokens

Swyddogaeth: resolveTokens()

resolveTokens(base, options?): Map<string, string>

Bêta

Datrys gwerth pob token yn erbyn y set (gweler makeResolver), gyda'r allwedd yn ôl enw.

Paramedrau

base

dim ond darllen Token[]

options?

ResolveOptions = {}

Yn dychwelyd

Map<string, string>

Enghraifft

Datrys IR cyfan i fap enw → gwerth

ts
import { resolveTokens } from "@pantoken/utils";
import type { Token } from "@pantoken/model";

const ir: Token[] = [
  { name: "--instui-leaf", syntax: "<color>", inherits: true, value: "#0374B5" },
  { name: "--instui-brand", syntax: "*", inherits: true, value: "var(--instui-leaf)" },
  { name: "--instui-bg", syntax: "*", inherits: true, value: "light-dark(#fff, #000)" },
];

const byName = resolveTokens(ir, { mode: "dark" });
byName.get("--instui-brand"); // → "#0374B5"
byName.get("--instui-bg");    // → "#000"