UNPKG

stnl

Version:

A simple, opinionated type validator built for performance

1 lines 695 B
let __number_list=o=>{if(o.length>1){let _=`[`+o[0];for(let i=1;i<o.length;i++)_+=`,`+o[i];return _+`]`}return o.length===1?`[`+o[0]+`]`:`[]`};let __bool_list=o=>{if(o.length>1){let _=o[0]?`[true`:`[false`;for(let i=1;i<o.length;i++)_+=o[i]?`,true`:`,false`;return _+`]`}return o.length===1?o[0]?`[true]`:`[false]`:`[]`};let __number=o=>``+o;let __bool=o=>o?`true`:`false`;export default t=>{let id=t[0];if(id===0||id===2)return __number;if(id===6)return __bool;if(id===10){let obj={};for(let i=0,list=t[1];i<list.length;i++)obj[list[i]]=JSON.stringify(list[i]);return a=>obj[a]}if(id===14){id=t[1][0];return id===0||id===2?__number_list:id===6?__bool_list:JSON.stringify}return JSON.stringify};