- Erasable
- Gradual
- Structural
- Generic
- Inferable
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
console.clear(); | |
function isFunction(o){ | |
return typeof o === (typeof isFunction); | |
} | |
/** | |
* Wraps up an object replacing methods with an interceptor | |
* @param obj - the obj to wrap | |
* @param interceptor {(obj, methodName, args) => any} |
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 OriginalPromise = Promise; | |
const enum State { | |
PENDING, | |
RESOLVED, | |
REJECTED | |
} | |
const emptyFn = () => {}; | |
const FUDGE_FACTOR_MS = 100; |
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; | |
} |
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; |
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: [] | |
} | |
]; |
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); | |
} | |
} |
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); |
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(); |
Immutability is Equality's support act [hackmd]
When considering the design of the Record & Tuple proposal a core driver in much of the design stems primarily from equality rather than immutability.
There are many ways to think about equality but one way to divide up the design space is two dimensions.
pure | impure |
---|
OlderNewer