class ComparableNumber implements Comparable<number> {
constructor(private _value: number) {}
get value() {
return this._value;
This file contains hidden or 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
| /** | |
| Copyright 2023 Sal Rahman | |
| Permission is hereby granted, free of charge, to any person obtaining a copy of | |
| this software and associated documentation files (the “Software”), to deal in | |
| the Software without restriction, including without limitation the rights to | |
| use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of | |
| the Software, and to permit persons to whom the Software is furnished to do so, | |
| subject to the following conditions: |
This file contains hidden or 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
| interface ReadOnlyMapNoGetter<K, V> { | |
| has(key: K): boolean; | |
| entries(): IterableIterator<[K, V]>; | |
| forEach(cb: (value: V, key: K, map: ReadOnlyMapNoGetter<K, V>) => void): void; | |
| keys(): IterableIterator<K>; | |
| values(): IterableIterator<V>; | |
| readonly size: number; | |
| } | |
| interface ReadOnlyMap<K, V> extends ReadOnlyMapNoGetter<K, V> { |
This file contains hidden or 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
| class Trie { | |
| private children: Map<string, Trie> = new Map(); | |
| insert(value: string) { | |
| if (value === "") { | |
| return; | |
| } | |
| const first = value[0]; | |
| if (!first) { | |
| throw new Error("Expected the first element to not be an empty string."); |
This file contains hidden or 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
| type List<T1> = [T1, List<T1> | null]; | |
| function* iterateCons<T>([left, right]: List<T>): IterableIterator<T> { | |
| if (right) { | |
| yield* iterateCons(right); | |
| } | |
| yield left; | |
| } | |
| const cons = <T1, T2>(left: T1, right: T2): [T1, T2] => [left, right]; |
This file contains hidden or 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
| type Pipe<T> = { | |
| _<V>(fn: (value: T) => V): Pipe<V>; | |
| readonly value: T; | |
| }; | |
| function start<T>(initial: T): Pipe<T> { | |
| return { | |
| _<V>(fn: (value: T) => V): Pipe<V> { | |
| return start(fn(initial)); | |
| }, |
This file contains hidden or 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
| export type Listener<T> = (value: T) => void; | |
| export type OperatorFunction<T, V> = ( | |
| oberver: IObservable<T> | |
| ) => IObservable<V>; | |
| export interface IObservable<T> { | |
| subscribe(listner: Listener<T>): () => void; | |
| } |
This file contains hidden or 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 { useEffect, useRef, useState } from "react"; | |
| export default function ExpandableInput( | |
| props: React.DetailedHTMLProps< | |
| React.InputHTMLAttributes<HTMLInputElement>, | |
| HTMLInputElement | |
| > | |
| ) { | |
| const [value, setValue] = useState(props.value); | |
| const inputRef = useRef<HTMLInputElement | null>(null); |
This file contains hidden or 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
| export type Links = { [key: string]: Link }; | |
| export type StatusCode = | |
| | "400" | |
| | "401" | |
| | "402" | |
| | "403" | |
| | "404" | |
| | "405" | |
| | "406" |