Skip to content

Instantly share code, notes, and snippets.

View TylorS's full-sized avatar
🍕
OSS on my mind

Tylor Steinberger TylorS

🍕
OSS on my mind
View GitHub Profile
@TylorS
TylorS / mimeTypesESM.ts
Created September 10, 2023 16:41
ESM Module port of mime types
/**
* Adapted from https://github.com/broofa/mime/blob/main/index.js#L4
*/
export const mimeTypesToFileExtensions = {
"application/andrew-inset": ["ez"],
"application/applixware": ["aw"],
"application/atom+xml": ["atom"],
"application/atomcat+xml": ["atomcat"],
"application/atomsvc+xml": ["atomsvc"],
"application/bdoc": ["bdoc"],
@TylorS
TylorS / WeakRefMap.ts
Created May 27, 2021 14:48
WeakRefMap
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)
@TylorS
TylorS / esnextbin.md
Created June 26, 2019 20:46
esnextbin sketch
@TylorS
TylorS / dissoc.ts
Created January 1, 2018 17:15
Dissoc Type For Typescript
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>>>
export const enum KeyboareEventKey {
// Modifier Keys
Alt = 'Alt',
AltGraph = 'AltGraph',
CapsLock = 'CapsLock',
Control = 'Control',
Fn = 'Fn',
FnLock = 'FnLock',
Hyper = 'Hyper',
Meta = 'Meta',
@TylorS
TylorS / esnextbin.md
Last active June 22, 2017 15:24
esnextbin sketch
@TylorS
TylorS / esnextbin.md
Last active June 13, 2017 14:40
esnextbin sketch
@TylorS
TylorS / esnextbin.md
Created June 13, 2017 13:59
esnextbin sketch
@TylorS
TylorS / esnextbin.md
Created June 6, 2017 19:48
esnextbin sketch
@TylorS
TylorS / esnextbin.md
Last active June 3, 2017 18:44
esnextbin sketch