- Erasable
- Gradual
- Structural
- Generic
- Inferable
View onSettled.js
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
/** @param promises {Array<Promise<unknown>>} */ | |
export async function * onSettled(promises) { | |
let wake; | |
let wait = new Promise(_ => wake = _); | |
let pending = promises.length; | |
const queue = []; | |
for (const p of promises) { | |
Promise.allSettled([p]).then(([result]) => { | |
queue.push(result); |
View tuples-in-weakmaps.js
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
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | |
// this approach fails to handle cycles | |
// next attempt: https://gist.github.com/acutmore/d1aaaff27c898fdd26b2e15de5c2f7c6 | |
const {Tuple, FakeSymbol} = ToyTupleLib(); | |
const Box = BoxLib(FakeSymbol); | |
const TupleWeakMap = TupleWeakMapLib(Tuple, FakeSymbol, v => FakeSymbol.isFakeSymbol(v)); | |
const wm = new TupleWeakMap(); |
View index.md
View simple-tsserver-script.js
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
// @ts-check | |
const childProcess = require('child_process'); | |
const path = require('path'); | |
const TTL_MS = 5000; | |
/** | |
* @description Start a connection to tsserver | |
* @param {{debug?: boolean}} options | |
* @example | |
const server = tsserverAPI.start(); |
View _web-framework-render-fns.md
Web Framework Render Functions
A look at the different render functions created by different web-frameworks, for the same website.
Website is very minimal:
- A large rectangle than can recursively render 9 more rectangles inside it
- Can navigate around the rectangles (Cells) using the keyboard
Vanilla.js demo https://gistpreview.github.io/?154fa3d4a17c3e124eb9ea0e7b69ae1d/z_vanilla.html
View focused.js
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 updateFocus(elm) { | |
const focusedClass = 'focused'; | |
const currentlyFocused = document.querySelector('.' + focusedClass); | |
if (currentlyFocused != null) { | |
currentlyFocused.classList.remove(focusedClass); | |
} | |
if (elm) { | |
elm.classList.add(focusedClass); | |
} | |
} |
View README.md
A compile-time 4-Bit Virtual Machine implemented in TypeScript's type system. Capable of running a sample 'FizzBuzz' program.
Syntax emits zero JavaScript.
type RESULT = VM<
[
["push", N_1], // 1
["push", False], // 2
["peek", _], // 3
View tsc-logic.ts
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
// ASHEMBLER | |
type B = 1 | 0; | |
type BITS_4 = [B,B,B,B]; | |
// note: 'assert' interfaces function as unit tests | |
interface assert { | |
true: 1; | |
false: 0; | |
} |
View resolve.test.ts
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 {resolve, Service, ResolvedService} from './resolve'; | |
describe('resolve', () => { | |
it('resolves a single service graph', () => { | |
const input: Service[] = [ | |
{ | |
name: 'a', | |
requires: [] | |
} | |
]; |
View index.ts
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
/// <reference types="node" /> | |
import { mod } from "riceburn"; | |
import { TypescriptMod } from "riceburn/lib/interfaces"; | |
import ts = require("typescript"); | |
import cp = require("child_process"); | |
import fs = require("fs"); | |
const glob = require("glob"); | |
import { getServiceDescription } from "../phoenix/tools/webpack/hatch/typescript-dependency-annotations/tsc-dep-annotations"; | |
const { log } = console; |
NewerOlder