Skip to content

Instantly share code, notes, and snippets.

@phillmac
phillmac / iterable_weak_map.js
Last active Jun 24, 2020 — forked from seanlinsley/iterable_weak_set.js
Iterable WeakSet in JavaScript
View iterable_weak_map.js
// spec: https://github.com/tc39/proposal-weakrefs
// the spec contains an [iterable WeakMap implementation](https://github.com/tc39/proposal-weakrefs#iterable-weakmaps)
// NOTE: this WeakSet implementation is incomplete, only does what I needed
// In Firefox Nightly, visit about:config and enable javascript.options.experimental.weakrefs
class IterableWeakMap extends Map {
set(k, v) {
super.set(new WeakRef(k), v)
}
forEach(fn) {
@phillmac
phillmac / put.txt
Created Apr 13, 2020
put vs putAll performace
View put.txt
Starting IPFS daemon...
287 docs per second, 287 docs in 1 seconds (Oplog: 287)
305 docs per second, 592 docs in 2 seconds (Oplog: 592)
285 docs per second, 877 docs in 3 seconds (Oplog: 877)
236 docs per second, 1113 docs in 4 seconds (Oplog: 1113)
180 docs per second, 1293 docs in 5 seconds (Oplog: 1293)
224 docs per second, 1517 docs in 6 seconds (Oplog: 1517)
217 docs per second, 1734 docs in 7 seconds (Oplog: 1734)
200 docs per second, 1934 docs in 8 seconds (Oplog: 1935)
192 docs per second, 2126 docs in 9 seconds (Oplog: 2126)
View put.log
Starting IPFS daemon...
287 docs per second, 287 docs in 1 seconds (Oplog: 287)
305 docs per second, 592 docs in 2 seconds (Oplog: 592)
285 docs per second, 877 docs in 3 seconds (Oplog: 877)
236 docs per second, 1113 docs in 4 seconds (Oplog: 1113)
180 docs per second, 1293 docs in 5 seconds (Oplog: 1293)
224 docs per second, 1517 docs in 6 seconds (Oplog: 1517)
217 docs per second, 1734 docs in 7 seconds (Oplog: 1734)
200 docs per second, 1934 docs in 8 seconds (Oplog: 1935)
192 docs per second, 2126 docs in 9 seconds (Oplog: 2126)
@phillmac
phillmac / api.js
Created Mar 12, 2019
Orbit-DB Http API
View api.js
const IpfsApi = require('ipfs-api');
const OrbitDB = require('orbit-db');
const Express = require('express');
const DBManager = require('./dbmanager.js').DBManager
const api_port = process.env.API_PORT;
const ipfs_host = process.env.IPFS_HOST
const ipfs_port = process.env.IPFS_PORT
const orbitdb_dir = process.env.ORBITDB_DIR
You can’t perform that action at this time.