Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v11.1.1 #130

Merged
merged 1 commit into from
Oct 12, 2022
Merged

v11.1.1 #130

merged 1 commit into from
Oct 12, 2022

Conversation

ndaidong
Copy link
Owner

  • Remove crypto dependent parts
    • remove sha256, sha512 from v11.1.0
    • use regular method for randoming string/id
  • Keep support node 14 as before

- Remove crypto dependent parts
  - remove sha256, sha512 from v11.1.0
  - use regular method for randoming string/id
- Keep support node 14 as before
@coveralls
Copy link

coveralls commented Oct 12, 2022

Coverage Status

Coverage remained the same at 100.0% when pulling fbc3717 on 11.1.1 into 60eebba on main.

// bellajs@11.1.0 https://github.com/ndaidong/bellajs - built with esbuild at 2022-10-12T09:56:19.003Z
var g=t=>({}).toString.call(t),z=t=>Number.isInteger(t),p=t=>Array.isArray(t),a=t=>String(t)===t,h=t=>Number(t)===t,B=t=>Boolean(t)===t,E=t=>g(t)==="[object Null]",D=t=>g(t)==="[object Undefined]",N=t=>D(t)||E(t),R=t=>g(t)==="[object Function]",l=t=>g(t)==="[object Object]"&&!p(t),A=t=>t instanceof Date&&!isNaN(t.valueOf()),V=t=>g(t).match(/^\[object HTML\w*Element]$/)!==null,G=t=>{let e=/^[a-z]+$/i;return a(t)&&e.test(t)},K=t=>{let e=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;return a(t)&&e.test(t)},W=t=>!t||N(t)||a(t)&&t===""||p(t)&&t.length===0||l(t)&&Object.keys(t).length===0,x=(t,e)=>!t||!e?!1:Object.prototype.hasOwnProperty.call(t,e);var f=t=>{let e=h(t)?String(t):t;if(!a(e))throw new Error("InvalidInput: String required.");return e},X=(t,e=140)=>{let r=f(t);if(r.length<=e)return r;let n=r.substring(0,e).trim(),s=n.split(" ");return s.length>1?(s.pop(),s.map(i=>i.trim()).join(" ")+"..."):n.substring(0,e-3)+"..."},Y=t=>f(t).replace(/(<([^>]+)>)/ig,"").trim(),Z=t=>f(t).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;"),v=t=>f(t).replace(/&quot;/g,'"').replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&amp;/g,"&"),U=t=>{let e=f(t).toLowerCase();return e.length>1?e.charAt(0).toUpperCase()+e.slice(1):e.toUpperCase()},tt=t=>f(t).split(" ").map(e=>U(e)).join(" "),y=(t,e,r)=>{let o=f(t),n=h(e)?String(e):e,s=h(r)?String(r):r;if(a(n)&&a(s))o=o.split(n).join(s);else if(p(n)&&a(s))n.forEach(c=>{o=y(o,c,s)});else if(p(n)&&p(s)&&n.length===s.length){let c=n.length;if(c>0)for(let i=0;i<c;i++){let u=n[i],T=s[i];o=y(o,u,T)}}return o},C=()=>{let t={a:"á|à|ả|ã|ạ|ă|ắ|ặ|ằ|ẳ|ẵ|â|ấ|ầ|ẩ|ẫ|ậ|ä|æ",c:"ç",d:"đ|ð",e:"é|è|ẻ|ẽ|ẹ|ê|ế|ề|ể|ễ|ệ|ë",i:"í|ì|ỉ|ĩ|ị|ï|î",n:"ñ",o:"ó|ò|ỏ|õ|ọ|ô|ố|ồ|ổ|ỗ|ộ|ơ|ớ|ờ|ở|ỡ|ợ|ö|ø",s:"ß",u:"ú|ù|ủ|ũ|ụ|ư|ứ|ừ|ử|ữ|ự|û",y:"ý|ỳ|ỷ|ỹ|ỵ|ÿ"},e={...t};return Object.keys(t).forEach(r=>{let o=r.toUpperCase();e[o]=t[r].toUpperCase()}),e},L=t=>{let e=f(t),r=(n,s)=>{e=y(e,n,s)},o=C();for(let n in o)x(o,n)&&o[n].split("|").forEach(c=>r(c,n));return e},et=(t,e="-")=>L(t).trim().toLowerCase().replace(/\W+/g," ").replace(/\s+/g," ").replace(/\s/g,e);var b=crypto;var w=window.TextEncoder,ot=window.TextDecoder;var d=b.webcrypto?b.webcrypto:b,it=(t=0,e=1e6)=>{let r=new Uint8Array(1);d.getRandomValues(r);let o="0."+r[0].toString();return Math.floor(o*(e-t+1))+t},_=(t=32,e="")=>{let r=e;for(let o=0;o<t;o++){let n=Math.random(),s=Math.floor(n*36),c=s.toString(36);r+=s>9&&n>.3&&n<.7?c.toUpperCase():c}return r.substring(0,t)},M=(t=32,e="")=>{let r=e,o=d.getRandomValues(new Uint16Array(t));for(let n=0;n<o.length;n++){let s=o[n].toString(36),c=Math.random(),i=s.charAt(Math.floor(c*s.length));r+=c>.3&&c<.7?i.toUpperCase():i}return r.substring(0,t)},ut=(t=32,e="")=>t<=128?M(t,e):`${M(99,e)}${_(t-99)}`;var O=async(t,e)=>{let r=new w().encode(t),o=await d.subtle.digest(e,r);return[...new Uint8Array(o)].map(s=>s.toString(16).padStart(2,"0")).join("")},ft=async(t="")=>await O(t,"SHA-256"),mt=async(t="")=>await O(t,"SHA-512");var I=()=>({dateStyle:"medium",timeStyle:"long"}),P=()=>({second:1e3,minute:60,hour:60,day:24,week:7,month:4,year:12}),k=t=>{try{return new Intl.Locale(t).language!==""}catch{return!1}},ht=(...t)=>{let e=t[0],r=k(t[1])?t[1]:"en",o=I(),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))},bt=(t,e="en",r="just now")=>{let o=new Date(t),n=Date.now()-o,s=P();if(n<=s.second)return r;let c="second";for(let u in s){if(n<s[u])break;c=u,n/=s[u]}return n=Math.floor(n),new Intl.RelativeTimeFormat(e).format(-n,c)};var yt=t=>{let e=t.length,r=(o,n)=>o>0?(...s)=>r(o-s.length,[...n,...s]):t(...n);return r(e,[])};var St=(...t)=>t.reduce((e,r)=>o=>e(r(o)));var At=(...t)=>t.reduce((e,r)=>o=>r(e(o)));var m=(t,e,r,o={})=>{let{writable:n=!1,configurable:s=!1,enumerable:c=!1}=o;Object.defineProperty(t,e,{value:r,writable:n,configurable:s,enumerable:c})};var S=t=>{let e=t,r=()=>e==null,o=()=>e,n=u=>S(e||u()),s=u=>S(u(e)===!0?e:null),c=u=>S(r()?null:u(e)),i=Object.create({});return m(i,"__value__",e,{enumerable:!0}),m(i,"__type__","Maybe",{enumerable:!0}),m(i,"isNil",r),m(i,"value",o),m(i,"map",c),m(i,"if",s),m(i,"else",n),i};var j=(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 o=s=>{let c=Object.create({});for(let i in s)x(s,i)&&(c[i]=j(s[i],r));return c},n=s=>[...s].map(c=>p(c)?n(c):l(c)?o(c):j(c,r));return p(t)?n(t):l(t)?o(t):t},F=(t,e,r=!1,o=[])=>{for(let n in t)if(!(o.length>0&&o.includes(n))&&(!r||r&&x(e,n))){let s=t[n],c=e[n];l(c)&&l(s)||p(c)&&p(s)?e[n]=F(s,e[n],r,o):e[n]=j(s)}return e},Nt=(t=[])=>[...new Set(t)],H=(t,e)=>t>e?1:t<e?-1:0,$=(t=[],e=null)=>{let r=[...t],o=e||H;return r.sort(o),r},Ut=(t=[],e=1,r="")=>!a(r)||!x(t[0],r)?t:$(t,(o,n)=>o[r]>n[r]?e:o[r]<n[r]?-1*e:0),q=(t=[])=>{let e=[...t],r=[],o=e.length;for(;o>0;){let n=Math.floor(Math.random()*o);r.push(e.splice(n,1)[0]),o--}return r},Ct=(t=[],e=1)=>{let r=q(t),o=Math.max(1,e),n=Math.min(o,r.length-1);return r.splice(0,n)};export{w as TextEncoder,j as clone,St as compose,F as copies,d as crypto,yt as curry,Z as escapeHTML,ht as formatDateString,bt as formatTimeAgo,ut as genid,x as hasProperty,p as isArray,B as isBoolean,A as isDate,V as isElement,K as isEmail,W as isEmpty,R as isFunction,z as isInteger,G as isLetter,N as isNil,E as isNull,h as isNumber,l as isObject,a as isString,D as isUndefined,S as maybe,Ct as pick,At as pipe,it as randint,y as replaceAll,ft as sha256,mt as sha512,q as shuffle,et as slugify,$ as sort,Ut as sortBy,L as stripAccent,Y as stripTags,X as truncate,U as ucfirst,tt as ucwords,v as unescapeHTML,Nt as unique};
// bellajs@11.1.1 https://github.com/ndaidong/bellajs - built with esbuild at 2022-10-12T10:45:38.055Z
var g=t=>({}).toString.call(t),U=t=>Number.isInteger(t),p=t=>Array.isArray(t),l=t=>String(t)===t,h=t=>Number(t)===t,k=t=>Boolean(t)===t,S=t=>g(t)==="[object Null]",M=t=>g(t)==="[object Undefined]",O=t=>M(t)||S(t),F=t=>g(t)==="[object Function]",a=t=>g(t)==="[object Object]"&&!p(t),w=t=>t instanceof Date&&!isNaN(t.valueOf()),q=t=>g(t).match(/^\[object HTML\w*Element]$/)!==null,z=t=>{let e=/^[a-z]+$/i;return l(t)&&e.test(t)},B=t=>{let e=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;return l(t)&&e.test(t)},H=t=>!t||O(t)||l(t)&&t===""||p(t)&&t.length===0||a(t)&&Object.keys(t).length===0,x=(t,e)=>!t||!e?!1:Object.prototype.hasOwnProperty.call(t,e);var f=t=>{let e=h(t)?String(t):t;if(!l(e))throw new Error("InvalidInput: String required.");return e},R=(t,e=140)=>{let r=f(t);if(r.length<=e)return r;let n=r.substring(0,e).trim(),s=n.split(" ");return s.length>1?(s.pop(),s.map(i=>i.trim()).join(" ")+"..."):n.substring(0,e-3)+"..."},V=t=>f(t).replace(/(<([^>]+)>)/ig,"").trim(),W=t=>f(t).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;"),G=t=>f(t).replace(/&quot;/g,'"').replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&amp;/g,"&"),A=t=>{let e=f(t).toLowerCase();return e.length>1?e.charAt(0).toUpperCase()+e.slice(1):e.toUpperCase()},J=t=>f(t).split(" ").map(e=>A(e)).join(" "),b=(t,e,r)=>{let o=f(t),n=h(e)?String(e):e,s=h(r)?String(r):r;if(l(n)&&l(s))o=o.split(n).join(s);else if(p(n)&&l(s))n.forEach(c=>{o=b(o,c,s)});else if(p(n)&&p(s)&&n.length===s.length){let c=n.length;if(c>0)for(let i=0;i<c;i++){let u=n[i],j=s[i];o=b(o,u,j)}}return o},N=()=>{let t={a:"á|à|ả|ã|ạ|ă|ắ|ặ|ằ|ẳ|ẵ|â|ấ|ầ|ẩ|ẫ|ậ|ä|æ",c:"ç",d:"đ|ð",e:"é|è|ẻ|ẽ|ẹ|ê|ế|ề|ể|ễ|ệ|ë",i:"í|ì|ỉ|ĩ|ị|ï|î",n:"ñ",o:"ó|ò|ỏ|õ|ọ|ô|ố|ồ|ổ|ỗ|ộ|ơ|ớ|ờ|ở|ỡ|ợ|ö|ø",s:"ß",u:"ú|ù|ủ|ũ|ụ|ư|ứ|ừ|ử|ữ|ự|û",y:"ý|ỳ|ỷ|ỹ|ỵ|ÿ"},e={...t};return Object.keys(t).forEach(r=>{let o=r.toUpperCase();e[o]=t[r].toUpperCase()}),e},D=t=>{let e=f(t),r=(n,s)=>{e=b(e,n,s)},o=N();for(let n in o)x(o,n)&&o[n].split("|").forEach(c=>r(c,n));return e},Q=(t,e="-")=>D(t).trim().toLowerCase().replace(/\W+/g," ").replace(/\s+/g," ").replace(/\s/g,e);var Y=(t=0,e=1e6)=>Math.floor(Math.random()*(e-t+1))+t,Z=(t=32,e="")=>{let r=e;for(let o=0;o<t;o++){let n=Math.random(),s=Math.floor(n*36),c=s.toString(36);r+=s>9&&n>.3&&n<.7?c.toUpperCase():c}return r.substring(0,t)};var L=()=>({dateStyle:"medium",timeStyle:"long"}),_=()=>({second:1e3,minute:60,hour:60,day:24,week:7,month:4,year:12}),C=t=>{try{return new Intl.Locale(t).language!==""}catch{return!1}},et=(...t)=>{let e=t[0],r=C(t[1])?t[1]:"en",o=L(),n=t.length>=3?t[2]:t.length===1?o:a(t[1])?t[1]:o;return new Intl.DateTimeFormat(r,n).format(new Date(e))},rt=(t,e="en",r="just now")=>{let o=new Date(t),n=Date.now()-o,s=_();if(n<=s.second)return r;let c="second";for(let u in s){if(n<s[u])break;c=u,n/=s[u]}return n=Math.floor(n),new Intl.RelativeTimeFormat(e).format(-n,c)};var ot=t=>{let e=t.length,r=(o,n)=>o>0?(...s)=>r(o-s.length,[...n,...s]):t(...n);return r(e,[])};var ct=(...t)=>t.reduce((e,r)=>o=>e(r(o)));var ut=(...t)=>t.reduce((e,r)=>o=>r(e(o)));var m=(t,e,r,o={})=>{let{writable:n=!1,configurable:s=!1,enumerable:c=!1}=o;Object.defineProperty(t,e,{value:r,writable:n,configurable:s,enumerable:c})};var d=t=>{let e=t,r=()=>e==null,o=()=>e,n=u=>d(e||u()),s=u=>d(u(e)===!0?e:null),c=u=>d(r()?null:u(e)),i=Object.create({});return m(i,"__value__",e,{enumerable:!0}),m(i,"__type__","Maybe",{enumerable:!0}),m(i,"isNil",r),m(i,"value",o),m(i,"map",c),m(i,"if",s),m(i,"else",n),i};var y=(t,e=null)=>{let r=e||new Set;if(r.has(t))return t;if(r.add(t),w(t))return new Date(t.valueOf());let o=s=>{let c=Object.create({});for(let i in s)x(s,i)&&(c[i]=y(s[i],r));return c},n=s=>[...s].map(c=>p(c)?n(c):a(c)?o(c):y(c,r));return p(t)?n(t):a(t)?o(t):t},E=(t,e,r=!1,o=[])=>{for(let n in t)if(!(o.length>0&&o.includes(n))&&(!r||r&&x(e,n))){let s=t[n],c=e[n];a(c)&&a(s)||p(c)&&p(s)?e[n]=E(s,e[n],r,o):e[n]=y(s)}return e},xt=(t=[])=>[...new Set(t)],T=(t,e)=>t>e?1:t<e?-1:0,I=(t=[],e=null)=>{let r=[...t],o=e||T;return r.sort(o),r},gt=(t=[],e=1,r="")=>!l(r)||!x(t[0],r)?t:I(t,(o,n)=>o[r]>n[r]?e:o[r]<n[r]?-1*e:0),P=(t=[])=>{let e=[...t],r=[],o=e.length;for(;o>0;){let n=Math.floor(Math.random()*o);r.push(e.splice(n,1)[0]),o--}return r},ht=(t=[],e=1)=>{let r=P(t),o=Math.max(1,e),n=Math.min(o,r.length-1);return r.splice(0,n)};export{y as clone,ct as compose,E as copies,ot as curry,W as escapeHTML,et as formatDateString,rt as formatTimeAgo,Z as genid,x as hasProperty,p as isArray,k as isBoolean,w as isDate,q as isElement,B as isEmail,H as isEmpty,F as isFunction,U as isInteger,z as isLetter,O as isNil,S as isNull,h as isNumber,a as isObject,l as isString,M as isUndefined,d as maybe,ht as pick,ut as pipe,Y as randint,b as replaceAll,P as shuffle,Q as slugify,I as sort,gt as sortBy,D as stripAccent,V as stripTags,R as truncate,A as ucfirst,J as ucwords,G as unescapeHTML,xt as unique};

Check warning

Code scanning / CodeQL

Prototype-polluting function

Properties are copied from [t](1) to [e](2) without guarding against prototype pollution.
// bellajs@11.1.0 https://github.com/ndaidong/bellajs - built with esbuild at 2022-10-12T09:56:19.003Z
var F=Object.create;var y=Object.defineProperty;var H=Object.getOwnPropertyDescriptor;var $=Object.getOwnPropertyNames;var q=Object.getPrototypeOf,z=Object.prototype.hasOwnProperty;var B=(t,e)=>{for(var r in e)y(t,r,{get:e[r],enumerable:!0})},O=(t,e,r,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of $(e))!z.call(t,n)&&n!==r&&y(t,n,{get:()=>e[n],enumerable:!(o=H(e,n))||o.enumerable});return t};var R=(t,e,r)=>(r=t!=null?F(q(t)):{},O(e||!t||!t.__esModule?y(r,"default",{value:t,enumerable:!0}):r,t)),V=t=>O(y({},"__esModule",{value:!0}),t);var jt={};B(jt,{TextEncoder:()=>S.TextEncoder,clone:()=>A,compose:()=>ht,copies:()=>_,crypto:()=>b,curry:()=>gt,escapeHTML:()=>tt,formatDateString:()=>mt,formatTimeAgo:()=>xt,genid:()=>it,hasProperty:()=>x,isArray:()=>u,isBoolean:()=>K,isDate:()=>M,isElement:()=>J,isEmail:()=>X,isEmpty:()=>Y,isFunction:()=>W,isInteger:()=>G,isLetter:()=>Q,isNil:()=>U,isNull:()=>N,isNumber:()=>h,isObject:()=>l,isString:()=>a,isUndefined:()=>E,maybe:()=>j,pick:()=>St,pipe:()=>bt,randint:()=>st,replaceAll:()=>d,sha256:()=>ut,sha512:()=>pt,shuffle:()=>P,slugify:()=>ot,sort:()=>I,sortBy:()=>wt,stripAccent:()=>D,stripTags:()=>v,truncate:()=>Z,ucfirst:()=>C,ucwords:()=>rt,unescapeHTML:()=>et,unique:()=>yt});module.exports=V(jt);var g=t=>({}).toString.call(t),G=t=>Number.isInteger(t),u=t=>Array.isArray(t),a=t=>String(t)===t,h=t=>Number(t)===t,K=t=>Boolean(t)===t,N=t=>g(t)==="[object Null]",E=t=>g(t)==="[object Undefined]",U=t=>E(t)||N(t),W=t=>g(t)==="[object Function]",l=t=>g(t)==="[object Object]"&&!u(t),M=t=>t instanceof Date&&!isNaN(t.valueOf()),J=t=>g(t).match(/^\[object HTML\w*Element]$/)!==null,Q=t=>{let e=/^[a-z]+$/i;return a(t)&&e.test(t)},X=t=>{let e=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;return a(t)&&e.test(t)},Y=t=>!t||U(t)||a(t)&&t===""||u(t)&&t.length===0||l(t)&&Object.keys(t).length===0,x=(t,e)=>!t||!e?!1:Object.prototype.hasOwnProperty.call(t,e);var f=t=>{let e=h(t)?String(t):t;if(!a(e))throw new Error("InvalidInput: String required.");return e},Z=(t,e=140)=>{let r=f(t);if(r.length<=e)return r;let n=r.substring(0,e).trim(),s=n.split(" ");return s.length>1?(s.pop(),s.map(i=>i.trim()).join(" ")+"..."):n.substring(0,e-3)+"..."},v=t=>f(t).replace(/(<([^>]+)>)/ig,"").trim(),tt=t=>f(t).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;"),et=t=>f(t).replace(/&quot;/g,'"').replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&amp;/g,"&"),C=t=>{let e=f(t).toLowerCase();return e.length>1?e.charAt(0).toUpperCase()+e.slice(1):e.toUpperCase()},rt=t=>f(t).split(" ").map(e=>C(e)).join(" "),d=(t,e,r)=>{let o=f(t),n=h(e)?String(e):e,s=h(r)?String(r):r;if(a(n)&&a(s))o=o.split(n).join(s);else if(u(n)&&a(s))n.forEach(c=>{o=d(o,c,s)});else if(u(n)&&u(s)&&n.length===s.length){let c=n.length;if(c>0)for(let i=0;i<c;i++){let p=n[i],k=s[i];o=d(o,p,k)}}return o},nt=()=>{let t={a:"á|à|ả|ã|ạ|ă|ắ|ặ|ằ|ẳ|ẵ|â|ấ|ầ|ẩ|ẫ|ậ|ä|æ",c:"ç",d:"đ|ð",e:"é|è|ẻ|ẽ|ẹ|ê|ế|ề|ể|ễ|ệ|ë",i:"í|ì|ỉ|ĩ|ị|ï|î",n:"ñ",o:"ó|ò|ỏ|õ|ọ|ô|ố|ồ|ổ|ỗ|ộ|ơ|ớ|ờ|ở|ỡ|ợ|ö|ø",s:"ß",u:"ú|ù|ủ|ũ|ụ|ư|ứ|ừ|ử|ữ|ự|û",y:"ý|ỳ|ỷ|ỹ|ỵ|ÿ"},e={...t};return Object.keys(t).forEach(r=>{let o=r.toUpperCase();e[o]=t[r].toUpperCase()}),e},D=t=>{let e=f(t),r=(n,s)=>{e=d(e,n,s)},o=nt();for(let n in o)x(o,n)&&o[n].split("|").forEach(c=>r(c,n));return e},ot=(t,e="-")=>D(t).trim().toLowerCase().replace(/\W+/g," ").replace(/\s+/g," ").replace(/\s/g,e);var w=R(require("crypto"),1),S=require("util"),b=w.default.webcrypto?w.default.webcrypto:w.default,st=(t=0,e=1e6)=>{let r=new Uint8Array(1);b.getRandomValues(r);let o="0."+r[0].toString();return Math.floor(o*(e-t+1))+t},ct=(t=32,e="")=>{let r=e;for(let o=0;o<t;o++){let n=Math.random(),s=Math.floor(n*36),c=s.toString(36);r+=s>9&&n>.3&&n<.7?c.toUpperCase():c}return r.substring(0,t)},L=(t=32,e="")=>{let r=e,o=b.getRandomValues(new Uint16Array(t));for(let n=0;n<o.length;n++){let s=o[n].toString(36),c=Math.random(),i=s.charAt(Math.floor(c*s.length));r+=c>.3&&c<.7?i.toUpperCase():i}return r.substring(0,t)},it=(t=32,e="")=>t<=128?L(t,e):`${L(99,e)}${ct(t-99)}`;var T=async(t,e)=>{let r=new S.TextEncoder().encode(t),o=await b.subtle.digest(e,r);return[...new Uint8Array(o)].map(s=>s.toString(16).padStart(2,"0")).join("")},ut=async(t="")=>await T(t,"SHA-256"),pt=async(t="")=>await T(t,"SHA-512");var at=()=>({dateStyle:"medium",timeStyle:"long"}),lt=()=>({second:1e3,minute:60,hour:60,day:24,week:7,month:4,year:12}),ft=t=>{try{return new Intl.Locale(t).language!==""}catch{return!1}},mt=(...t)=>{let e=t[0],r=ft(t[1])?t[1]:"en",o=at(),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))},xt=(t,e="en",r="just now")=>{let o=new Date(t),n=Date.now()-o,s=lt();if(n<=s.second)return r;let c="second";for(let p in s){if(n<s[p])break;c=p,n/=s[p]}return n=Math.floor(n),new Intl.RelativeTimeFormat(e).format(-n,c)};var gt=t=>{let e=t.length,r=(o,n)=>o>0?(...s)=>r(o-s.length,[...n,...s]):t(...n);return r(e,[])};var ht=(...t)=>t.reduce((e,r)=>o=>e(r(o)));var bt=(...t)=>t.reduce((e,r)=>o=>r(e(o)));var m=(t,e,r,o={})=>{let{writable:n=!1,configurable:s=!1,enumerable:c=!1}=o;Object.defineProperty(t,e,{value:r,writable:n,configurable:s,enumerable:c})};var j=t=>{let e=t,r=()=>e==null,o=()=>e,n=p=>j(e||p()),s=p=>j(p(e)===!0?e:null),c=p=>j(r()?null:p(e)),i=Object.create({});return m(i,"__value__",e,{enumerable:!0}),m(i,"__type__","Maybe",{enumerable:!0}),m(i,"isNil",r),m(i,"value",o),m(i,"map",c),m(i,"if",s),m(i,"else",n),i};var A=(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 o=s=>{let c=Object.create({});for(let i in s)x(s,i)&&(c[i]=A(s[i],r));return c},n=s=>[...s].map(c=>u(c)?n(c):l(c)?o(c):A(c,r));return u(t)?n(t):l(t)?o(t):t},_=(t,e,r=!1,o=[])=>{for(let n in t)if(!(o.length>0&&o.includes(n))&&(!r||r&&x(e,n))){let s=t[n],c=e[n];l(c)&&l(s)||u(c)&&u(s)?e[n]=_(s,e[n],r,o):e[n]=A(s)}return e},yt=(t=[])=>[...new Set(t)],dt=(t,e)=>t>e?1:t<e?-1:0,I=(t=[],e=null)=>{let r=[...t],o=e||dt;return r.sort(o),r},wt=(t=[],e=1,r="")=>!a(r)||!x(t[0],r)?t:I(t,(o,n)=>o[r]>n[r]?e:o[r]<n[r]?-1*e:0),P=(t=[])=>{let e=[...t],r=[],o=e.length;for(;o>0;){let n=Math.floor(Math.random()*o);r.push(e.splice(n,1)[0]),o--}return r},St=(t=[],e=1)=>{let r=P(t),o=Math.max(1,e),n=Math.min(o,r.length-1);return r.splice(0,n)};0&&(module.exports={TextEncoder,clone,compose,copies,crypto,curry,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,sha256,sha512,shuffle,slugify,sort,sortBy,stripAccent,stripTags,truncate,ucfirst,ucwords,unescapeHTML,unique});
// bellajs@11.1.1 https://github.com/ndaidong/bellajs - built with esbuild at 2022-10-12T10:45:38.055Z
var w=Object.defineProperty;var E=Object.getOwnPropertyDescriptor;var T=Object.getOwnPropertyNames;var I=Object.prototype.hasOwnProperty;var P=(t,e)=>{for(var r in e)w(t,r,{get:e[r],enumerable:!0})},U=(t,e,r,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of T(e))!I.call(t,n)&&n!==r&&w(t,n,{get:()=>e[n],enumerable:!(o=E(e,n))||o.enumerable});return t};var k=t=>U(w({},"__esModule",{value:!0}),t);var at={};P(at,{clone:()=>y,compose:()=>st,copies:()=>D,curry:()=>ot,escapeHTML:()=>W,formatDateString:()=>rt,formatTimeAgo:()=>nt,genid:()=>Z,hasProperty:()=>x,isArray:()=>u,isBoolean:()=>q,isDate:()=>j,isElement:()=>B,isEmail:()=>$,isEmpty:()=>K,isFunction:()=>z,isInteger:()=>F,isLetter:()=>H,isNil:()=>O,isNull:()=>S,isNumber:()=>h,isObject:()=>a,isString:()=>l,isUndefined:()=>M,maybe:()=>d,pick:()=>lt,pipe:()=>ct,randint:()=>Y,replaceAll:()=>b,shuffle:()=>_,slugify:()=>X,sort:()=>L,sortBy:()=>pt,stripAccent:()=>N,stripTags:()=>V,truncate:()=>R,ucfirst:()=>A,ucwords:()=>J,unescapeHTML:()=>G,unique:()=>it});module.exports=k(at);var g=t=>({}).toString.call(t),F=t=>Number.isInteger(t),u=t=>Array.isArray(t),l=t=>String(t)===t,h=t=>Number(t)===t,q=t=>Boolean(t)===t,S=t=>g(t)==="[object Null]",M=t=>g(t)==="[object Undefined]",O=t=>M(t)||S(t),z=t=>g(t)==="[object Function]",a=t=>g(t)==="[object Object]"&&!u(t),j=t=>t instanceof Date&&!isNaN(t.valueOf()),B=t=>g(t).match(/^\[object HTML\w*Element]$/)!==null,H=t=>{let e=/^[a-z]+$/i;return l(t)&&e.test(t)},$=t=>{let e=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;return l(t)&&e.test(t)},K=t=>!t||O(t)||l(t)&&t===""||u(t)&&t.length===0||a(t)&&Object.keys(t).length===0,x=(t,e)=>!t||!e?!1:Object.prototype.hasOwnProperty.call(t,e);var f=t=>{let e=h(t)?String(t):t;if(!l(e))throw new Error("InvalidInput: String required.");return e},R=(t,e=140)=>{let r=f(t);if(r.length<=e)return r;let n=r.substring(0,e).trim(),s=n.split(" ");return s.length>1?(s.pop(),s.map(i=>i.trim()).join(" ")+"..."):n.substring(0,e-3)+"..."},V=t=>f(t).replace(/(<([^>]+)>)/ig,"").trim(),W=t=>f(t).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;"),G=t=>f(t).replace(/&quot;/g,'"').replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&amp;/g,"&"),A=t=>{let e=f(t).toLowerCase();return e.length>1?e.charAt(0).toUpperCase()+e.slice(1):e.toUpperCase()},J=t=>f(t).split(" ").map(e=>A(e)).join(" "),b=(t,e,r)=>{let o=f(t),n=h(e)?String(e):e,s=h(r)?String(r):r;if(l(n)&&l(s))o=o.split(n).join(s);else if(u(n)&&l(s))n.forEach(c=>{o=b(o,c,s)});else if(u(n)&&u(s)&&n.length===s.length){let c=n.length;if(c>0)for(let i=0;i<c;i++){let p=n[i],C=s[i];o=b(o,p,C)}}return o},Q=()=>{let t={a:"á|à|ả|ã|ạ|ă|ắ|ặ|ằ|ẳ|ẵ|â|ấ|ầ|ẩ|ẫ|ậ|ä|æ",c:"ç",d:"đ|ð",e:"é|è|ẻ|ẽ|ẹ|ê|ế|ề|ể|ễ|ệ|ë",i:"í|ì|ỉ|ĩ|ị|ï|î",n:"ñ",o:"ó|ò|ỏ|õ|ọ|ô|ố|ồ|ổ|ỗ|ộ|ơ|ớ|ờ|ở|ỡ|ợ|ö|ø",s:"ß",u:"ú|ù|ủ|ũ|ụ|ư|ứ|ừ|ử|ữ|ự|û",y:"ý|ỳ|ỷ|ỹ|ỵ|ÿ"},e={...t};return Object.keys(t).forEach(r=>{let o=r.toUpperCase();e[o]=t[r].toUpperCase()}),e},N=t=>{let e=f(t),r=(n,s)=>{e=b(e,n,s)},o=Q();for(let n in o)x(o,n)&&o[n].split("|").forEach(c=>r(c,n));return e},X=(t,e="-")=>N(t).trim().toLowerCase().replace(/\W+/g," ").replace(/\s+/g," ").replace(/\s/g,e);var Y=(t=0,e=1e6)=>Math.floor(Math.random()*(e-t+1))+t,Z=(t=32,e="")=>{let r=e;for(let o=0;o<t;o++){let n=Math.random(),s=Math.floor(n*36),c=s.toString(36);r+=s>9&&n>.3&&n<.7?c.toUpperCase():c}return r.substring(0,t)};var v=()=>({dateStyle:"medium",timeStyle:"long"}),tt=()=>({second:1e3,minute:60,hour:60,day:24,week:7,month:4,year:12}),et=t=>{try{return new Intl.Locale(t).language!==""}catch{return!1}},rt=(...t)=>{let e=t[0],r=et(t[1])?t[1]:"en",o=v(),n=t.length>=3?t[2]:t.length===1?o:a(t[1])?t[1]:o;return new Intl.DateTimeFormat(r,n).format(new Date(e))},nt=(t,e="en",r="just now")=>{let o=new Date(t),n=Date.now()-o,s=tt();if(n<=s.second)return r;let c="second";for(let p in s){if(n<s[p])break;c=p,n/=s[p]}return n=Math.floor(n),new Intl.RelativeTimeFormat(e).format(-n,c)};var ot=t=>{let e=t.length,r=(o,n)=>o>0?(...s)=>r(o-s.length,[...n,...s]):t(...n);return r(e,[])};var st=(...t)=>t.reduce((e,r)=>o=>e(r(o)));var ct=(...t)=>t.reduce((e,r)=>o=>r(e(o)));var m=(t,e,r,o={})=>{let{writable:n=!1,configurable:s=!1,enumerable:c=!1}=o;Object.defineProperty(t,e,{value:r,writable:n,configurable:s,enumerable:c})};var d=t=>{let e=t,r=()=>e==null,o=()=>e,n=p=>d(e||p()),s=p=>d(p(e)===!0?e:null),c=p=>d(r()?null:p(e)),i=Object.create({});return m(i,"__value__",e,{enumerable:!0}),m(i,"__type__","Maybe",{enumerable:!0}),m(i,"isNil",r),m(i,"value",o),m(i,"map",c),m(i,"if",s),m(i,"else",n),i};var y=(t,e=null)=>{let r=e||new Set;if(r.has(t))return t;if(r.add(t),j(t))return new Date(t.valueOf());let o=s=>{let c=Object.create({});for(let i in s)x(s,i)&&(c[i]=y(s[i],r));return c},n=s=>[...s].map(c=>u(c)?n(c):a(c)?o(c):y(c,r));return u(t)?n(t):a(t)?o(t):t},D=(t,e,r=!1,o=[])=>{for(let n in t)if(!(o.length>0&&o.includes(n))&&(!r||r&&x(e,n))){let s=t[n],c=e[n];a(c)&&a(s)||u(c)&&u(s)?e[n]=D(s,e[n],r,o):e[n]=y(s)}return e},it=(t=[])=>[...new Set(t)],ut=(t,e)=>t>e?1:t<e?-1:0,L=(t=[],e=null)=>{let r=[...t],o=e||ut;return r.sort(o),r},pt=(t=[],e=1,r="")=>!l(r)||!x(t[0],r)?t:L(t,(o,n)=>o[r]>n[r]?e:o[r]<n[r]?-1*e:0),_=(t=[])=>{let e=[...t],r=[],o=e.length;for(;o>0;){let n=Math.floor(Math.random()*o);r.push(e.splice(n,1)[0]),o--}return r},lt=(t=[],e=1)=>{let r=_(t),o=Math.max(1,e),n=Math.min(o,r.length-1);return r.splice(0,n)};0&&(module.exports={clone,compose,copies,curry,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});

Check warning

Code scanning / CodeQL

Prototype-polluting function

Properties are copied from [t](1) to [e](2) without guarding against prototype pollution.
@ndaidong ndaidong merged commit 187f087 into main Oct 12, 2022
@ndaidong ndaidong deleted the 11.1.1 branch February 28, 2023 13:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants