UNPKG

@terrazzo/token-tools

Version:

Various utilities for token types

17 lines 721 B
/** Give a user pertinent feedback if they override a transform incorrectly */ export function validateCustomTransform(value, { $type }) { if (value) { if ((typeof value !== 'string' && typeof value !== 'object') || Array.isArray(value)) { throw new Error(`transform(): expected string or Object of strings, received ${Array.isArray(value) ? 'Array' : typeof value}`); } switch ($type) { case 'typography': { if (typeof value !== 'object') { throw new TypeError('transform(): typography tokens must be an object of keys'); } break; } } } } //# sourceMappingURL=transform.js.map