git ssb

6+

Dominic / epidemic-broadcast-trees



Tree: d7274a7dbfa5c6ea2e60d2a7e9e592973469a894

Files: d7274a7dbfa5c6ea2e60d2a7e9e592973469a894 / 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.
4exports.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
14exports.isMessage = function (msg) {
15 return msg && Number.isInteger(msg.sequence) && 'string' === typeof msg.author && msg.content != null
16}
17
18exports.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