export const constructTokenFunctionCall: ( token: string, fallback: string | ShadowDefinition, ) => string = (token: string, fallback: string | ShadowDefinition) => { if (Array.isArray(fallback)) { fallback = constructShadow(fallback); } return `token('${token}', '${fallback}')`; }; export type ShadowDefinition = Array<{ radius: number; offset: { x: number; y: number; }; color: string; opacity: number; }>; const constructShadow = (shadowObject: ShadowDefinition) => { return shadowObject .map((shadow) => `${shadow.offset.x}px ${shadow.offset.y}px ${shadow.radius}px ${shadow.color}`) .join(', '); }; type BooleanCallback = (args: T) => boolean; export const not: (cb: BooleanCallback) => (val: T) => boolean = (cb: BooleanCallback) => (val: T) => !cb(val); export const or: (...fns: BooleanCallback[]) => (val: T) => boolean = (...fns: BooleanCallback[]) => (val: T) => fns.some((fn) => fn(val));