Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

bellajs

Package Overview
Dependencies
Maintainers
1
Versions
147
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bellajs - npm Package Compare versions

Comparing version 11.0.0-rc1 to 11.0.0-rc2

6

dist/bella.esm.js
/**
* bellajs@11.0.0rc1
* built with esbuild at: 2022-01-02T10:31:26.719Z
* bellajs@11.0.0rc2
* built with esbuild at: 2022-01-03T13:45:10.948Z
* repository: https://github.com/ndaidong/bellajs

@@ -8,2 +8,2 @@ * maintainer: @ndaidong

**/
var w=t=>({}).toString.call(t),W=t=>Number.isInteger(t),a=t=>Array.isArray(t),f=t=>String(t)===t,b=t=>Number(t)===t,X=t=>Boolean(t)===t,k=t=>w(t)==="[object Null]",C=t=>w(t)==="[object Undefined]",U=t=>C(t)||k(t),K=t=>w(t)==="[object Function]",g=t=>w(t)==="[object Object]"&&!a(t),p=t=>t instanceof Date&&!isNaN(t.valueOf()),Q=t=>w(t).match(/^\[object HTML\w*Element]$/)!==null,V=t=>{let e=/^[a-z]+$/i;return f(t)&&e.test(t)},Z=t=>{let e=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;return f(t)&&e.test(t)},j=t=>!t||U(t)||f(t)&&t===""||a(t)&&t.length===0||g(t)&&Object.keys(t).length===0,d=(t,e)=>!t||!e?!1:Object.prototype.hasOwnProperty.call(t,e);var O=(t,e)=>{if(j(t)&&j(e))return!0;if(p(t)&&p(e))return t.getTime()===e.getTime();if(a(t)&&a(e)){if(t.length!==e.length)return!1;let r=!0;for(let n=0;n<t.length;n++)if(!O(t[n],e[n])){r=!1;break}return r}if(g(t)&&g(e)){if(Object.keys(t).length!==Object.keys(e).length)return!1;let r=!0;for(let n in t)if(!d(e,n)||!O(t[n],e[n])){r=!1;break}return r}return t===e};var q=Number.MAX_SAFE_INTEGER,T=(t,e)=>{if((!t||t<0)&&(t=0),e||(e=q),t===e)return e;t>e&&(t=Math.min(t,e),e=Math.max(t,e));let r=t,n=e-t+1;return Math.floor(Math.random()*n)+r};var m=t=>{let e=b(t)?String(t):t;if(!f(e))throw new Error("InvalidInput: String required.");return e},st=(t,e)=>{let r=m(t),n=e||140;if(r.length<=n)return r;let o=r.substring(0,n),s=o.split(" "),c=s.length,i="";return c>1?(s.pop(),i+=s.join(" "),i.length<r.length&&(i+="...")):(o=o.substring(0,n-3),i=o+"..."),i},ct=t=>m(t).replace(/<.*?>/gi," ").replace(/\s\s+/g," ").trim(),it=t=>m(t).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;"),ut=t=>m(t).replace(/&quot;/g,'"').replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&amp;/g,"&"),z=t=>{let e=m(t).toLowerCase();return e.length>1?e.charAt(0).toUpperCase()+e.slice(1):e.toUpperCase()},lt=t=>m(t).split(" ").map(e=>z(e)).join(" "),D=(t,e,r)=>{let n=m(t);if(b(e)&&(e=String(e)),b(r)&&(r=String(r)),f(e)&&f(r))n=n.split(e).join(r);else if(a(e)&&f(r))e.forEach(o=>{n=D(n,o,r)});else if(a(e)&&a(r)&&e.length===r.length){let o=e.length;if(o>0)for(let s=0;s<o;s++){let c=e[s],i=r[s];n=D(n,c,i)}}return n},P=t=>{let e=m(t),r={a:"á|à|ả|ã|ạ|ă|ắ|ặ|ằ|ẳ|ẵ|â|ấ|ầ|ẩ|ẫ|ậ|ä",A:"Á|À|Ả|Ã|Ạ|Ă|Ắ|Ặ|Ằ|Ẳ|Ẵ|Â|Ấ|Ầ|Ẩ|Ẫ|Ậ|Ä",c:"ç",C:"Ç",d:"đ",D:"Đ",e:"é|è|ẻ|ẽ|ẹ|ê|ế|ề|ể|ễ|ệ|ë",E:"É|È|Ẻ|Ẽ|Ẹ|Ê|Ế|Ề|Ể|Ễ|Ệ|Ë",i:"í|ì|ỉ|ĩ|ị|ï|î",I:"Í|Ì|Ỉ|Ĩ|Ị|Ï|Î",o:"ó|ò|ỏ|õ|ọ|ô|ố|ồ|ổ|ỗ|ộ|ơ|ớ|ờ|ở|ỡ|ợ|ö",O:"Ó|Ò|Ỏ|Õ|Ọ|Ô|Ố|Ồ|Ổ|Ô|Ộ|Ơ|Ớ|Ờ|Ở|Ỡ|Ợ|Ö",u:"ú|ù|ủ|ũ|ụ|ư|ứ|ừ|ử|ữ|ự|û",U:"Ú|Ù|Ủ|Ũ|Ụ|Ư|Ứ|Ừ|Ử|Ữ|Ự|Û",y:"ý|ỳ|ỷ|ỹ|ỵ",Y:"Ý|Ỳ|Ỷ|Ỹ|Ỵ"},n=(o,s)=>{e=D(e,o,s)};for(let o in r)d(r,o)&&r[o].split("|").forEach(c=>n(c,o));return e},at=(t,e="")=>{let r="abcdefghijklmnopqrstuvwxyz",n=r.toUpperCase(),s=[r,n,"0123456789"].join("").split("").sort(()=>Math.random()>.5).join(""),c=s.length,i=Math.max(t||32,e.length),l=e;for(;l.length<i;){let u=T(0,c);l+=s.charAt(u)||""}return l},pt=(t,e="-")=>P(t).trim().toLowerCase().replace(/\W+/g," ").replace(/\s+/g," ").replace(/\s/g,e);var Y="D, M d, Y h:i:s A",F=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],G=["January","February","March","April","May","June","July","August","September","October","November","December"],I=()=>new Date,S=()=>Date.now(),A=I().getTimezoneOffset(),L=(()=>{let t=Math.abs(A/60),e=A<0?"+":"-";return["GMT",e,String(t).padStart(4,"0")].join("")})(),M=t=>String(t<10?"0"+t:t),R=t=>{let e=t+" ",r=e.charAt(e.length-2);return r==="1"?e="st":r==="2"?e="nd":r==="3"?e="rd":e="th",e},_=(t,e=Y)=>{let r=p(t)?t:new Date(t);if(!p(r))throw new Error("InvalidInput: Number or Date required.");let n=/\.*\\?([a-z])/gi,o=e.includes("a")||e.includes("A"),s=F,c=G,i={Y(){return r.getFullYear()},y(){return(i.Y()+"").slice(-2)},F(){return c[i.n()-1]},M(){return(i.F()+"").slice(0,3)},m(){return M(i.n())},n(){return r.getMonth()+1},S(){return R(i.j())},j(){return r.getDate()},d(){return M(i.j())},t(){return new Date(i.Y(),i.n(),0).getDate()},w(){return r.getDay()},l(){return s[i.w()]},D(){return(i.l()+"").slice(0,3)},G(){return r.getHours()},g(){return i.G()%12||12},h(){return M(o?i.g():i.G())},i(){return M(r.getMinutes())},s(){return M(r.getSeconds())},a(){return i.G()>11?"pm":"am"},A(){return i.a().toUpperCase()},O(){return L}},l=(u,y)=>i[u]?i[u]():y;return e.replace(n,l)},ht=(t=S())=>{let e=p(t)?t:new Date(t);if(!p(e))throw new Error("InvalidInput: Number or Date required.");let r=I()-e,n=parseInt(e,10);if(isNaN(n)&&(n=0),r<=n)return"Just now";let o=null,s={millisecond:1,second:1e3,minute:60,hour:60,day:24,month:30,year:12};for(let c in s){if(r<s[c])break;o=c,r/=s[c]}return r=Math.floor(r),r!==1&&(o+="s"),[r,o].join(" ")+" ago"},dt=(t=S())=>{let e=p(t)?t:new Date(t);if(!p(e))throw new Error("InvalidInput: Number or Date required.");let r=e.getMinutes(),n=new Date(e);return n.setMinutes(r+A),`${_(n,"D, j M Y h:i:s")} GMT+0000`},mt=(t=S())=>{let e=p(t)?t:new Date(t);if(!p(e))throw new Error("InvalidInput: Number or Date required.");return _(e,"D, j M Y h:i:s O")};var yt=t=>{for(var e=[],r=0;r<64;)e[r]=0|Math.abs(Math.sin(++r))*4294967296;for(var n,o,s,c,i=[],l=decodeURIComponent(encodeURI(t)),u=l.length,y=[n=1732584193,o=-271733879,~n,~o],h=0;h<=u;)i[h>>2]|=(l.charCodeAt(h)||128)<<8*(h++%4);for(i[t=(u+8>>6)*16+14]=u*8,h=0;h<t;h+=16){for(u=y,c=0;c<64;)u=[s=u[3],(n=u[1]|0)+((s=u[0]+[n&(o=u[2])|~n&s,s&n|~s&o,n^o^s,o^(n|~s)][u=c>>4]+(e[c]+(i[[c,5*c+1,3*c+5,7*c][u]%16+h]|0)))<<(u=[7,12,17,22,5,9,14,20,4,11,16,23,6,10,15,21][4*u+c++%4])|s>>>32-u),n,o];for(c=4;c;)y[--c]=y[c]+u[c]}for(t="";c<32;)t+=(y[c>>3]>>(1^c++&7)*4&15).toString(16);return t};var Mt=t=>{let e=t.length,r=(n,o)=>n>0?(...s)=>r(n-s.length,[...o,...s]):t(...o);return r(e,[])};var jt=(...t)=>t.reduce((e,r)=>n=>e(r(n)));var St=(...t)=>t.reduce((e,r)=>n=>r(e(n)));var x=(t,e,r,n={})=>{let{writable:o=!1,configurable:s=!1,enumerable:c=!1}=n;Object.defineProperty(t,e,{value:r,writable:o,configurable:s,enumerable:c})};var N=t=>{let e=t,r=()=>e==null,n=()=>e,o=l=>N(e||l()),s=l=>N(l(e)===!0?e:null),c=l=>N(r()?null:l(e)),i=Object.create({});return x(i,"__value__",e,{enumerable:!0}),x(i,"__type__","Maybe",{enumerable:!0}),x(i,"isNil",r),x(i,"value",n),x(i,"map",c),x(i,"if",s),x(i,"else",o),i};var E=(t,e=null)=>{let r=e||new Set;if(r.has(t))return t;if(r.add(t),p(t))return new Date(t.valueOf());let n=s=>{let c=Object.create({});for(let i in s)d(s,i)&&(c[i]=E(s[i],r));return c},o=s=>[...s].map(c=>a(c)?o(c):g(c)?n(c):E(c,r));return a(t)?o(t):g(t)?n(t):t},H=(t,e,r=!1,n=[])=>{for(let o in t)if(!(n.length>0&&n.includes(o))&&(!r||r&&d(e,o))){let s=t[o],c=e[o];g(c)&&g(s)||a(c)&&a(s)?e[o]=H(s,e[o],r,n):e[o]=E(s)}return e},It=(t=[])=>[...new Set(t)],B=(t,e)=>t>e?1:t<e?-1:0,J=(t=[],e=null)=>{let r=[...t],n=e||B;return r.sort(n),r},_t=(t=[],e=1,r="")=>!f(r)||!d(t[0],r)?t:J(t,(n,o)=>n[r]>o[r]?e:n[r]<o[r]?-1*e:0),$=(t=[])=>{let e=[...t],r=[],n=e.length;for(;n>0;){let o=Math.floor(Math.random()*n);r.push(e.splice(o,1)[0]),n--}return r},kt=(t=[],e=1)=>{let r=$(t),n=Math.max(1,e),o=Math.min(n,r.length-1);return r.splice(0,o)};export{E as clone,jt as compose,H as copies,Mt as curry,O as equals,it as escapeHTML,at as genid,d as hasProperty,a as isArray,X as isBoolean,p as isDate,Q as isElement,Z as isEmail,j as isEmpty,K as isFunction,W as isInteger,V as isLetter,U as isNil,k as isNull,b as isNumber,g as isObject,f as isString,C as isUndefined,N as maybe,yt as md5,I as now,kt as pick,St as pipe,T as randint,D as replaceAll,$ as shuffle,pt as slugify,J as sort,_t as sortBy,P as stripAccent,ct as stripTags,S as time,_ as toDateString,mt as toLocalDateString,ht as toRelativeTime,dt as toUTCDateString,st as truncate,z as ucfirst,lt as ucwords,ut as unescapeHTML,It as unique};
var h=t=>({}).toString.call(t),F=t=>Number.isInteger(t),u=t=>Array.isArray(t),p=t=>String(t)===t,y=t=>Number(t)===t,R=t=>Boolean(t)===t,N=t=>h(t)==="[object Null]",_=t=>h(t)==="[object Undefined]",T=t=>_(t)||N(t),z=t=>h(t)==="[object Function]",l=t=>h(t)==="[object Object]"&&!u(t),m=t=>t instanceof Date&&!isNaN(t.valueOf()),B=t=>h(t).match(/^\[object HTML\w*Element]$/)!==null,H=t=>{let e=/^[a-z]+$/i;return p(t)&&e.test(t)},$=t=>{let e=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;return p(t)&&e.test(t)},w=t=>!t||T(t)||p(t)&&t===""||u(t)&&t.length===0||l(t)&&Object.keys(t).length===0,a=(t,e)=>!t||!e?!1:Object.prototype.hasOwnProperty.call(t,e);var S=(t,e)=>{if(w(t)&&w(e))return!0;if(m(t)&&m(e))return t.getTime()===e.getTime();if(u(t)&&u(e)){if(t.length!==e.length)return!1;let r=!0;for(let n=0;n<t.length;n++)if(!S(t[n],e[n])){r=!1;break}return r}if(l(t)&&l(e)){if(Object.keys(t).length!==Object.keys(e).length)return!1;let r=!0;for(let n in t)if(!a(e,n)||!S(t[n],e[n])){r=!1;break}return r}return t===e};var D=Number.MAX_SAFE_INTEGER,A=(t,e)=>{if((!t||t<0)&&(t=0),e||(e=D),t===e)return e;t>e&&(t=Math.min(t,e),e=Math.max(t,e));let r=t,n=e-t+1;return Math.floor(Math.random()*n)+r};var g=t=>{let e=y(t)?String(t):t;if(!p(e))throw new Error("InvalidInput: String required.");return e},K=(t,e)=>{let r=g(t),n=e||140;if(r.length<=n)return r;let o=r.substring(0,n),s=o.split(" "),i=s.length,c="";return i>1?(s.pop(),c+=s.join(" "),c.length<r.length&&(c+="...")):(o=o.substring(0,n-3),c=o+"..."),c},Q=t=>g(t).replace(/<.*?>/gi," ").replace(/\s\s+/g," ").trim(),Z=t=>g(t).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;"),v=t=>g(t).replace(/&quot;/g,'"').replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&amp;/g,"&"),k=t=>{let e=g(t).toLowerCase();return e.length>1?e.charAt(0).toUpperCase()+e.slice(1):e.toUpperCase()},tt=t=>g(t).split(" ").map(e=>k(e)).join(" "),j=(t,e,r)=>{let n=g(t);if(y(e)&&(e=String(e)),y(r)&&(r=String(r)),p(e)&&p(r))n=n.split(e).join(r);else if(u(e)&&p(r))e.forEach(o=>{n=j(n,o,r)});else if(u(e)&&u(r)&&e.length===r.length){let o=e.length;if(o>0)for(let s=0;s<o;s++){let i=e[s],c=r[s];n=j(n,i,c)}}return n},I=t=>{let e=g(t),r={a:"á|à|ả|ã|ạ|ă|ắ|ặ|ằ|ẳ|ẵ|â|ấ|ầ|ẩ|ẫ|ậ|ä",A:"Á|À|Ả|Ã|Ạ|Ă|Ắ|Ặ|Ằ|Ẳ|Ẵ|Â|Ấ|Ầ|Ẩ|Ẫ|Ậ|Ä",c:"ç",C:"Ç",d:"đ",D:"Đ",e:"é|è|ẻ|ẽ|ẹ|ê|ế|ề|ể|ễ|ệ|ë",E:"É|È|Ẻ|Ẽ|Ẹ|Ê|Ế|Ề|Ể|Ễ|Ệ|Ë",i:"í|ì|ỉ|ĩ|ị|ï|î",I:"Í|Ì|Ỉ|Ĩ|Ị|Ï|Î",o:"ó|ò|ỏ|õ|ọ|ô|ố|ồ|ổ|ỗ|ộ|ơ|ớ|ờ|ở|ỡ|ợ|ö",O:"Ó|Ò|Ỏ|Õ|Ọ|Ô|Ố|Ồ|Ổ|Ô|Ộ|Ơ|Ớ|Ờ|Ở|Ỡ|Ợ|Ö",u:"ú|ù|ủ|ũ|ụ|ư|ứ|ừ|ử|ữ|ự|û",U:"Ú|Ù|Ủ|Ũ|Ụ|Ư|Ứ|Ừ|Ử|Ữ|Ự|Û",y:"ý|ỳ|ỷ|ỹ|ỵ",Y:"Ý|Ỳ|Ỷ|Ỹ|Ỵ"},n=(o,s)=>{e=j(e,o,s)};for(let o in r)a(r,o)&&r[o].split("|").forEach(i=>n(i,o));return e},et=(t,e="")=>{let r="abcdefghijklmnopqrstuvwxyz",n=r.toUpperCase(),s=[r,n,"0123456789"].join("").split("").sort(()=>Math.random()>.5).join(""),i=s.length,c=Math.max(t||32,e.length),f=e;for(;f.length<c;){let E=A(0,i);f+=s.charAt(E)||""}return f},rt=(t,e="-")=>I(t).trim().toLowerCase().replace(/\W+/g," ").replace(/\s+/g," ").replace(/\s/g,e);var O={dateStyle:"medium",timeStyle:"long"},d={second:1e3,minute:60,hour:60,day:24,week:7,month:4,year:12},L=t=>{try{return new Intl.Locale(t).language!==""}catch{return!1}},st=(...t)=>{let e=t[0],r=L(t[1])?t[1]:"en",n=t.length>=3?t[2]:t.length===1?O:l(t[1])?t[1]:O;return new Intl.DateTimeFormat(r,n).format(new Date(e))},ct=(t,e="en",r="just now")=>{let n=new Date(t),o=Date.now()-n;if(o<=d.second)return r;let s="second";for(let c in d){if(o<d[c])break;s=c,o/=d[c]}return o=Math.floor(o),new Intl.RelativeTimeFormat(e).format(-o,s)};var ut=t=>{let e=t.length,r=(n,o)=>n>0?(...s)=>r(n-s.length,[...o,...s]):t(...o);return r(e,[])};var pt=(...t)=>t.reduce((e,r)=>n=>e(r(n)));var at=(...t)=>t.reduce((e,r)=>n=>r(e(n)));var x=(t,e,r,n={})=>{let{writable:o=!1,configurable:s=!1,enumerable:i=!1}=n;Object.defineProperty(t,e,{value:r,writable:o,configurable:s,enumerable:i})};var b=t=>{let e=t,r=()=>e==null,n=()=>e,o=f=>b(e||f()),s=f=>b(f(e)===!0?e:null),i=f=>b(r()?null:f(e)),c=Object.create({});return x(c,"__value__",e,{enumerable:!0}),x(c,"__type__","Maybe",{enumerable:!0}),x(c,"isNil",r),x(c,"value",n),x(c,"map",i),x(c,"if",s),x(c,"else",o),c};var M=(t,e=null)=>{let r=e||new Set;if(r.has(t))return t;if(r.add(t),m(t))return new Date(t.valueOf());let n=s=>{let i=Object.create({});for(let c in s)a(s,c)&&(i[c]=M(s[c],r));return i},o=s=>[...s].map(i=>u(i)?o(i):l(i)?n(i):M(i,r));return u(t)?o(t):l(t)?n(t):t},P=(t,e,r=!1,n=[])=>{for(let o in t)if(!(n.length>0&&n.includes(o))&&(!r||r&&a(e,o))){let s=t[o],i=e[o];l(i)&&l(s)||u(i)&&u(s)?e[o]=P(s,e[o],r,n):e[o]=M(s)}return e},dt=(t=[])=>[...new Set(t)],C=(t,e)=>t>e?1:t<e?-1:0,U=(t=[],e=null)=>{let r=[...t],n=e||C;return r.sort(n),r},wt=(t=[],e=1,r="")=>!p(r)||!a(t[0],r)?t:U(t,(n,o)=>n[r]>o[r]?e:n[r]<o[r]?-1*e:0),q=(t=[])=>{let e=[...t],r=[],n=e.length;for(;n>0;){let o=Math.floor(Math.random()*n);r.push(e.splice(o,1)[0]),n--}return r},jt=(t=[],e=1)=>{let r=q(t),n=Math.max(1,e),o=Math.min(n,r.length-1);return r.splice(0,o)};export{M as clone,pt as compose,P as copies,ut as curry,S as equals,Z as escapeHTML,st as formatDateString,ct as formatTimeAgo,et as genid,a as hasProperty,u as isArray,R as isBoolean,m as isDate,B as isElement,$ as isEmail,w as isEmpty,z as isFunction,F as isInteger,H as isLetter,T as isNil,N as isNull,y as isNumber,l as isObject,p as isString,_ as isUndefined,b as maybe,jt as pick,at as pipe,A as randint,j as replaceAll,q as shuffle,rt as slugify,U as sort,wt as sortBy,I as stripAccent,Q as stripTags,K as truncate,k as ucfirst,tt as ucwords,v as unescapeHTML,dt as unique};

@@ -1,2 +0,2 @@

// bellajs@11.0.0rc1, by @ndaidong - built with esbuild at 2022-01-02T10:31:26.719Z - published under MIT license
var bella=(()=>{var E=Object.defineProperty;var L=Object.getOwnPropertyDescriptor;var R=Object.getOwnPropertyNames;var H=Object.prototype.hasOwnProperty;var B=t=>E(t,"__esModule",{value:!0});var J=(t,e)=>{for(var r in e)E(t,r,{get:e[r],enumerable:!0})},$=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of R(e))!H.call(t,o)&&(r||o!=="default")&&E(t,o,{get:()=>e[o],enumerable:!(n=L(e,o))||n.enumerable});return t};var W=(t=>(e,r)=>t&&t.get(e)||(r=$(B({}),e,1),t&&t.set(e,r),r))(typeof WeakMap!="undefined"?new WeakMap:0);var St={};J(St,{clone:()=>N,compose:()=>yt,copies:()=>Y,curry:()=>xt,equals:()=>O,escapeHTML:()=>nt,genid:()=>ct,hasProperty:()=>h,isArray:()=>l,isBoolean:()=>K,isDate:()=>a,isElement:()=>V,isEmail:()=>v,isEmpty:()=>j,isFunction:()=>Q,isInteger:()=>X,isLetter:()=>Z,isNil:()=>q,isNull:()=>C,isNumber:()=>M,isObject:()=>g,isString:()=>f,isUndefined:()=>U,maybe:()=>A,md5:()=>mt,now:()=>I,pick:()=>Dt,pipe:()=>wt,randint:()=>T,replaceAll:()=>D,shuffle:()=>G,slugify:()=>it,sort:()=>F,sortBy:()=>jt,stripAccent:()=>P,stripTags:()=>rt,time:()=>S,toDateString:()=>k,toLocalDateString:()=>dt,toRelativeTime:()=>gt,toUTCDateString:()=>ht,truncate:()=>et,ucfirst:()=>z,ucwords:()=>st,unescapeHTML:()=>ot,unique:()=>Mt});var w=t=>({}).toString.call(t),X=t=>Number.isInteger(t),l=t=>Array.isArray(t),f=t=>String(t)===t,M=t=>Number(t)===t,K=t=>Boolean(t)===t,C=t=>w(t)==="[object Null]",U=t=>w(t)==="[object Undefined]",q=t=>U(t)||C(t),Q=t=>w(t)==="[object Function]",g=t=>w(t)==="[object Object]"&&!l(t),a=t=>t instanceof Date&&!isNaN(t.valueOf()),V=t=>w(t).match(/^\[object HTML\w*Element]$/)!==null,Z=t=>{let e=/^[a-z]+$/i;return f(t)&&e.test(t)},v=t=>{let e=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;return f(t)&&e.test(t)},j=t=>!t||q(t)||f(t)&&t===""||l(t)&&t.length===0||g(t)&&Object.keys(t).length===0,h=(t,e)=>!t||!e?!1:Object.prototype.hasOwnProperty.call(t,e);var O=(t,e)=>{if(j(t)&&j(e))return!0;if(a(t)&&a(e))return t.getTime()===e.getTime();if(l(t)&&l(e)){if(t.length!==e.length)return!1;let r=!0;for(let n=0;n<t.length;n++)if(!O(t[n],e[n])){r=!1;break}return r}if(g(t)&&g(e)){if(Object.keys(t).length!==Object.keys(e).length)return!1;let r=!0;for(let n in t)if(!h(e,n)||!O(t[n],e[n])){r=!1;break}return r}return t===e};var tt=Number.MAX_SAFE_INTEGER,T=(t,e)=>{if((!t||t<0)&&(t=0),e||(e=tt),t===e)return e;t>e&&(t=Math.min(t,e),e=Math.max(t,e));let r=t,n=e-t+1;return Math.floor(Math.random()*n)+r};var m=t=>{let e=M(t)?String(t):t;if(!f(e))throw new Error("InvalidInput: String required.");return e},et=(t,e)=>{let r=m(t),n=e||140;if(r.length<=n)return r;let o=r.substring(0,n),s=o.split(" "),c=s.length,i="";return c>1?(s.pop(),i+=s.join(" "),i.length<r.length&&(i+="...")):(o=o.substring(0,n-3),i=o+"..."),i},rt=t=>m(t).replace(/<.*?>/gi," ").replace(/\s\s+/g," ").trim(),nt=t=>m(t).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;"),ot=t=>m(t).replace(/&quot;/g,'"').replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&amp;/g,"&"),z=t=>{let e=m(t).toLowerCase();return e.length>1?e.charAt(0).toUpperCase()+e.slice(1):e.toUpperCase()},st=t=>m(t).split(" ").map(e=>z(e)).join(" "),D=(t,e,r)=>{let n=m(t);if(M(e)&&(e=String(e)),M(r)&&(r=String(r)),f(e)&&f(r))n=n.split(e).join(r);else if(l(e)&&f(r))e.forEach(o=>{n=D(n,o,r)});else if(l(e)&&l(r)&&e.length===r.length){let o=e.length;if(o>0)for(let s=0;s<o;s++){let c=e[s],i=r[s];n=D(n,c,i)}}return n},P=t=>{let e=m(t),r={a:"á|à|ả|ã|ạ|ă|ắ|ặ|ằ|ẳ|ẵ|â|ấ|ầ|ẩ|ẫ|ậ|ä",A:"Á|À|Ả|Ã|Ạ|Ă|Ắ|Ặ|Ằ|Ẳ|Ẵ|Â|Ấ|Ầ|Ẩ|Ẫ|Ậ|Ä",c:"ç",C:"Ç",d:"đ",D:"Đ",e:"é|è|ẻ|ẽ|ẹ|ê|ế|ề|ể|ễ|ệ|ë",E:"É|È|Ẻ|Ẽ|Ẹ|Ê|Ế|Ề|Ể|Ễ|Ệ|Ë",i:"í|ì|ỉ|ĩ|ị|ï|î",I:"Í|Ì|Ỉ|Ĩ|Ị|Ï|Î",o:"ó|ò|ỏ|õ|ọ|ô|ố|ồ|ổ|ỗ|ộ|ơ|ớ|ờ|ở|ỡ|ợ|ö",O:"Ó|Ò|Ỏ|Õ|Ọ|Ô|Ố|Ồ|Ổ|Ô|Ộ|Ơ|Ớ|Ờ|Ở|Ỡ|Ợ|Ö",u:"ú|ù|ủ|ũ|ụ|ư|ứ|ừ|ử|ữ|ự|û",U:"Ú|Ù|Ủ|Ũ|Ụ|Ư|Ứ|Ừ|Ử|Ữ|Ự|Û",y:"ý|ỳ|ỷ|ỹ|ỵ",Y:"Ý|Ỳ|Ỷ|Ỹ|Ỵ"},n=(o,s)=>{e=D(e,o,s)};for(let o in r)h(r,o)&&r[o].split("|").forEach(c=>n(c,o));return e},ct=(t,e="")=>{let r="abcdefghijklmnopqrstuvwxyz",n=r.toUpperCase(),s=[r,n,"0123456789"].join("").split("").sort(()=>Math.random()>.5).join(""),c=s.length,i=Math.max(t||32,e.length),p=e;for(;p.length<i;){let u=T(0,c);p+=s.charAt(u)||""}return p},it=(t,e="-")=>P(t).trim().toLowerCase().replace(/\W+/g," ").replace(/\s+/g," ").replace(/\s/g,e);var ut="D, M d, Y h:i:s A",lt=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],at=["January","February","March","April","May","June","July","August","September","October","November","December"],I=()=>new Date,S=()=>Date.now(),_=I().getTimezoneOffset(),pt=(()=>{let t=Math.abs(_/60),e=_<0?"+":"-";return["GMT",e,String(t).padStart(4,"0")].join("")})(),b=t=>String(t<10?"0"+t:t),ft=t=>{let e=t+" ",r=e.charAt(e.length-2);return r==="1"?e="st":r==="2"?e="nd":r==="3"?e="rd":e="th",e},k=(t,e=ut)=>{let r=a(t)?t:new Date(t);if(!a(r))throw new Error("InvalidInput: Number or Date required.");let n=/\.*\\?([a-z])/gi,o=e.includes("a")||e.includes("A"),s=lt,c=at,i={Y(){return r.getFullYear()},y(){return(i.Y()+"").slice(-2)},F(){return c[i.n()-1]},M(){return(i.F()+"").slice(0,3)},m(){return b(i.n())},n(){return r.getMonth()+1},S(){return ft(i.j())},j(){return r.getDate()},d(){return b(i.j())},t(){return new Date(i.Y(),i.n(),0).getDate()},w(){return r.getDay()},l(){return s[i.w()]},D(){return(i.l()+"").slice(0,3)},G(){return r.getHours()},g(){return i.G()%12||12},h(){return b(o?i.g():i.G())},i(){return b(r.getMinutes())},s(){return b(r.getSeconds())},a(){return i.G()>11?"pm":"am"},A(){return i.a().toUpperCase()},O(){return pt}},p=(u,y)=>i[u]?i[u]():y;return e.replace(n,p)},gt=(t=S())=>{let e=a(t)?t:new Date(t);if(!a(e))throw new Error("InvalidInput: Number or Date required.");let r=I()-e,n=parseInt(e,10);if(isNaN(n)&&(n=0),r<=n)return"Just now";let o=null,s={millisecond:1,second:1e3,minute:60,hour:60,day:24,month:30,year:12};for(let c in s){if(r<s[c])break;o=c,r/=s[c]}return r=Math.floor(r),r!==1&&(o+="s"),[r,o].join(" ")+" ago"},ht=(t=S())=>{let e=a(t)?t:new Date(t);if(!a(e))throw new Error("InvalidInput: Number or Date required.");let r=e.getMinutes(),n=new Date(e);return n.setMinutes(r+_),`${k(n,"D, j M Y h:i:s")} GMT+0000`},dt=(t=S())=>{let e=a(t)?t:new Date(t);if(!a(e))throw new Error("InvalidInput: Number or Date required.");return k(e,"D, j M Y h:i:s O")};var mt=t=>{for(var e=[],r=0;r<64;)e[r]=0|Math.abs(Math.sin(++r))*4294967296;for(var n,o,s,c,i=[],p=decodeURIComponent(encodeURI(t)),u=p.length,y=[n=1732584193,o=-271733879,~n,~o],d=0;d<=u;)i[d>>2]|=(p.charCodeAt(d)||128)<<8*(d++%4);for(i[t=(u+8>>6)*16+14]=u*8,d=0;d<t;d+=16){for(u=y,c=0;c<64;)u=[s=u[3],(n=u[1]|0)+((s=u[0]+[n&(o=u[2])|~n&s,s&n|~s&o,n^o^s,o^(n|~s)][u=c>>4]+(e[c]+(i[[c,5*c+1,3*c+5,7*c][u]%16+d]|0)))<<(u=[7,12,17,22,5,9,14,20,4,11,16,23,6,10,15,21][4*u+c++%4])|s>>>32-u),n,o];for(c=4;c;)y[--c]=y[c]+u[c]}for(t="";c<32;)t+=(y[c>>3]>>(1^c++&7)*4&15).toString(16);return t};var xt=t=>{let e=t.length,r=(n,o)=>n>0?(...s)=>r(n-s.length,[...o,...s]):t(...o);return r(e,[])};var yt=(...t)=>t.reduce((e,r)=>n=>e(r(n)));var wt=(...t)=>t.reduce((e,r)=>n=>r(e(n)));var x=(t,e,r,n={})=>{let{writable:o=!1,configurable:s=!1,enumerable:c=!1}=n;Object.defineProperty(t,e,{value:r,writable:o,configurable:s,enumerable:c})};var A=t=>{let e=t,r=()=>e==null,n=()=>e,o=p=>A(e||p()),s=p=>A(p(e)===!0?e:null),c=p=>A(r()?null:p(e)),i=Object.create({});return x(i,"__value__",e,{enumerable:!0}),x(i,"__type__","Maybe",{enumerable:!0}),x(i,"isNil",r),x(i,"value",n),x(i,"map",c),x(i,"if",s),x(i,"else",o),i};var N=(t,e=null)=>{let r=e||new Set;if(r.has(t))return t;if(r.add(t),a(t))return new Date(t.valueOf());let n=s=>{let c=Object.create({});for(let i in s)h(s,i)&&(c[i]=N(s[i],r));return c},o=s=>[...s].map(c=>l(c)?o(c):g(c)?n(c):N(c,r));return l(t)?o(t):g(t)?n(t):t},Y=(t,e,r=!1,n=[])=>{for(let o in t)if(!(n.length>0&&n.includes(o))&&(!r||r&&h(e,o))){let s=t[o],c=e[o];g(c)&&g(s)||l(c)&&l(s)?e[o]=Y(s,e[o],r,n):e[o]=N(s)}return e},Mt=(t=[])=>[...new Set(t)],bt=(t,e)=>t>e?1:t<e?-1:0,F=(t=[],e=null)=>{let r=[...t],n=e||bt;return r.sort(n),r},jt=(t=[],e=1,r="")=>!f(r)||!h(t[0],r)?t:F(t,(n,o)=>n[r]>o[r]?e:n[r]<o[r]?-1*e:0),G=(t=[])=>{let e=[...t],r=[],n=e.length;for(;n>0;){let o=Math.floor(Math.random()*n);r.push(e.splice(o,1)[0]),n--}return r},Dt=(t=[],e=1)=>{let r=G(t),n=Math.max(1,e),o=Math.min(n,r.length-1);return r.splice(0,o)};return W(St);})();
// bellajs@11.0.0rc2, by @ndaidong - built with esbuild at 2022-01-03T13:45:10.948Z - published under MIT license
var bella=(()=>{var S=Object.defineProperty;var U=Object.getOwnPropertyDescriptor;var q=Object.getOwnPropertyNames;var F=Object.prototype.hasOwnProperty;var R=t=>S(t,"__esModule",{value:!0});var z=(t,e)=>{for(var r in e)S(t,r,{get:e[r],enumerable:!0})},B=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of q(e))!F.call(t,o)&&(r||o!=="default")&&S(t,o,{get:()=>e[o],enumerable:!(n=U(e,o))||n.enumerable});return t};var H=(t=>(e,r)=>t&&t.get(e)||(r=B(R({}),e,1),t&&t.set(e,r),r))(typeof WeakMap!="undefined"?new WeakMap:0);var gt={};z(gt,{clone:()=>M,compose:()=>it,copies:()=>I,curry:()=>ct,equals:()=>A,escapeHTML:()=>Z,formatDateString:()=>ot,formatTimeAgo:()=>st,genid:()=>et,hasProperty:()=>a,isArray:()=>u,isBoolean:()=>V,isDate:()=>h,isElement:()=>G,isEmail:()=>Y,isEmpty:()=>d,isFunction:()=>X,isInteger:()=>$,isLetter:()=>W,isNil:()=>_,isNull:()=>E,isNumber:()=>y,isObject:()=>l,isString:()=>p,isUndefined:()=>N,maybe:()=>b,pick:()=>at,pipe:()=>ut,randint:()=>O,replaceAll:()=>w,shuffle:()=>P,slugify:()=>rt,sort:()=>L,sortBy:()=>ft,stripAccent:()=>D,stripTags:()=>Q,truncate:()=>K,ucfirst:()=>T,ucwords:()=>tt,unescapeHTML:()=>v,unique:()=>lt});var m=t=>({}).toString.call(t),$=t=>Number.isInteger(t),u=t=>Array.isArray(t),p=t=>String(t)===t,y=t=>Number(t)===t,V=t=>Boolean(t)===t,E=t=>m(t)==="[object Null]",N=t=>m(t)==="[object Undefined]",_=t=>N(t)||E(t),X=t=>m(t)==="[object Function]",l=t=>m(t)==="[object Object]"&&!u(t),h=t=>t instanceof Date&&!isNaN(t.valueOf()),G=t=>m(t).match(/^\[object HTML\w*Element]$/)!==null,W=t=>{let e=/^[a-z]+$/i;return p(t)&&e.test(t)},Y=t=>{let e=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;return p(t)&&e.test(t)},d=t=>!t||_(t)||p(t)&&t===""||u(t)&&t.length===0||l(t)&&Object.keys(t).length===0,a=(t,e)=>!t||!e?!1:Object.prototype.hasOwnProperty.call(t,e);var A=(t,e)=>{if(d(t)&&d(e))return!0;if(h(t)&&h(e))return t.getTime()===e.getTime();if(u(t)&&u(e)){if(t.length!==e.length)return!1;let r=!0;for(let n=0;n<t.length;n++)if(!A(t[n],e[n])){r=!1;break}return r}if(l(t)&&l(e)){if(Object.keys(t).length!==Object.keys(e).length)return!1;let r=!0;for(let n in t)if(!a(e,n)||!A(t[n],e[n])){r=!1;break}return r}return t===e};var J=Number.MAX_SAFE_INTEGER,O=(t,e)=>{if((!t||t<0)&&(t=0),e||(e=J),t===e)return e;t>e&&(t=Math.min(t,e),e=Math.max(t,e));let r=t,n=e-t+1;return Math.floor(Math.random()*n)+r};var g=t=>{let e=y(t)?String(t):t;if(!p(e))throw new Error("InvalidInput: String required.");return e},K=(t,e)=>{let r=g(t),n=e||140;if(r.length<=n)return r;let o=r.substring(0,n),s=o.split(" "),i=s.length,c="";return i>1?(s.pop(),c+=s.join(" "),c.length<r.length&&(c+="...")):(o=o.substring(0,n-3),c=o+"..."),c},Q=t=>g(t).replace(/<.*?>/gi," ").replace(/\s\s+/g," ").trim(),Z=t=>g(t).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;"),v=t=>g(t).replace(/&quot;/g,'"').replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&amp;/g,"&"),T=t=>{let e=g(t).toLowerCase();return e.length>1?e.charAt(0).toUpperCase()+e.slice(1):e.toUpperCase()},tt=t=>g(t).split(" ").map(e=>T(e)).join(" "),w=(t,e,r)=>{let n=g(t);if(y(e)&&(e=String(e)),y(r)&&(r=String(r)),p(e)&&p(r))n=n.split(e).join(r);else if(u(e)&&p(r))e.forEach(o=>{n=w(n,o,r)});else if(u(e)&&u(r)&&e.length===r.length){let o=e.length;if(o>0)for(let s=0;s<o;s++){let i=e[s],c=r[s];n=w(n,i,c)}}return n},D=t=>{let e=g(t),r={a:"á|à|ả|ã|ạ|ă|ắ|ặ|ằ|ẳ|ẵ|â|ấ|ầ|ẩ|ẫ|ậ|ä",A:"Á|À|Ả|Ã|Ạ|Ă|Ắ|Ặ|Ằ|Ẳ|Ẵ|Â|Ấ|Ầ|Ẩ|Ẫ|Ậ|Ä",c:"ç",C:"Ç",d:"đ",D:"Đ",e:"é|è|ẻ|ẽ|ẹ|ê|ế|ề|ể|ễ|ệ|ë",E:"É|È|Ẻ|Ẽ|Ẹ|Ê|Ế|Ề|Ể|Ễ|Ệ|Ë",i:"í|ì|ỉ|ĩ|ị|ï|î",I:"Í|Ì|Ỉ|Ĩ|Ị|Ï|Î",o:"ó|ò|ỏ|õ|ọ|ô|ố|ồ|ổ|ỗ|ộ|ơ|ớ|ờ|ở|ỡ|ợ|ö",O:"Ó|Ò|Ỏ|Õ|Ọ|Ô|Ố|Ồ|Ổ|Ô|Ộ|Ơ|Ớ|Ờ|Ở|Ỡ|Ợ|Ö",u:"ú|ù|ủ|ũ|ụ|ư|ứ|ừ|ử|ữ|ự|û",U:"Ú|Ù|Ủ|Ũ|Ụ|Ư|Ứ|Ừ|Ử|Ữ|Ự|Û",y:"ý|ỳ|ỷ|ỹ|ỵ",Y:"Ý|Ỳ|Ỷ|Ỹ|Ỵ"},n=(o,s)=>{e=w(e,o,s)};for(let o in r)a(r,o)&&r[o].split("|").forEach(i=>n(i,o));return e},et=(t,e="")=>{let r="abcdefghijklmnopqrstuvwxyz",n=r.toUpperCase(),s=[r,n,"0123456789"].join("").split("").sort(()=>Math.random()>.5).join(""),i=s.length,c=Math.max(t||32,e.length),f=e;for(;f.length<c;){let C=O(0,i);f+=s.charAt(C)||""}return f},rt=(t,e="-")=>D(t).trim().toLowerCase().replace(/\W+/g," ").replace(/\s+/g," ").replace(/\s/g,e);var k={dateStyle:"medium",timeStyle:"long"},j={second:1e3,minute:60,hour:60,day:24,week:7,month:4,year:12},nt=t=>{try{return new Intl.Locale(t).language!==""}catch{return!1}},ot=(...t)=>{let e=t[0],r=nt(t[1])?t[1]:"en",n=t.length>=3?t[2]:t.length===1?k:l(t[1])?t[1]:k;return new Intl.DateTimeFormat(r,n).format(new Date(e))},st=(t,e="en",r="just now")=>{let n=new Date(t),o=Date.now()-n;if(o<=j.second)return r;let s="second";for(let c in j){if(o<j[c])break;s=c,o/=j[c]}return o=Math.floor(o),new Intl.RelativeTimeFormat(e).format(-o,s)};var ct=t=>{let e=t.length,r=(n,o)=>n>0?(...s)=>r(n-s.length,[...o,...s]):t(...o);return r(e,[])};var it=(...t)=>t.reduce((e,r)=>n=>e(r(n)));var ut=(...t)=>t.reduce((e,r)=>n=>r(e(n)));var x=(t,e,r,n={})=>{let{writable:o=!1,configurable:s=!1,enumerable:i=!1}=n;Object.defineProperty(t,e,{value:r,writable:o,configurable:s,enumerable:i})};var b=t=>{let e=t,r=()=>e==null,n=()=>e,o=f=>b(e||f()),s=f=>b(f(e)===!0?e:null),i=f=>b(r()?null:f(e)),c=Object.create({});return x(c,"__value__",e,{enumerable:!0}),x(c,"__type__","Maybe",{enumerable:!0}),x(c,"isNil",r),x(c,"value",n),x(c,"map",i),x(c,"if",s),x(c,"else",o),c};var M=(t,e=null)=>{let r=e||new Set;if(r.has(t))return t;if(r.add(t),h(t))return new Date(t.valueOf());let n=s=>{let i=Object.create({});for(let c in s)a(s,c)&&(i[c]=M(s[c],r));return i},o=s=>[...s].map(i=>u(i)?o(i):l(i)?n(i):M(i,r));return u(t)?o(t):l(t)?n(t):t},I=(t,e,r=!1,n=[])=>{for(let o in t)if(!(n.length>0&&n.includes(o))&&(!r||r&&a(e,o))){let s=t[o],i=e[o];l(i)&&l(s)||u(i)&&u(s)?e[o]=I(s,e[o],r,n):e[o]=M(s)}return e},lt=(t=[])=>[...new Set(t)],pt=(t,e)=>t>e?1:t<e?-1:0,L=(t=[],e=null)=>{let r=[...t],n=e||pt;return r.sort(n),r},ft=(t=[],e=1,r="")=>!p(r)||!a(t[0],r)?t:L(t,(n,o)=>n[r]>o[r]?e:n[r]<o[r]?-1*e:0),P=(t=[])=>{let e=[...t],r=[],n=e.length;for(;n>0;){let o=Math.floor(Math.random()*n);r.push(e.splice(o,1)[0]),n--}return r},at=(t=[],e=1)=>{let r=P(t),n=Math.max(1,e),o=Math.min(n,r.length-1);return r.splice(0,o)};return H(gt);})();
/**
* bellajs@11.0.0rc1
* built with esbuild at: 2022-01-02T10:31:26.719Z
* bellajs@11.0.0rc2
* built with esbuild at: 2022-01-03T13:45:10.948Z
* repository: https://github.com/ndaidong/bellajs

@@ -8,2 +8,2 @@ * maintainer: @ndaidong

**/
var E=Object.defineProperty;var L=Object.getOwnPropertyDescriptor;var R=Object.getOwnPropertyNames;var H=Object.prototype.hasOwnProperty;var B=t=>E(t,"__esModule",{value:!0});var J=(t,e)=>{for(var r in e)E(t,r,{get:e[r],enumerable:!0})},$=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of R(e))!H.call(t,o)&&(r||o!=="default")&&E(t,o,{get:()=>e[o],enumerable:!(n=L(e,o))||n.enumerable});return t};var W=(t=>(e,r)=>t&&t.get(e)||(r=$(B({}),e,1),t&&t.set(e,r),r))(typeof WeakMap!="undefined"?new WeakMap:0);var St={};J(St,{clone:()=>N,compose:()=>yt,copies:()=>Y,curry:()=>xt,equals:()=>O,escapeHTML:()=>nt,genid:()=>ct,hasProperty:()=>h,isArray:()=>l,isBoolean:()=>K,isDate:()=>a,isElement:()=>V,isEmail:()=>v,isEmpty:()=>j,isFunction:()=>Q,isInteger:()=>X,isLetter:()=>Z,isNil:()=>q,isNull:()=>C,isNumber:()=>M,isObject:()=>g,isString:()=>f,isUndefined:()=>U,maybe:()=>A,md5:()=>mt,now:()=>I,pick:()=>Dt,pipe:()=>wt,randint:()=>T,replaceAll:()=>D,shuffle:()=>G,slugify:()=>it,sort:()=>F,sortBy:()=>jt,stripAccent:()=>P,stripTags:()=>rt,time:()=>S,toDateString:()=>k,toLocalDateString:()=>dt,toRelativeTime:()=>gt,toUTCDateString:()=>ht,truncate:()=>et,ucfirst:()=>z,ucwords:()=>st,unescapeHTML:()=>ot,unique:()=>Mt});var w=t=>({}).toString.call(t),X=t=>Number.isInteger(t),l=t=>Array.isArray(t),f=t=>String(t)===t,M=t=>Number(t)===t,K=t=>Boolean(t)===t,C=t=>w(t)==="[object Null]",U=t=>w(t)==="[object Undefined]",q=t=>U(t)||C(t),Q=t=>w(t)==="[object Function]",g=t=>w(t)==="[object Object]"&&!l(t),a=t=>t instanceof Date&&!isNaN(t.valueOf()),V=t=>w(t).match(/^\[object HTML\w*Element]$/)!==null,Z=t=>{let e=/^[a-z]+$/i;return f(t)&&e.test(t)},v=t=>{let e=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;return f(t)&&e.test(t)},j=t=>!t||q(t)||f(t)&&t===""||l(t)&&t.length===0||g(t)&&Object.keys(t).length===0,h=(t,e)=>!t||!e?!1:Object.prototype.hasOwnProperty.call(t,e);var O=(t,e)=>{if(j(t)&&j(e))return!0;if(a(t)&&a(e))return t.getTime()===e.getTime();if(l(t)&&l(e)){if(t.length!==e.length)return!1;let r=!0;for(let n=0;n<t.length;n++)if(!O(t[n],e[n])){r=!1;break}return r}if(g(t)&&g(e)){if(Object.keys(t).length!==Object.keys(e).length)return!1;let r=!0;for(let n in t)if(!h(e,n)||!O(t[n],e[n])){r=!1;break}return r}return t===e};var tt=Number.MAX_SAFE_INTEGER,T=(t,e)=>{if((!t||t<0)&&(t=0),e||(e=tt),t===e)return e;t>e&&(t=Math.min(t,e),e=Math.max(t,e));let r=t,n=e-t+1;return Math.floor(Math.random()*n)+r};var m=t=>{let e=M(t)?String(t):t;if(!f(e))throw new Error("InvalidInput: String required.");return e},et=(t,e)=>{let r=m(t),n=e||140;if(r.length<=n)return r;let o=r.substring(0,n),s=o.split(" "),c=s.length,i="";return c>1?(s.pop(),i+=s.join(" "),i.length<r.length&&(i+="...")):(o=o.substring(0,n-3),i=o+"..."),i},rt=t=>m(t).replace(/<.*?>/gi," ").replace(/\s\s+/g," ").trim(),nt=t=>m(t).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;"),ot=t=>m(t).replace(/&quot;/g,'"').replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&amp;/g,"&"),z=t=>{let e=m(t).toLowerCase();return e.length>1?e.charAt(0).toUpperCase()+e.slice(1):e.toUpperCase()},st=t=>m(t).split(" ").map(e=>z(e)).join(" "),D=(t,e,r)=>{let n=m(t);if(M(e)&&(e=String(e)),M(r)&&(r=String(r)),f(e)&&f(r))n=n.split(e).join(r);else if(l(e)&&f(r))e.forEach(o=>{n=D(n,o,r)});else if(l(e)&&l(r)&&e.length===r.length){let o=e.length;if(o>0)for(let s=0;s<o;s++){let c=e[s],i=r[s];n=D(n,c,i)}}return n},P=t=>{let e=m(t),r={a:"á|à|ả|ã|ạ|ă|ắ|ặ|ằ|ẳ|ẵ|â|ấ|ầ|ẩ|ẫ|ậ|ä",A:"Á|À|Ả|Ã|Ạ|Ă|Ắ|Ặ|Ằ|Ẳ|Ẵ|Â|Ấ|Ầ|Ẩ|Ẫ|Ậ|Ä",c:"ç",C:"Ç",d:"đ",D:"Đ",e:"é|è|ẻ|ẽ|ẹ|ê|ế|ề|ể|ễ|ệ|ë",E:"É|È|Ẻ|Ẽ|Ẹ|Ê|Ế|Ề|Ể|Ễ|Ệ|Ë",i:"í|ì|ỉ|ĩ|ị|ï|î",I:"Í|Ì|Ỉ|Ĩ|Ị|Ï|Î",o:"ó|ò|ỏ|õ|ọ|ô|ố|ồ|ổ|ỗ|ộ|ơ|ớ|ờ|ở|ỡ|ợ|ö",O:"Ó|Ò|Ỏ|Õ|Ọ|Ô|Ố|Ồ|Ổ|Ô|Ộ|Ơ|Ớ|Ờ|Ở|Ỡ|Ợ|Ö",u:"ú|ù|ủ|ũ|ụ|ư|ứ|ừ|ử|ữ|ự|û",U:"Ú|Ù|Ủ|Ũ|Ụ|Ư|Ứ|Ừ|Ử|Ữ|Ự|Û",y:"ý|ỳ|ỷ|ỹ|ỵ",Y:"Ý|Ỳ|Ỷ|Ỹ|Ỵ"},n=(o,s)=>{e=D(e,o,s)};for(let o in r)h(r,o)&&r[o].split("|").forEach(c=>n(c,o));return e},ct=(t,e="")=>{let r="abcdefghijklmnopqrstuvwxyz",n=r.toUpperCase(),s=[r,n,"0123456789"].join("").split("").sort(()=>Math.random()>.5).join(""),c=s.length,i=Math.max(t||32,e.length),p=e;for(;p.length<i;){let u=T(0,c);p+=s.charAt(u)||""}return p},it=(t,e="-")=>P(t).trim().toLowerCase().replace(/\W+/g," ").replace(/\s+/g," ").replace(/\s/g,e);var ut="D, M d, Y h:i:s A",lt=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],at=["January","February","March","April","May","June","July","August","September","October","November","December"],I=()=>new Date,S=()=>Date.now(),_=I().getTimezoneOffset(),pt=(()=>{let t=Math.abs(_/60),e=_<0?"+":"-";return["GMT",e,String(t).padStart(4,"0")].join("")})(),b=t=>String(t<10?"0"+t:t),ft=t=>{let e=t+" ",r=e.charAt(e.length-2);return r==="1"?e="st":r==="2"?e="nd":r==="3"?e="rd":e="th",e},k=(t,e=ut)=>{let r=a(t)?t:new Date(t);if(!a(r))throw new Error("InvalidInput: Number or Date required.");let n=/\.*\\?([a-z])/gi,o=e.includes("a")||e.includes("A"),s=lt,c=at,i={Y(){return r.getFullYear()},y(){return(i.Y()+"").slice(-2)},F(){return c[i.n()-1]},M(){return(i.F()+"").slice(0,3)},m(){return b(i.n())},n(){return r.getMonth()+1},S(){return ft(i.j())},j(){return r.getDate()},d(){return b(i.j())},t(){return new Date(i.Y(),i.n(),0).getDate()},w(){return r.getDay()},l(){return s[i.w()]},D(){return(i.l()+"").slice(0,3)},G(){return r.getHours()},g(){return i.G()%12||12},h(){return b(o?i.g():i.G())},i(){return b(r.getMinutes())},s(){return b(r.getSeconds())},a(){return i.G()>11?"pm":"am"},A(){return i.a().toUpperCase()},O(){return pt}},p=(u,y)=>i[u]?i[u]():y;return e.replace(n,p)},gt=(t=S())=>{let e=a(t)?t:new Date(t);if(!a(e))throw new Error("InvalidInput: Number or Date required.");let r=I()-e,n=parseInt(e,10);if(isNaN(n)&&(n=0),r<=n)return"Just now";let o=null,s={millisecond:1,second:1e3,minute:60,hour:60,day:24,month:30,year:12};for(let c in s){if(r<s[c])break;o=c,r/=s[c]}return r=Math.floor(r),r!==1&&(o+="s"),[r,o].join(" ")+" ago"},ht=(t=S())=>{let e=a(t)?t:new Date(t);if(!a(e))throw new Error("InvalidInput: Number or Date required.");let r=e.getMinutes(),n=new Date(e);return n.setMinutes(r+_),`${k(n,"D, j M Y h:i:s")} GMT+0000`},dt=(t=S())=>{let e=a(t)?t:new Date(t);if(!a(e))throw new Error("InvalidInput: Number or Date required.");return k(e,"D, j M Y h:i:s O")};var mt=t=>{for(var e=[],r=0;r<64;)e[r]=0|Math.abs(Math.sin(++r))*4294967296;for(var n,o,s,c,i=[],p=decodeURIComponent(encodeURI(t)),u=p.length,y=[n=1732584193,o=-271733879,~n,~o],d=0;d<=u;)i[d>>2]|=(p.charCodeAt(d)||128)<<8*(d++%4);for(i[t=(u+8>>6)*16+14]=u*8,d=0;d<t;d+=16){for(u=y,c=0;c<64;)u=[s=u[3],(n=u[1]|0)+((s=u[0]+[n&(o=u[2])|~n&s,s&n|~s&o,n^o^s,o^(n|~s)][u=c>>4]+(e[c]+(i[[c,5*c+1,3*c+5,7*c][u]%16+d]|0)))<<(u=[7,12,17,22,5,9,14,20,4,11,16,23,6,10,15,21][4*u+c++%4])|s>>>32-u),n,o];for(c=4;c;)y[--c]=y[c]+u[c]}for(t="";c<32;)t+=(y[c>>3]>>(1^c++&7)*4&15).toString(16);return t};var xt=t=>{let e=t.length,r=(n,o)=>n>0?(...s)=>r(n-s.length,[...o,...s]):t(...o);return r(e,[])};var yt=(...t)=>t.reduce((e,r)=>n=>e(r(n)));var wt=(...t)=>t.reduce((e,r)=>n=>r(e(n)));var x=(t,e,r,n={})=>{let{writable:o=!1,configurable:s=!1,enumerable:c=!1}=n;Object.defineProperty(t,e,{value:r,writable:o,configurable:s,enumerable:c})};var A=t=>{let e=t,r=()=>e==null,n=()=>e,o=p=>A(e||p()),s=p=>A(p(e)===!0?e:null),c=p=>A(r()?null:p(e)),i=Object.create({});return x(i,"__value__",e,{enumerable:!0}),x(i,"__type__","Maybe",{enumerable:!0}),x(i,"isNil",r),x(i,"value",n),x(i,"map",c),x(i,"if",s),x(i,"else",o),i};var N=(t,e=null)=>{let r=e||new Set;if(r.has(t))return t;if(r.add(t),a(t))return new Date(t.valueOf());let n=s=>{let c=Object.create({});for(let i in s)h(s,i)&&(c[i]=N(s[i],r));return c},o=s=>[...s].map(c=>l(c)?o(c):g(c)?n(c):N(c,r));return l(t)?o(t):g(t)?n(t):t},Y=(t,e,r=!1,n=[])=>{for(let o in t)if(!(n.length>0&&n.includes(o))&&(!r||r&&h(e,o))){let s=t[o],c=e[o];g(c)&&g(s)||l(c)&&l(s)?e[o]=Y(s,e[o],r,n):e[o]=N(s)}return e},Mt=(t=[])=>[...new Set(t)],bt=(t,e)=>t>e?1:t<e?-1:0,F=(t=[],e=null)=>{let r=[...t],n=e||bt;return r.sort(n),r},jt=(t=[],e=1,r="")=>!f(r)||!h(t[0],r)?t:F(t,(n,o)=>n[r]>o[r]?e:n[r]<o[r]?-1*e:0),G=(t=[])=>{let e=[...t],r=[],n=e.length;for(;n>0;){let o=Math.floor(Math.random()*n);r.push(e.splice(o,1)[0]),n--}return r},Dt=(t=[],e=1)=>{let r=G(t),n=Math.max(1,e),o=Math.min(n,r.length-1);return r.splice(0,o)};module.exports=W(St);0&&(module.exports={clone,compose,copies,curry,equals,escapeHTML,genid,hasProperty,isArray,isBoolean,isDate,isElement,isEmail,isEmpty,isFunction,isInteger,isLetter,isNil,isNull,isNumber,isObject,isString,isUndefined,maybe,md5,now,pick,pipe,randint,replaceAll,shuffle,slugify,sort,sortBy,stripAccent,stripTags,time,toDateString,toLocalDateString,toRelativeTime,toUTCDateString,truncate,ucfirst,ucwords,unescapeHTML,unique});
var S=Object.defineProperty;var U=Object.getOwnPropertyDescriptor;var q=Object.getOwnPropertyNames;var F=Object.prototype.hasOwnProperty;var R=t=>S(t,"__esModule",{value:!0});var z=(t,e)=>{for(var r in e)S(t,r,{get:e[r],enumerable:!0})},B=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of q(e))!F.call(t,o)&&(r||o!=="default")&&S(t,o,{get:()=>e[o],enumerable:!(n=U(e,o))||n.enumerable});return t};var H=(t=>(e,r)=>t&&t.get(e)||(r=B(R({}),e,1),t&&t.set(e,r),r))(typeof WeakMap!="undefined"?new WeakMap:0);var gt={};z(gt,{clone:()=>M,compose:()=>it,copies:()=>I,curry:()=>ct,equals:()=>A,escapeHTML:()=>Z,formatDateString:()=>ot,formatTimeAgo:()=>st,genid:()=>et,hasProperty:()=>a,isArray:()=>u,isBoolean:()=>V,isDate:()=>h,isElement:()=>G,isEmail:()=>Y,isEmpty:()=>d,isFunction:()=>X,isInteger:()=>$,isLetter:()=>W,isNil:()=>_,isNull:()=>E,isNumber:()=>y,isObject:()=>l,isString:()=>p,isUndefined:()=>N,maybe:()=>b,pick:()=>at,pipe:()=>ut,randint:()=>O,replaceAll:()=>w,shuffle:()=>P,slugify:()=>rt,sort:()=>L,sortBy:()=>ft,stripAccent:()=>D,stripTags:()=>Q,truncate:()=>K,ucfirst:()=>T,ucwords:()=>tt,unescapeHTML:()=>v,unique:()=>lt});var m=t=>({}).toString.call(t),$=t=>Number.isInteger(t),u=t=>Array.isArray(t),p=t=>String(t)===t,y=t=>Number(t)===t,V=t=>Boolean(t)===t,E=t=>m(t)==="[object Null]",N=t=>m(t)==="[object Undefined]",_=t=>N(t)||E(t),X=t=>m(t)==="[object Function]",l=t=>m(t)==="[object Object]"&&!u(t),h=t=>t instanceof Date&&!isNaN(t.valueOf()),G=t=>m(t).match(/^\[object HTML\w*Element]$/)!==null,W=t=>{let e=/^[a-z]+$/i;return p(t)&&e.test(t)},Y=t=>{let e=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;return p(t)&&e.test(t)},d=t=>!t||_(t)||p(t)&&t===""||u(t)&&t.length===0||l(t)&&Object.keys(t).length===0,a=(t,e)=>!t||!e?!1:Object.prototype.hasOwnProperty.call(t,e);var A=(t,e)=>{if(d(t)&&d(e))return!0;if(h(t)&&h(e))return t.getTime()===e.getTime();if(u(t)&&u(e)){if(t.length!==e.length)return!1;let r=!0;for(let n=0;n<t.length;n++)if(!A(t[n],e[n])){r=!1;break}return r}if(l(t)&&l(e)){if(Object.keys(t).length!==Object.keys(e).length)return!1;let r=!0;for(let n in t)if(!a(e,n)||!A(t[n],e[n])){r=!1;break}return r}return t===e};var J=Number.MAX_SAFE_INTEGER,O=(t,e)=>{if((!t||t<0)&&(t=0),e||(e=J),t===e)return e;t>e&&(t=Math.min(t,e),e=Math.max(t,e));let r=t,n=e-t+1;return Math.floor(Math.random()*n)+r};var g=t=>{let e=y(t)?String(t):t;if(!p(e))throw new Error("InvalidInput: String required.");return e},K=(t,e)=>{let r=g(t),n=e||140;if(r.length<=n)return r;let o=r.substring(0,n),s=o.split(" "),i=s.length,c="";return i>1?(s.pop(),c+=s.join(" "),c.length<r.length&&(c+="...")):(o=o.substring(0,n-3),c=o+"..."),c},Q=t=>g(t).replace(/<.*?>/gi," ").replace(/\s\s+/g," ").trim(),Z=t=>g(t).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;"),v=t=>g(t).replace(/&quot;/g,'"').replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&amp;/g,"&"),T=t=>{let e=g(t).toLowerCase();return e.length>1?e.charAt(0).toUpperCase()+e.slice(1):e.toUpperCase()},tt=t=>g(t).split(" ").map(e=>T(e)).join(" "),w=(t,e,r)=>{let n=g(t);if(y(e)&&(e=String(e)),y(r)&&(r=String(r)),p(e)&&p(r))n=n.split(e).join(r);else if(u(e)&&p(r))e.forEach(o=>{n=w(n,o,r)});else if(u(e)&&u(r)&&e.length===r.length){let o=e.length;if(o>0)for(let s=0;s<o;s++){let i=e[s],c=r[s];n=w(n,i,c)}}return n},D=t=>{let e=g(t),r={a:"á|à|ả|ã|ạ|ă|ắ|ặ|ằ|ẳ|ẵ|â|ấ|ầ|ẩ|ẫ|ậ|ä",A:"Á|À|Ả|Ã|Ạ|Ă|Ắ|Ặ|Ằ|Ẳ|Ẵ|Â|Ấ|Ầ|Ẩ|Ẫ|Ậ|Ä",c:"ç",C:"Ç",d:"đ",D:"Đ",e:"é|è|ẻ|ẽ|ẹ|ê|ế|ề|ể|ễ|ệ|ë",E:"É|È|Ẻ|Ẽ|Ẹ|Ê|Ế|Ề|Ể|Ễ|Ệ|Ë",i:"í|ì|ỉ|ĩ|ị|ï|î",I:"Í|Ì|Ỉ|Ĩ|Ị|Ï|Î",o:"ó|ò|ỏ|õ|ọ|ô|ố|ồ|ổ|ỗ|ộ|ơ|ớ|ờ|ở|ỡ|ợ|ö",O:"Ó|Ò|Ỏ|Õ|Ọ|Ô|Ố|Ồ|Ổ|Ô|Ộ|Ơ|Ớ|Ờ|Ở|Ỡ|Ợ|Ö",u:"ú|ù|ủ|ũ|ụ|ư|ứ|ừ|ử|ữ|ự|û",U:"Ú|Ù|Ủ|Ũ|Ụ|Ư|Ứ|Ừ|Ử|Ữ|Ự|Û",y:"ý|ỳ|ỷ|ỹ|ỵ",Y:"Ý|Ỳ|Ỷ|Ỹ|Ỵ"},n=(o,s)=>{e=w(e,o,s)};for(let o in r)a(r,o)&&r[o].split("|").forEach(i=>n(i,o));return e},et=(t,e="")=>{let r="abcdefghijklmnopqrstuvwxyz",n=r.toUpperCase(),s=[r,n,"0123456789"].join("").split("").sort(()=>Math.random()>.5).join(""),i=s.length,c=Math.max(t||32,e.length),f=e;for(;f.length<c;){let C=O(0,i);f+=s.charAt(C)||""}return f},rt=(t,e="-")=>D(t).trim().toLowerCase().replace(/\W+/g," ").replace(/\s+/g," ").replace(/\s/g,e);var k={dateStyle:"medium",timeStyle:"long"},j={second:1e3,minute:60,hour:60,day:24,week:7,month:4,year:12},nt=t=>{try{return new Intl.Locale(t).language!==""}catch{return!1}},ot=(...t)=>{let e=t[0],r=nt(t[1])?t[1]:"en",n=t.length>=3?t[2]:t.length===1?k:l(t[1])?t[1]:k;return new Intl.DateTimeFormat(r,n).format(new Date(e))},st=(t,e="en",r="just now")=>{let n=new Date(t),o=Date.now()-n;if(o<=j.second)return r;let s="second";for(let c in j){if(o<j[c])break;s=c,o/=j[c]}return o=Math.floor(o),new Intl.RelativeTimeFormat(e).format(-o,s)};var ct=t=>{let e=t.length,r=(n,o)=>n>0?(...s)=>r(n-s.length,[...o,...s]):t(...o);return r(e,[])};var it=(...t)=>t.reduce((e,r)=>n=>e(r(n)));var ut=(...t)=>t.reduce((e,r)=>n=>r(e(n)));var x=(t,e,r,n={})=>{let{writable:o=!1,configurable:s=!1,enumerable:i=!1}=n;Object.defineProperty(t,e,{value:r,writable:o,configurable:s,enumerable:i})};var b=t=>{let e=t,r=()=>e==null,n=()=>e,o=f=>b(e||f()),s=f=>b(f(e)===!0?e:null),i=f=>b(r()?null:f(e)),c=Object.create({});return x(c,"__value__",e,{enumerable:!0}),x(c,"__type__","Maybe",{enumerable:!0}),x(c,"isNil",r),x(c,"value",n),x(c,"map",i),x(c,"if",s),x(c,"else",o),c};var M=(t,e=null)=>{let r=e||new Set;if(r.has(t))return t;if(r.add(t),h(t))return new Date(t.valueOf());let n=s=>{let i=Object.create({});for(let c in s)a(s,c)&&(i[c]=M(s[c],r));return i},o=s=>[...s].map(i=>u(i)?o(i):l(i)?n(i):M(i,r));return u(t)?o(t):l(t)?n(t):t},I=(t,e,r=!1,n=[])=>{for(let o in t)if(!(n.length>0&&n.includes(o))&&(!r||r&&a(e,o))){let s=t[o],i=e[o];l(i)&&l(s)||u(i)&&u(s)?e[o]=I(s,e[o],r,n):e[o]=M(s)}return e},lt=(t=[])=>[...new Set(t)],pt=(t,e)=>t>e?1:t<e?-1:0,L=(t=[],e=null)=>{let r=[...t],n=e||pt;return r.sort(n),r},ft=(t=[],e=1,r="")=>!p(r)||!a(t[0],r)?t:L(t,(n,o)=>n[r]>o[r]?e:n[r]<o[r]?-1*e:0),P=(t=[])=>{let e=[...t],r=[],n=e.length;for(;n>0;){let o=Math.floor(Math.random()*n);r.push(e.splice(o,1)[0]),n--}return r},at=(t=[],e=1)=>{let r=P(t),n=Math.max(1,e),o=Math.min(n,r.length-1);return r.splice(0,o)};module.exports=H(gt);0&&(module.exports={clone,compose,copies,curry,equals,escapeHTML,formatDateString,formatTimeAgo,genid,hasProperty,isArray,isBoolean,isDate,isElement,isEmail,isEmpty,isFunction,isInteger,isLetter,isNil,isNull,isNumber,isObject,isString,isUndefined,maybe,pick,pipe,randint,replaceAll,shuffle,slugify,sort,sortBy,stripAccent,stripTags,truncate,ucfirst,ucwords,unescapeHTML,unique});
{
"name": "bellajs-cjs",
"version": "11.0.0rc1",
"version": "11.0.0rc2",
"main": "./bella.js"
}
{
"version": "11.0.0rc1",
"version": "11.0.0rc2",
"name": "bellajs",

@@ -11,3 +11,3 @@ "description": "A useful helper for any javascript program",

"author": "@ndaidong",
"main": "./dist/bella.js",
"main": "./dist/cjs/bella.js",
"module": "./src/main.js",

@@ -14,0 +14,0 @@ "browser": "./dist/bella.min.js",

@@ -19,23 +19,8 @@ BellaJS

* [DataType detection](#datatype-detection)
* [Date format](#date-format)
* [String manipulation](#string-manipulation)
* [Data handling](#data-handling)
* [clone](#clone)
* [copies](#copies)
* [Array utils](#array-utils)
* [pick](#pick)
* [sort](#sort)
* [sortBy](#sortBy)
* [shuffle](#shuffle)
* [unique](#unique)
* [Functional utils](#functional-utils)
* [curry](#curryfn)
* [compose](#compose)
* [pipe](#pipe)
* [maybe](#maybe)
* [Other utils](#other-utils)
* [equals](#equals)
* [randint](#randint)
* [genid](#genid)
* [md5](#md5)
* [Data handling](#data-handling): [clone](#clone), [copies](#copies)
* [Array utils](#array-utils): [pick](#pick), [sort](#sort), [sortBy](#sortBy), [shuffle](#shuffle), [unique](#unique)
* [Functional utils](#functional-utils): [curry](#curryfn), [compose](#compose), [pipe](#pipe), [maybe](#maybe)
* [Date utils](#date-utils)
* [Other utils](#other-utils): [equals](#equals), [randint](#randint), [genid](#genid)

@@ -129,57 +114,3 @@ * [Test](#test)

### Date format
- `toRelativeTime([Date | Timestamp])`
- `toDateString([Date | Timestamp] [, String pattern])`
- `toLocalDateString([Date | Timestamp])`
- `toUTCDateString([Date | Timestamp])`
Default pattern for `toDateString()` method is `D, M d, Y H:i:s A`.
Pattern for `toLocalDateString()` and `toUTCDateString()` is `D, j M Y h:i:s O`.
Here are the available characters:
```
- Y: full year, ex: 2050
- y: short year, ex: 50
- F: full month name, ex: August
- M: short month name, ex: Aug
- m: month index with zero, ex: 08 (in 08/24/2050)
- n: short month name with no zero, ex: 8 (in 8/24/2050)
- S: the ordering subfix for date, ext: 1st, 2nd, 3rd, 4th
- j: day of the month, with no zero, ex: 3 (in 18/3/2050)
- d: day of the month, with zero, ex: 03 (in 18/03/2050)
- t: date in year
- w: weekday in number
- l: long name of weekday, ex: Sunday
- D: short name of weekday, ex: Sun
- G: hour, with no zero: 0 - 24
- g: hour, with no zero: 0 - 12
- h: hour, with zero: 00 - 24
- i: minute: 00 - 59
- s: second: 00 - 59
- a: am, pm
- A: AM, PM
- O: timezone
```
Example:
```js
import {
toRelativeTime,
toDateString,
toLocalDateString,
toUTCDateString
} from 'bellajs'
const t = 1509628030108
toRelativeTime(t) // => 2 seconds ago
toDateString(t, 'Y/m/d h:i:s') // => 2017/11/02 20:07:10
toLocalDateString(t) // => Thu, 2 Nov 2017 20:07:10 GMT+0007
toUTCDateString(t) // => Thu, 2 Nov 2017 13:07:10 GMT+0000
```
### String manipulation

@@ -565,2 +496,74 @@

### Date utils
- `formatDateString(Date | Timestamp [, String locale [, Object options]])`
- `formatTimeAgo(Date | Timestamp [, String locale [, String justnow]])`
Example:
```js
import {
formatDateString,
formatTimeAgo
} from 'bellajs'
const today = new Date()
formatDateString(today) // => Jan 3, 2022, 8:34:28 PM GMT+7
// custom format
formatDateString(today, {
dateStyle: 'short',
timeStyle: 'short',
hour12: true
}) // => 1/3/22, 8:34 PM
// custom locale
formatDateString(today, 'zh') // => 2022年1月3日 GMT+7 下午8:34:28
// custom lang and format
formatDateString(today, 'zh', {
dateStyle: 'short',
timeStyle: 'long',
hour12: true
}) // => 2022/1/3 GMT+7 下午8:34:28
formatDateString(today, 'vi') // => 20:34:28 GMT+7, 3 thg 1, 2022
formatDateString(today, 'vi', {
dateStyle: 'full',
timeStyle: 'full'
}) // => 20:34:28 Giờ Đông Dương Thứ Hai, 3 tháng 1, 2022
const yesterday = today.setDate(today.getDate() - 1)
formatTimeAgo(yesterday) // => 1 day ago
const current = new Date()
const aLittleWhile = current.setHours(current.getHours() - 3)
formatTimeAgo(aLittleWhile) // => 3 hours ago
// change locale
formatTimeAgo(aLittleWhile, 'zh') // => 3小时前
formatTimeAgo(aLittleWhile, 'vi') // => 3 giờ trước
```
The last param `justnow` can be used to display a custom 'just now' message, when the distance is lesser than 1s.
```js
const now = new Date()
const aJiff = now.setTime(now.getTime() - 100)
formatTimeAgo(aJiff) // => 'just now'
console.log(formatTimeAgo(aJiff, 'fr', 'à l\'instant')) // => à l'instant
console.log(formatTimeAgo(aJiff, 'ja', 'すこし前')) // => すこし前
```
These two functions based on recent features of built-in object `Intl`.
Please refer the following resources for more info:
- [Intl.DateTimeFormat() constructor](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat/DateTimeFormat)
- [Intl.RelativeTimeFormat](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/RelativeTimeFormat)
- [Intl.Locale](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale)
### Other utils

@@ -615,18 +618,2 @@

#### md5
```js
md5(String s)
```
For example:
```js
import { md5 } from 'bellajs'
md5('abc') // => 900150983cd24fb0d6963f7d28e17f72
```
## Test

@@ -633,0 +620,0 @@

@@ -125,3 +125,2 @@ /**

export * from './utils/date'
export * from './utils/md5'

@@ -128,0 +127,0 @@ export * from './utils/curry'

// utils / date
import {
isDate
isObject
} from './detection'
const PATTERN = 'D, M d, Y h:i:s A'
const WEEKDAYS = [
'Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'
]
const MONTHS = [
'January', 'February', 'March', 'April',
'May', 'June', 'July', 'August',
'September', 'October', 'November', 'December'
]
export const now = () => {
return new Date()
const DATE_FORMAT = {
dateStyle: 'medium',
timeStyle: 'long'
}
export const time = () => {
return Date.now()
const TIME_CONVERS = {
second: 1000,
minute: 60,
hour: 60,
day: 24,
week: 7,
month: 4,
year: 12
}
const tzone = now().getTimezoneOffset()
const tz = (() => {
const z = Math.abs(tzone / 60)
const sign = tzone < 0 ? '+' : '-'
return ['GMT', sign, String(z).padStart(4, '0')].join('')
})()
const _num = (n) => {
return String(n < 10 ? '0' + n : n)
}
const _ord = (day) => {
let s = day + ' '
const x = s.charAt(s.length - 2)
if (x === '1') {
s = 'st'
} else if (x === '2') {
s = 'nd'
} else if (x === '3') {
s = 'rd'
} else {
s = 'th'
const isValidLocal = (hl) => {
try {
const locale = new Intl.Locale(hl)
return locale.language !== ''
} catch (err) {
return false
}
return s
}
export const toDateString = (input, output = PATTERN) => {
const d = isDate(input) ? input : new Date(input)
if (!isDate(d)) {
throw new Error('InvalidInput: Number or Date required.')
}
const vchar = /\.*\\?([a-z])/gi
const meridiem = output.includes('a') || output.includes('A')
const wn = WEEKDAYS
const mn = MONTHS
const f = {
Y () {
return d.getFullYear() // 2015
},
y () {
return (f.Y() + '').slice(-2) // 15
},
F () {
return mn[f.n() - 1] // August
},
M () {
return (f.F() + '').slice(0, 3) // Aug
},
m () {
return _num(f.n()) // 08
},
n () {
return d.getMonth() + 1 // 8
},
S () {
return _ord(f.j()) // st, nd, rd, th
},
j () {
return d.getDate() // 3
},
d () {
return _num(f.j()) // 03
},
t () {
return new Date(f.Y(), f.n(), 0).getDate() // date in year
},
w () {
return d.getDay() // weekday in number
},
l () {
return wn[f.w()] // Sunday, Monday
},
D () {
return (f.l() + '').slice(0, 3) // Sun, Mon
},
G () {
return d.getHours() // 0 - 24
},
g () {
return f.G() % 12 || 12 // 0 - 12
},
h () {
return _num(meridiem ? f.g() : f.G()) // 00 - 12 or 00 - 24
},
i () {
return _num(d.getMinutes()) // 00 - 59
},
s () {
return _num(d.getSeconds()) // 00 - 59
},
a () {
return f.G() > 11 ? 'pm' : 'am' // am, pm
},
A () {
return f.a().toUpperCase() // AM, PM
},
O () {
return tz
}
}
/* eslint-enable */
const _term = (t, s) => {
return f[t] ? f[t]() : s
}
return output.replace(vchar, _term)
export const formatDateString = (...args) => {
const input = args[0]
const lang = isValidLocal(args[1]) ? args[1] : 'en'
const opt = args.length >= 3
? args[2]
: args.length === 1
? DATE_FORMAT
: isObject(args[1])
? args[1]
: DATE_FORMAT
const dtf = new Intl.DateTimeFormat(lang, opt)
return dtf.format(new Date(input))
}
export const toRelativeTime = (input = time()) => {
const d = isDate(input) ? input : new Date(input)
if (!isDate(d)) {
throw new Error('InvalidInput: Number or Date required.')
export const formatTimeAgo = (input, lang = 'en', justnow = 'just now') => {
const t = new Date(input)
let delta = Date.now() - t
if (delta <= TIME_CONVERS.second) {
return justnow
}
let delta = now() - d
let nowThreshold = parseInt(d, 10)
if (isNaN(nowThreshold)) {
nowThreshold = 0
}
if (delta <= nowThreshold) {
return 'Just now'
}
let units = null
const conversions = {
millisecond: 1,
second: 1000,
minute: 60,
hour: 60,
day: 24,
month: 30,
year: 12
}
for (const key in conversions) {
if (delta < conversions[key]) {
let unit = 'second'
for (const key in TIME_CONVERS) {
if (delta < TIME_CONVERS[key]) {
break
} else {
units = key
delta /= conversions[key]
unit = key
delta /= TIME_CONVERS[key]
}
}
delta = Math.floor(delta)
if (delta !== 1) {
units += 's'
}
return [delta, units].join(' ') + ' ago'
const rel = new Intl.RelativeTimeFormat(lang)
return rel.format(-delta, unit)
}
export const toUTCDateString = (input = time()) => {
const d = isDate(input) ? input : new Date(input)
if (!isDate(d)) {
throw new Error('InvalidInput: Number or Date required.')
}
const dMinutes = d.getMinutes()
const dClone = new Date(d)
dClone.setMinutes(dMinutes + tzone)
return `${toDateString(dClone, 'D, j M Y h:i:s')} GMT+0000`
}
export const toLocalDateString = (input = time()) => {
const d = isDate(input) ? input : new Date(input)
if (!isDate(d)) {
throw new Error('InvalidInput: Number or Date required.')
}
return toDateString(d, 'D, j M Y h:i:s O')
}

@@ -6,119 +6,52 @@ // date.test

import {
isInteger
} from './detection'
import {
now,
time,
toDateString,
toLocalDateString,
toUTCDateString,
toRelativeTime
formatDateString,
formatTimeAgo
} from './date'
describe('test .now() method:', () => {
test(' check if .now() returns Date instance', () => {
const d = now()
expect(d).toBeInstanceOf(Date)
})
})
describe('test .formatDateString() method', () => {
const d = new Date()
describe('test .time() method:', () => {
test(' check if .time() returns integer', () => {
const t = time()
expect(isInteger(t)).toBeTruthy()
test(' check .formatDateString() with default options', () => {
const result = formatDateString(d)
const reg = /^\w+\s\d+,\s+\d{4},\s\d+:\d+:\d+\s(AM|PM)\s(GMT)\+\d+$/
expect(result.match(reg) !== null).toBeTruthy()
})
})
describe('test .toDateString() method:', () => {
const atime = 1455784100752
const samples = [
{ ouput: 'Y/m/d h:i:s', expectation: '2016/02/18 15:28:20' },
{ ouput: 'Y/m/d h:i:s A', expectation: '2016/02/18 03:28:20 PM' },
{ ouput: 'M j, Y h:i:s A', expectation: 'Feb 18, 2016 03:28:20 PM' },
{ ouput: 'l, j F Y h:i:s a', expectation: 'Thursday, 18 February 2016 03:28:20 pm' },
{ ouput: 'w D G O', expectation: '4 Thu 15 GMT+0007' },
{ ouput: 'm/d/y', expectation: '02/18/16' },
{ ouput: 'm/d/y t', expectation: '02/18/16 29' },
{ ouput: 'M jS, Y', expectation: 'Feb 18th, 2016' },
{
ouput: 'M jS, Y',
expectation: 'Feb 21st, 2016',
input: atime + 3 * 24 * 60 * 6e4
},
{
ouput: 'M jS, Y',
expectation: 'Feb 22nd, 2016',
input: atime + 4 * 24 * 60 * 6e4
},
{
ouput: 'M jS, Y',
expectation: 'Feb 23rd, 2016',
input: atime + 5 * 24 * 60 * 6e4
}
]
samples.forEach((sample, k) => {
const { input = atime, ouput, expectation } = sample
test(` check .toDateString(${atime}, ${k}) with regular params`, () => {
const result = toDateString(input, ouput)
expect(result === expectation).toBeTruthy()
test(' check .formatDateString() with custom options', () => {
const result = formatDateString(d, {
dateStyle: 'full',
timeStyle: 'medium',
hour12: true
})
const reg = /^\w+,\s\w+\s\d+,\s+\d{4}\sat\s\d+:\d+:\d+\s(AM|PM)$/
expect(result.match(reg) !== null).toBeTruthy()
})
test(' check .toDateString(invalid date)', () => {
expect(() => {
toDateString({})
}).toThrowError('InvalidInput')
expect(() => {
toDateString('ab')
}).toThrowError('InvalidInput')
test(' check .formatDateString() with custom language and options', () => {
const result = formatDateString(d, 'en', {
dateStyle: 'full',
timeStyle: 'medium',
hour12: true
})
const reg = /^\w+,\s\w+\s\d+,\s+\d{4}\sat\s\d+:\d+:\d+\s(AM|PM)$/
expect(result.match(reg) !== null).toBeTruthy()
})
})
describe('test .toLocalDateString() method:', () => {
test(' check if .toLocalDateString() returns correct date string', () => {
const t = 1455784100000
const d = toLocalDateString(t)
const e = 'Thu, 18 Feb 2016 15:28:20 GMT+0007'
expect(d === e).toBeTruthy()
})
test(' check .toUTCDateString(invalid date)', () => {
expect(() => {
toLocalDateString({})
}).toThrowError('InvalidInput')
})
})
describe('test .toUTCDateString() method:', () => {
test(' check if .toUTCDateString() returns correct date string', () => {
const t = 1455784100752
const d = toUTCDateString(t)
const e = 'Thu, 18 Feb 2016 08:28:20 GMT+0000'
expect(d === e).toBeTruthy()
})
test(' check .toUTCDateString(invalid date)', () => {
expect(() => {
toUTCDateString({})
}).toThrowError('InvalidInput')
})
})
describe('test .toRelativeTime() method:', () => {
describe('test .formatTimeAgo() method:', () => {
jest.useFakeTimers()
jest.spyOn(global, 'setTimeout')
const t = time()
const d = new Date()
test(' check if .toRelativeTime(t) return "Just now"', () => {
const result = toRelativeTime(t)
expect(result === 'Just now').toBeTruthy()
test(' check if .formatTimeAgo() return "just now"', () => {
const result = formatTimeAgo(d)
expect(result === 'just now').toBeTruthy()
const justnowCustomMessage = formatTimeAgo(d, 'vi', 'vừa mới xong')
expect(justnowCustomMessage === 'vừa mới xong').toBeTruthy()
})
test(' check .toRelativeTime(t) after 5s', () => {
test(' check .formatTimeAgo() after 5s', () => {
setTimeout(() => {
const result = toRelativeTime(t)
const result = formatTimeAgo(d)
expect(result === '5 seconds ago').toBeTruthy()

@@ -128,32 +61,2 @@ }, 5000)

})
test(' check .toRelativeTime(t) after 5m', () => {
setTimeout(() => {
const result = toRelativeTime(t)
expect(result === '5 minutes ago').toBeTruthy()
}, 6e4 * 5)
jest.advanceTimersByTime(6e4 * 5)
})
test(' check .toRelativeTime(t) after 5h', () => {
setTimeout(() => {
const result = toRelativeTime(t)
expect(result === '5 hours ago').toBeTruthy()
}, 6e4 * 60 * 5)
jest.advanceTimersByTime(6e4 * 60 * 5)
})
test(' check .toRelativeTime(t) after 5d', () => {
setTimeout(() => {
const result = toRelativeTime(t)
expect(result === '5 days ago').toBeTruthy()
}, 6e4 * 60 * 24 * 5)
jest.advanceTimersByTime(6e4 * 60 * 24 * 5)
})
test(' check .toRelativeTime(invalid date)', () => {
expect(() => {
toRelativeTime({})
}).toThrowError('InvalidInput')
})
})
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc