@pillar-ui/utils
Version:
A collection of utility functions and tools to assist with common tasks and improve the efficiency of web development. These utilities are carefully crafted to enhance productivity and streamline the development process.
2 lines • 1.46 kB
JavaScript
;function a(e,[t,r]){return Math.min(r,Math.max(t,e))}var s=(...e)=>t=>e.forEach(r=>typeof r=="function"&&r(t));var i=(e,t="en-US",r="USD")=>new Intl.NumberFormat(t,{style:"currency",currency:r}).format(e);function m(e){let t=new URLSearchParams(new URL(e).search),r={};for(let[o,n]of t.entries())r[o]=n;return r}var c=({value:e,min:t,max:r})=>e>=t&&e<=r;var p=e=>Number.isNaN(e)||e<=0?false:e%4===0&&(e%100!==0||e%400===0);function l(e){let t=new Date(e);return !(t.toString()==="Invalid Date"||isNaN(t.getTime()))}function u(e){if(!/^[a-zA-Z]{2,3}(?:-[a-zA-Z]{2,3}(?:-[a-zA-Z]{4})?)?$/i.test(e))return false;let r=Intl.getCanonicalLocales(e);return r.length>0&&r[0].toLowerCase()===e.toLowerCase()}var g=({min:e=0,max:t,rounded:r=false})=>{let o=Math.random()*(t-e)+e;return r?Math.floor(o):o};function f(e){return e=e.trim(),e[0].toUpperCase()+e.slice(1)}var x=e=>e.trim().replace(/([a-z])([A-Z])/g,"$1-$2").replace(/\s+/g,"-").toLowerCase();var b=e=>e.trim().length===0?"":e.toLowerCase().trim().replace(/ & /g," and ").replace(/[ ]+/g,"-").replace(/[-]+/g,"-").replace(/[^a-z0-9-]+/g,"").replace(/^-|-$/g,"");exports.clamp=a;exports.composeEventHandlers=s;exports.formatPrice=i;exports.getURLParameters=m;exports.isInRange=c;exports.isLeapYear=p;exports.isValidDate=l;exports.isValidLocale=u;exports.randomNumber=g;exports.toCapitalize=f;exports.toKebabCase=x;exports.toSlug=b;//# sourceMappingURL=index.js.map
//# sourceMappingURL=index.js.map