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