mix-cn
Version:
一个用于字符串拼接的小工具,常用于 class name 的拼接
2 lines (1 loc) • 625 B
JavaScript
import{isTrue as e,isArray as o,isString as r,isNumber as t,isFunction as i,isUndefined as n}from"a-type-of-js";function f(...s){const c=[],l=e=>e.trim().replace(/undefined/g," ").replace(/\s+/g," ").split(" ").sort().join(" "),p=e=>{if(n(e)||!r(e))return;const o=l(e).split(" ");o.length&&c.push(...o)};s.forEach(n=>{if(n&&!e(n))if(o(n))n.forEach(e=>p(f(e)));else if(r(n)||t(n))p(n.toString());else if(i(n)){const e=n();r(e)?p(e):e.forEach(e=>p(f(e)))}else for(const e in n)if(Object.prototype.hasOwnProperty.call(n,e)){!0===n[e]&&p(e)}});return l(Array.from(new Set(c)).filter(Boolean).join(" "))??void 0}export{f as xcn};