Files: 2744ecd62eb4f3f3bc415d40a981b0a6afc9507e / util.js
699 bytesRaw
1 | //this should be replaced with a heap, |
2 | //but i'll look for a good heap implementation later |
3 | //this should be enough for now. |
4 | exports.sort = function (queue) { |
5 | return queue.sort(function (a, b) { |
6 | if(!a.value && !b.value) return 0 |
7 | if(a.value && !b.value) return -1 |
8 | else if(b.value && !a.value) return 1 |
9 | else return a.value.timestamp - b.value.timestamp |
10 | return 0 |
11 | }) |
12 | } |
13 | |
14 | exports.isMessage = function (msg) { |
15 | return msg && Number.isInteger(msg.sequence) && 'string' === typeof msg.author && msg.content != null |
16 | } |
17 | |
18 | exports.isNote = function (note) { |
19 | return Number.isInteger(note) |
20 | // return note && Number.isInteger(note.seq) && 'string' == typeof note.author && !msg.content |
21 | } |
22 |
Built with git-ssb-web