Skip to content

Instantly share code, notes, and snippets.

@cblgh
cblgh / neat-example.js
Created July 4, 2018 19:26
testing neat-log's re-rendering on resize
var neatLog = require('..')
var output = require("diffy/trim")
var log = neatLog(headerView, {fullscreen: true})
log.render() // force an immediate render
function headerView (state) {
return output(`
Hello World!
rows ${process.stdout.rows}
function isValidMessage(msg) {
if (!msg.value.type) msg.value.type = "text/chat"
return msg.value && typeof msg.value === "object"
}

ARCHITECTURE

cabal clients
  cabal-core

cabal-core
  discovery-swarm
    dat-swarm-defaults
  kappa-view-level
 kappa-core
var hypercore = require('hypercore')
var pump = require("pump")
var disco = require("discovery-swarm")
var feed = hypercore('./single-chat-feed', {
valueEncoding: 'json'
})
var swarm = disco()
feed.ready(function () {
console.log("pub", feed.key.toString("hex"))

cabal-client definitely stores:

  • what channels you have joined
  • for each channel you've joined: what was the latest message you read in that channel
  • last viewed channel

cabal-client probably stores:

  • what cabals you have joined
  • what aliases (human friendly names for cabal:// keys) you have for those cabals
var asciify = require('asciify-image')
var options = {
fit: 'box',
width: process.stdout.columns,
height: process.stdout.rows
}
asciify('cabal.png', options)
.then(function (asciified) {
/ban
/mute
/purge
/ignore
**with optional stated reason**
hide all posts
hide future posts
hide locally only
return new Promise((res, rej) => {
rej ("mistaken")
console.log("Nope :)")
res("hehe")
}).then(() => {
console.log("execution continued without problem")
}).catch(() => {
console.log("lol im a noob")
})