Skip to content

Instantly share code, notes, and snippets.

Avatar
🍕
OSS on my mind

Tylor Steinberger TylorS

🍕
OSS on my mind
View GitHub Profile
View WeakRefMap.ts
export class WeakRefMap<K, V extends object> {
#weakRefs = new Map<K, WeakRef<V>>()
#registry = new FinalizationRegistry((key) => this.#weakRefs.delete(key))
has = (key: K) => this.#weakRefs.has(key)
get = (key: K) => this.#weakRefs.get(key)?.deref()
set = (key: K, value: V) => {
const ref = new WeakRef(value)
View better-gh-issue-labels
#!/bin/bash
echo -n "Github Username: "
read USER
echo -n "Password: "
read PASS
echo -n "Repo (e.g. cyclejs/core); "
read REPO
@TylorS
TylorS / dissoc.ts
Created Jan 1, 2018
Dissoc Type For Typescript
View dissoc.ts
type Subtract<A extends string, B extends string> = {
readonly [Key in A]: (Record<B, never> & Record<string, Key>)[Key]
}[A]
type Dissoc<A, B extends string> = Readonly<Pick<A, Subtract<keyof A, B>>>
View KeyboardEventKey.ts
export const enum KeyboareEventKey {
// Modifier Keys
Alt = 'Alt',
AltGraph = 'AltGraph',
CapsLock = 'CapsLock',
Control = 'Control',
Fn = 'Fn',
FnLock = 'FnLock',
Hyper = 'Hyper',
Meta = 'Meta',