tim
Version:
Tradle's P2P OTR-based chat with plaintext and structured messages, and the ability to externalize messages onto a blockchain (currently bitcoin's)
19 lines (16 loc) • 352 B
JavaScript
var rebuf = require('@tradle/utils').rebuf
module.exports = {
encode: function (entry) {
return JSON.stringify(entry)
},
decode: function (entry) {
try {
return rebuf(JSON.parse(entry))
} catch (err) {
console.warn('failed to decode entry', entry)
return entry
}
},
buffer: false,
type: 'jsonWithBufs'
}