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
function dateTimeFormat(timestamp, locale, str, ...opts) { | |
const d = new Date(timestamp); | |
return str.replace(/{(\d+)}/g, function(match, number) { | |
return typeof opts[number] != 'undefined' | |
? new Intl.DateTimeFormat(locale, opts[number]).format(d) | |
: match; | |
}); | |
} | |
console.log(dateTimeFormat("2021-11-19T19:19:36.598071-06:00", "en", "{0} at {1}!", {dateStyle:"short"}, {timeStyle:"long"})) |
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
const basicHTML = require('basichtml'); | |
basicHTML.init(); | |
document.documentElement.setAttribute('lang', 'en'); | |
const {bind} = require('hyperhtml'); | |
const model = { | |
index: { | |
title: 'hyperHTML does Cloudflare too', | |
h1: { |
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
import React from "react"; | |
import useMutableReducer from "./useMutableReducer"; | |
const reducer = (draft, action, state) => { | |
switch (action) { | |
case "increment": | |
draft.count++; | |
break; | |
case "decrement": | |
draft.count--; |
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
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 }); |