git ssb

6+

Dominic / epidemic-broadcast-trees



Tree: da8b90d365d449e737c606b1ba23cc612834778e

Files: da8b90d365d449e737c606b1ba23cc612834778e / util.js

831 bytesRaw
1'use strict'
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.
5exports.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
15exports.isMessage = function (msg) {
16 return msg && Number.isInteger(msg.sequence) && 'string' === typeof msg.author && msg.content != null
17}
18
19exports.isNote = function (note) {
20 return Number.isInteger(note)
21// return note && Number.isInteger(note.seq) && 'string' == typeof note.author && !msg.content
22}
23
24exports.isNotes = function (data) {
25 return typeof data === 'object' && data !== null && !(data instanceof Buffer)
26}
27

Built with git-ssb-web