Running a dht node is as simple as installing the DHT cli.
npm i -g @hyperswarm/cli
import {ReadableStream} from 'node:stream/web'; | |
/** | |
* @param iterable an iterable (asynchronous or synchronous) | |
* | |
* @see https://streams.spec.whatwg.org/#example-rs-pull | |
*/ | |
function iterableToReadableStream(iterable) { | |
return new ReadableStream({ | |
async start() { |
let last = new Date(); | |
setInterval(function () { | |
delta = new Date() - last; | |
if (delta > 2) { | |
console.log(delta); | |
} | |
last = new Date(); | |
}, 1); | |
setInterval(function () { |
Given an Array of Functions fns
, what argument(s) can you pass to fns.forEach
such that each function in fns
will execute, in order, without creating any anonymous (or named) functions or invoking the Function
constructor?
function
keyword, or arrow functions () =>
.Function
constructor.Function#bind
& friends on the Function.prototype
are ok.@timestampable | |
class Dog { | |
public name: string = 'Paul'; | |
} | |
function timestampable(func) { | |
return <any>(function() { | |
var genericConstructor = () => {}; | |
genericConstructor.prototype = func.prototype; | |
var instance = new genericConstructor(); |