UNPKG

@nexusui/components

Version:

These are custom components specially-developed for NexusUI applications. They will make your life easier by giving you out-of-the-box implementations for various high-level UI elements that you can drop directly into your application.

2 lines (1 loc) 833 B
const e=(e,t,d="descending")=>{const a=[...e],n="descending"===d?1:-1;return!a||a.length<1?[]:"date"===t?a.sort(((e,t)=>(new Date(t.dateModified).getTime()-new Date(e.dateModified).getTime())*n)):"unread"===t?a.sort(((e,t)=>t.unread&&!e.unread?1*n:e.unread&&!t.unread?-1*n:(new Date(t.dateModified).getTime()-new Date(e.dateModified).getTime())*n)):"author"===t?a.sort(((e,t)=>t.author.lastName<e.author.lastName?1*n:e.author.lastName<t.author.lastName?-1*n:(new Date(t.dateModified).getTime()-new Date(e.dateModified).getTime())*n)):a},t=(e,t)=>{if(!e||e.length<1)return[];if(0===t.length)return e.filter((e=>!e.resolved));const d=t.includes("read"),a=t.includes("unread"),n=t.includes("resolved"),r=[];return e.forEach((e=>{(d&&!e.unread||a&&e.unread||n&&e.resolved)&&r.push(e)})),r};export{t as filterComments,e as sortComments};