Skip to content

Instantly share code, notes, and snippets.

@DougAnderson444
Last active September 1, 2019 18:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DougAnderson444/bedb33fde08a718d9a8b12972ccfae80 to your computer and use it in GitHub Desktop.
Save DougAnderson444/bedb33fde08a718d9a8b12972ccfae80 to your computer and use it in GitHub Desktop.
Hypertrie-demo esnextbin sketch
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>ESNextbin Sketch</title>
<!-- put additional styles and scripts here -->
</head>
<body>
<!-- put markup and other contents here -->
</body>
</html>
// write ES2015 code and import modules from npm
// and then press "Execute" to run your program
const hypertrie = require('hypertrie')
const RAW = require('random-access-web')
const SDK = require('dat-sdk')
const { Hypercore } = SDK() //wss: breaks this
const storage = RAW('triedb')
const db = hypertrie(storage, {valueEncoding: 'json'})
db.put('hello', 'world', function () {
db.get('hello', console.log)
})
{
"name": "esnextbin-sketch",
"version": "0.0.0",
"dependencies": {
"hypertrie": "3.7.1",
"random-access-web": "2.0.3",
"dat-sdk": "0.2.0"
}
}
'use strict';
// write ES2015 code and import modules from npm
// and then press "Execute" to run your program
var hypertrie = require('hypertrie');
var RAW = require('random-access-web');
var SDK = require('dat-sdk');
var _SDK = SDK(),
Hypercore = _SDK.Hypercore; //wss: breaks this
var storage = RAW('triedb');
var db = hypertrie(storage, { valueEncoding: 'json' });
db.put('hello', 'world', function () {
db.get('hello', console.log);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment