Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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