Skip to content

Instantly share code, notes, and snippets.

View o-t-w's full-sized avatar

Oliver Williams o-t-w

View GitHub Profile
@WebReflection
WebReflection / index.js
Last active November 20, 2018 19:03
hyperHTML does Cloudflare Worker
const basicHTML = require('basichtml');
basicHTML.init();
document.documentElement.setAttribute('lang', 'en');
const {bind} = require('hyperhtml');
const model = {
index: {
title: 'hyperHTML does Cloudflare too',
h1: {
@aweary
aweary / App.js
Last active August 29, 2021 14:06
import React from "react";
import useMutableReducer from "./useMutableReducer";
const reducer = (draft, action, state) => {
switch (action) {
case "increment":
draft.count++;
break;
case "decrement":
draft.count--;
@domenic
domenic / readable-stream-progress.js
Last active February 10, 2020 17:05
XHR-esque progress events on top of streams
function processBodyChunkwiseWithProgress(res, processChunk) {
const dummyEventTarget = document.createElement("div"); // why isn't EventTarget constructible? :(
const lengthComputable = res.headers.has("Content-Length");
const total = res.headers.get("Content-Length") || 0;
let loaded = 0;
// Using http://underscorejs.org/#throttle
const fireProgressThrottled = _.throttle(fireProgress, 50, { trailing: false });