View hyperdrive-serviceworker.js
/* eslint-env serviceworker */
/* global fetch, ReadableStream, Response */
// Tweak so internal crypto stuff can find `window.crypto`
window = self
const hyperdrive = require('hyperdrive')
const websocket = require('websocket-stream')
const ram = require('random-access-memory')
const { E, M } = require('promisey')
View nativescript-file-system-example
var fileSystemModule = require("file-system");
var fileName = "persistedFile.json";
var file = fileSystemModule.knownFolders.documents().getFile(fileName);
var data = [{"id": "1", "value": "NativeScript"}, ...];
// write data to the file, converted to a JSON string first
file.writeText(JSON.stringify(data));
// read data from the file
View blake2b.js
async function setup() {
// In node, this will use the polyfill and read the file from disk using `fs.readFile('blake2b.wasm', ...)`
// But in the browser, it will make an HTTP fetch request to `GET blake2b.wasm`!
let res = await fetch('blake2b.wasm')
let buf = await res.arrayBuffer()
let mod = await WebAssembly.instantiate(buf))
// ...
}
View tree-on-list.js
/*
0 - [foo] [[0][]] time - Add empty folder /foo
1 - [foo,hello] [[1][1]] time meta - Add file /foo/hello
2 - [foo,goodbye] [[2][1,2]] time meta - Add file /foo/goodbye
3 - [foo,man] [[3][1,2,3][]] time - Add empty folder /foo/man
4 - [bar,baz] [[3,4][4]] time meta - Add file /bar/baz
5 - [bar,bit] [[3,5][4,5]] time meta - Add file /bar/bit
6 - [foo,hello] [[5,6][2,3]] time - Delete /foo/hello
View idb-dat-storage.js
/* eslint-env browser */
var Buffer = require('buffer').Buffer
var name = 'dat'
function withStore (type, block, callback) {
var req = indexedDB.open(name + '-db', 1)
req.onerror = () => callback(req.error)
req.onupgradeneeded = () => req.result.createObjectStore(name)
req.onsuccess = () => {
View beaker-update.sh
git fetch
git reset --hard origin/master
git clean -xdf
rm package-lock.json app/package-lock.json
npm install
npm run rebuild
npm start
View rainbow.js
import React, { Component } from 'react'
import { View } from 'react-native'
export default class FlexDimensionsBasics extends Component {
constructor (props) {
super(props)
this.state = {time: Date.now()}
// Toggle the state every second
setInterval(() => {
View fake-hypercore.js
// Fake hypercore feed for testing and learning
var values = []
var feed = {
append (value, cb) {
console.log('APPEND', {value, cb})
values.push(value)
nextTick(cb)
},
get (index, options, cb) {
console.log('GET', {index, options, cb})
View coroutine-fengari.js
// Import some stuff from fengari
global.WEB = false
const {
lua: {
lua_pushnil,
lua_tointeger,
lua_touserdata,
lua_atnativeerror,
lua_yield,
lua_resume,
View coroutine-fengari.js
// Import some stuff from fengari
global.WEB = false
const {
lua: {
lua_tointeger,
lua_touserdata,
lua_atnativeerror,
lua_yield,
lua_resume,
lua_pushjsfunction,