UNPKG

@winglet/style-utils

Version:

Comprehensive CSS and style management utilities including className manipulation, CSS compression, and universal style manager for TypeScript projects

27 lines (25 loc) 900 B
const cx = (...args) => { let index = 0, length = args.length, cursor, result = ''; for (; index < length; index++) if ((cursor = args[index]) && (cursor = getSegment(cursor))) result = result ? result + ' ' + cursor : cursor; return result; }; const getSegment = (input) => { let key, cursor, result = ''; if (typeof input === 'string' || typeof input === 'number') return result + input; if (input == null || typeof input !== 'object') return result; if (Array.isArray(input)) { for (key = 0; key < input.length; key++) if ((cursor = input[key]) && (cursor = getSegment(cursor))) result = result ? result + ' ' + cursor : cursor; } else for (key in input) if (input[key]) result = result ? result + ' ' + key : key; return result; }; export { cx };