@sync-in/server
Version:
The secure, open-source platform for file storage, sharing, collaboration, and sync
2 lines (1 loc) • 873 B
JavaScript
import{Oa as a,Xa as f}from"./chunk-O3YLAEVE.js";function b(c,n,i,e){let t=f(i,".");switch(c){case"number":N(n,i,e,t);break;case"string":r(n,i,e,t);break;case"length":g(n,i,e,t);break;case"date":u(n,i,e,t);break;default:console.warn(`Sort function not handles: ${c}.`)}}function u(c,n,i,e=!1){c.sort((t,l)=>{let o=new Date(e?a(t,n):t[n]).getTime(),s=new Date(e?a(l,n):l[n]).getTime();return isNaN(o)?1:isNaN(s)?-1:o===s?0:i?o>s?1:-1:s>o?1:-1})}function r(c,n,i,e=!1){c.sort((t,l)=>{let o=e?(a(t,n)||"z").toLowerCase():t[n].toLowerCase(),s=e?(a(l,n)||"z").toLowerCase():l[n].toLowerCase();return i?o<s?1:o>s?-1:0:o<s?-1:o>s?1:0})}function g(c,n,i,e=!1){c.sort((t,l)=>{let o=e?a(t,n).length:t[n].length,s=e?a(l,n).length:l[n].length;return i?o-s:s-o})}function N(c,n,i,e=!1){c.sort((t,l)=>{let o=e?a(t,n):t[n],s=e?a(l,n):l[n];return i?o-s:s-o})}export{b as a,u as b,N as c};