UNPKG

qsu

Version:

qsu is a utility library that contains useful and frequently used functions. Start with your preferred language and the modern development environment.

1 lines 525 B
export function split(e,...l){if(!e)return[];const t=l.length>0&&"object"==typeof l[0]?l[0]:l,g=t.length;let n="",r="";for(let e=0;e<g;e+=1){const l=t[e];l.length>1?r+=`${r.length<1?"":"|"}${l.replace(/\\/g,"\\\\").replace(/\[/g,"\\[").replace(/]/g,"\\]").replace(/\?/g,"\\?").replace(/\./g,"\\.").replace(/\{/g,"\\{").replace(/}/g,"\\}").replace(/\+/g,"\\+")}`:n+="-"===l||"["===l||"]"===l?`\\${l}`:l}return n.length<1&&r.length<1?[e]:(n.length>0&&(n=`[${n}]`,r.length>0&&(r=`|${r}`)),e.split(new RegExp(`${n}${r}+`,"gi")))}