Test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const sodium = require('sodium-native') | |
const assert = require('nanoassert') | |
const priv = new WeakMap() | |
class Key { | |
static BYTES = sodium.crypto_secretbox_KEYBYTES | |
static NONCEBYTES = crypto.crypto_aead_xchacha20poly1305_ietf_NPUBBYTES | |
static TAGBYTES = sodium.crypto_aead_xchacha20poly1305_ietf_ABYTES | |
static create () { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const sodium = require('sodium-native') | |
const DHT = require('bittorrent-dht') | |
const dht = new DHT({ | |
verify: sodium.crypto_sign_verify_detached | |
}) | |
const keys = keygen() | |
dht.put({ | |
v: Buffer.from('Hello world'), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function generator () { | |
var lastTime = Date.now() | |
var cnt = 0 | |
return function () { | |
var currentTime = Date.now() | |
if (currentTime !== lastTime) { | |
lastTime = currentTime | |
cnt = 0 | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const accounts = 1 | |
const bits = 42 | |
function forin (n, exp) { | |
res = [] | |
for (var i = 0; i < n; i++) { | |
res.push(exp(n)) | |
} | |
return res | |
} |
- do on readable then read
- do framing
- don't use data
- check this.destroyed after each "Hand-off" (emit and push)
- check stream.destroyed after all async operations
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
node_modules | |
remote | |
local |
- Have a recent version of Node (8+)
- Run
npm install -g wat2wasm wat2js
to have the compiler installed globally - Install a WebAssembly language pack for your editor (the one for Atom is nice)
- Optional: Install parinfer, which will help you managing brackets when writing WAT: https://shaunlebron.github.io/parinfer/#editor-plugins
- Have a recent version of Node (8+)
- Run
npm install -g wat2wasm wat2js
to have the compiler installed globally - Install a WebAssembly language pack for your editor (the one for Atom is nice)
- Optional: Install parinfer, which will help you managing brackets when writing WAT: https://shaunlebron.github.io/parinfer/#editor-plugins
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(module | |
(memory (export "memory") 1) | |
(func $decide | |
(export "decide") | |
(param $zero i32) | |
(result i32) | |
(if (result i32) | |
(i32.eqz (get_local $zero)) | |
(then (i32.const 0)) |
NewerOlder