MCPcopy Create free account
hub / github.com/ThatGuySam/doesitarm / byTimeThenNull

Function byTimeThenNull

helpers/sort-list.js:1–17  ·  view source on GitHub ↗
(appA, appB)

Source from the content-addressed store, hash-verified

1export function byTimeThenNull (appA, appB) {
2 // console.log('appA.lastUpdated', appA.lastUpdated)
3
4 // equal items sort equally
5 if (appA.lastUpdated === appB.lastUpdated) {
6 return 0;
7 }
8 // nulls sort after anything else
9 else if (appA.lastUpdated === null) {
10 return 1;
11 }
12 else if (appB.lastUpdated === null) {
13 return -1;
14 }
15
16 return appB.lastUpdated.timestamp - appA.lastUpdated.timestamp
17}
18
19export default function (appList) {
20 return appList.sort(byTimeThenNull)

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected