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 9.1.0 to 9.2.0

tests/specs/utils/sort.js

28

dist/bella.js
/**
* bellajs@9.1.0
* built on: Fri, 22 May 2020 02:51:59 GMT
* bellajs@9.2.0
* built on: Tue, 09 Jun 2020 09:35:29 GMT
* repository: https://github.com/ndaidong/bellajs

@@ -577,3 +577,8 @@ * maintainer: @ndaidong

};
const clone = (val) => {
const clone = (val, history = null) => {
const stack = history || new Set();
if (stack.has(val)) {
return val;
}
stack.add(val);
if (isDate(val)) {

@@ -586,3 +591,3 @@ return new Date(val.valueOf());

if (hasProperty(o, k)) {
oo[k] = clone(o[k]);
oo[k] = clone(o[k], stack);
}

@@ -599,3 +604,3 @@ }

}
return clone(e);
return clone(e, stack);
});

@@ -631,5 +636,10 @@ };

};
const sort = (fn, arr = []) => {
return [...arr].sort(fn);
const fnSort = (a, b) => {
return a > b ? 1 : a < b ? -1 : 0;
};
const sort = (arr = [], fn = fnSort) => {
const tmp = [...arr];
tmp.sort(fn);
return tmp;
};
const sortBy = (key, order = 1, arr = []) => {

@@ -641,5 +651,5 @@ return sort(arr, (m, n) => {

const shuffle = (arr = []) => {
return sort(() => {
return sort([...arr], () => {
return Math.random() > 0.5;
}, [...arr]);
});
};

@@ -646,0 +656,0 @@ const pick = (count = 1, arr = []) => {

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

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

@@ -4,0 +4,0 @@ "description": "A useful helper for any javascript program",

@@ -504,3 +504,3 @@ BellaJS

```js
sort(Array a, Number order)
sort(Array a [, Function compare])
```

@@ -513,4 +513,8 @@

sort([3, 1, 5, 2], 1); // => [ 1, 2, 3, 5 ]
sort([3, 1, 5, 2], -1); // => [ 5, 3, 2, 1 ]
const fn = (a, b) => {
return a < b ? 1 : a > b ? -1 : 0;
};
sort([3, 1, 5, 2], fn); // => [ 1, 2, 3, 5 ]
sort([3, 1, 5, 2], fn); // => [ 5, 3, 2, 1 ]
```

@@ -554,3 +558,3 @@

const result = sortBy('age', -1, players);
console.log(result_)
console.log(result)
```

@@ -557,0 +561,0 @@

@@ -77,3 +77,11 @@ /**

export const clone = (val) => {
export const clone = (val, history = null) => {
const stack = history || new Set();
if (stack.has(val)) {
return val;
}
stack.add(val);
if (isDate(val)) {

@@ -87,3 +95,3 @@ return new Date(val.valueOf());

if (hasProperty(o, k)) {
oo[k] = clone(o[k]);
oo[k] = clone(o[k], stack);
}

@@ -101,3 +109,3 @@ }

}
return clone(e);
return clone(e, stack);
});

@@ -140,6 +148,12 @@ };

export const sort = (fn, arr = []) => {
return [...arr].sort(fn);
const fnSort = (a, b) => {
return a > b ? 1 : a < b ? -1 : 0;
};
export const sort = (arr = [], fn = fnSort) => {
const tmp = [...arr];
tmp.sort(fn);
return tmp;
};
export const sortBy = (key, order = 1, arr = []) => {

@@ -152,5 +166,5 @@ return sort(arr, (m, n) => {

export const shuffle = (arr = []) => {
return sort(() => {
return sort([...arr], () => {
return Math.random() > 0.5;
}, [...arr]);
});
};

@@ -157,0 +171,0 @@

@@ -75,2 +75,7 @@ /**

assert.deepEquals(bella.stripTags(1238), '1238', `bella.stripTags(1238) must return "1238"`);
const fn = () => {
return bella.stripTags({});
};
assert.throws(fn, 'Error: InvalidInput: String required', 'stripTag non-string must throw error');
assert.end();

@@ -77,0 +82,0 @@ });

@@ -71,2 +71,9 @@ /**

assert.comment('Clone circular object');
const fn = () => {
const a = {t: 0};
a.me = a;
};
assert.doesNotThrow(fn, 'Clone circular object must not throw error');
assert.end();

@@ -73,0 +80,0 @@ });

Sorry, the diff of this file is not supported yet

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