made with esnextbin
Last active
September 1, 2019 18:38
-
-
Save DougAnderson444/bedb33fde08a718d9a8b12972ccfae80 to your computer and use it in GitHub Desktop.
Hypertrie-demo esnextbin sketch
made with esnextbin
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
<!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> |
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
// 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) | |
}) |
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
{ | |
"name": "esnextbin-sketch", | |
"version": "0.0.0", | |
"dependencies": { | |
"hypertrie": "3.7.1", | |
"random-access-web": "2.0.3", | |
"dat-sdk": "0.2.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
'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