jsx-slack
Version:
Build JSON object for Slack Block Kit surfaces from JSX
2 lines (1 loc) • 899 B
JavaScript
const u={m:1e3,cm:900,d:500,cd:400,c:100,xc:90,l:50,xl:40,x:10,ix:9,v:5,iv:4,i:1},s=t=>{if(t==="@channel"||t==="@everyone"||t==="@here")return t;const r=t.match(/^(#C|@[SUW])[A-Z0-9]{8,}$/);if(r)return r[1]==="#C"||r[1]==="@S"?r[1]:"@UW"},o=t=>{if(t===void 0)return;const r=Number.parseInt(t.toString(),10);if(!Number.isNaN(r))return r},a=t=>{if(typeof t=="string")return t;if(typeof t=="number"||typeof t=="bigint")return t.toString()},c=t=>{const r=o(t);if(r===void 0)return t.toString();if(r<=0)return r.toString();const n=Math.floor((r-1)/26);return(n>0?c(n):"")+String.fromCharCode((r-1)%26+97)},g=t=>{let r=o(t);if(r===void 0)return t.toString();if(r<=0||r>=4e3)return r.toString();let n="";for(const[f,e]of Object.entries(u)){const i=Math.floor(r/e);n+=i>0?f.repeat(i):"",r%=e}return n};export{o as coerceToInteger,a as coerceToString,s as detectSpecialLink,c as intToAlpha,g as intToRoman};