UNPKG

@primer/primitives

Version:

Typography, spacing, and color primitives for Primer design system

17 lines (16 loc) 628 B
import { invalidTokenValueError, invalidTokenValuePropertyError } from './invalidTokenError.js'; export const getTokenValue = (token, property) => { var _a; const value = (_a = token.$value) !== null && _a !== void 0 ? _a : token.value; if (value === undefined) { throw new invalidTokenValueError(token); } // for composite token if subproperty is needed if (typeof property === 'string' && value[property] === undefined) { throw new invalidTokenValuePropertyError(token, property); } if (typeof property === 'string') { return value[property]; } return value; };