Skip to content

Instantly share code, notes, and snippets.

@100ideas
Created June 28, 2019 07:00
Show Gist options
  • Save 100ideas/a8b9dc25df724cec5fb95afb621618f5 to your computer and use it in GitHub Desktop.
Save 100ideas/a8b9dc25df724cec5fb95afb621618f5 to your computer and use it in GitHub Desktop.
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>
// import { DatArchive } from "node-dat-archive";
// var DatArchive = require("node-dat-archive");
// import * as Dat from "dat-js";
// var DatJS = require("dat-js");
const DatWeb = require("dat-archive-web");
const exampleLabData = `dat://dd58cd3b0cae105f1708a97697ffecceee41cce98a8b7263fba806bca08782a7`;
// const exampleLabData = "dat://example-lab-data-small.hashbase.io";
// const dat = new Dat({
// gateway: "ws://gateway.mauve.moe:3000"
// });
// const dat = new DatJS();
// const labarchive = dat.get(exampleLabData);
async function initArchive(datAddress) {
// return new Promise(
// res => {
// // archive.on("ready", () => {
// // console.log("archive ready");
// // res(archive);
// // });
// labarchive.ready(() => {
// console.log("archive ready");
// labarchive.readdir("/", res);
// });
// },
// rej => console.error(rej)
// );
const datweb = await DatWeb.load(exampleLabData);
console.log(datweb.getInfo());
return datweb;
}
async function readDir() {
// let results = await initArchive(exampleLabData);
let datweb = initArchive();
let allFiles = await datweb.readdir("/", { recursive: true });
console.log(allFiles);
return allFiles;
}
export function readDat() {
let msg = "temp";
let dirs = readDir();
// let arch = initArchive(exampleLabData);
// let dir = await arch.readdir("/");
// msg = msg + "\n\n" + dir;
console.log(msg);
return "temp";
}
readDat()
{
"name": "esnextbin-sketch",
"version": "0.0.0"
}
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
var _regenerator = require("babel-runtime/regenerator");
var _regenerator2 = _interopRequireDefault(_regenerator);
var _asyncToGenerator2 = require("babel-runtime/helpers/asyncToGenerator");
var _asyncToGenerator3 = _interopRequireDefault(_asyncToGenerator2);
// const exampleLabData = "dat://example-lab-data-small.hashbase.io";
// const dat = new Dat({
// gateway: "ws://gateway.mauve.moe:3000"
// });
// const dat = new DatJS();
// const labarchive = dat.get(exampleLabData);
var initArchive = function () {
var _ref = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee(datAddress) {
var datweb;
return _regenerator2.default.wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
_context.next = 2;
return DatWeb.load(exampleLabData);
case 2:
datweb = _context.sent;
console.log(datweb.getInfo());
return _context.abrupt("return", datweb);
case 5:
case "end":
return _context.stop();
}
}
}, _callee, this);
}));
return function initArchive(_x) {
return _ref.apply(this, arguments);
};
}();
var readDir = function () {
var _ref2 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee2() {
var datweb, allFiles;
return _regenerator2.default.wrap(function _callee2$(_context2) {
while (1) {
switch (_context2.prev = _context2.next) {
case 0:
// let results = await initArchive(exampleLabData);
datweb = initArchive();
_context2.next = 3;
return datweb.readdir("/", { recursive: true });
case 3:
allFiles = _context2.sent;
console.log(allFiles);
return _context2.abrupt("return", allFiles);
case 6:
case "end":
return _context2.stop();
}
}
}, _callee2, this);
}));
return function readDir() {
return _ref2.apply(this, arguments);
};
}();
exports.readDat = readDat;
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
// import { DatArchive } from "node-dat-archive";
// var DatArchive = require("node-dat-archive");
// import * as Dat from "dat-js";
// var DatJS = require("dat-js");
var DatWeb = require("dat-archive-web");
var exampleLabData = "dat://dd58cd3b0cae105f1708a97697ffecceee41cce98a8b7263fba806bca08782a7";function readDat() {
var msg = "temp";
var dirs = readDir();
// let arch = initArchive(exampleLabData);
// let dir = await arch.readdir("/");
// msg = msg + "\n\n" + dir;
console.log(msg);
return "temp";
}
readDat();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment