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
class Token { | |
constructor( | |
public readonly name: string, | |
public readonly version: string, | |
public readonly tags: string[] = [] | |
) {} | |
toString() { | |
let string = `${this.name}/${this.version}`; |
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 type { MaybePromiseLike } from "monads-io"; | |
import { parallelMap } from "./parallel.js"; | |
type Handler<T> = (payload: T) => MaybePromiseLike<void>; | |
const EventType: unique symbol = Symbol("event.type"); | |
export class Event<T = any> { | |
[EventType]!: T; |
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
package fitnesse.html; | |
import fitnesse.responders.run.SuiteResponder; | |
import fitnesse.wiki.*; | |
public class SetupTeardownIncluder { | |
private PageData pageData; | |
private boolean isSuite; | |
private WikiPage testPage; | |
private StringBuffer newPageContent; |
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
export function bind(class_: Function) { | |
bindDescriptors(class_); | |
bindDescriptors(class_.prototype); | |
} | |
const autoBindSetup = Symbol("autoBindDone"); | |
function bindDescriptors(object: {}) { | |
if (autoBindSetup in object) { | |
return; |
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* zip<T extends readonly unknown[]>( | |
...iterables: { [key in keyof T]: Iterable<T[key]> } | |
): Generator<T, void, void> { | |
const iterators = iterables.map((iterable) => iterable[Symbol.iterator]()); | |
outer: while (iterators.length > 0) { | |
const values: unknown[] = []; | |
for (const iterator of iterators) { | |
const result = iterator.next(); |
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 generator = new SnowflakeGenerator({ | |
machineId: 129 | |
}); | |
const encoder = new BigIntEncoder({ | |
entityPrefix: "usr_" | |
}); | |
const id = generator.generate(); //? => 7044728736365154305 |
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 { wrapCall } from "./wrap.ts"; | |
const call = wrapCall('username=AlexXanderGrib', () => { | |
throw new Error(); | |
}) | |
call.async().catch(error => console.log(error.stack)); | |
// Error | |
// at example.ts:4:4 | |
// at username=AlexXanderGrib |
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 type { | |
AsyncMonad, | |
Alternative, | |
Container | |
} from "@sweet-monads/interfaces"; | |
const enum EitherType { | |
Left = "Left", | |
Right = "Right" | |
} |
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 a = new Proxy({ i: 1 }, { | |
get: (target) => () => target.i++, | |
}) | |
console.log(a == 1, a == 2, a == 3); | |
// true true true |
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 head = <T>(list: T[]) => list[0]; | |
const tail = <T>(list: T[]) => list.slice(1); | |
const merge = | |
<T>(a: T[]) => | |
(b: T[]) => | |
[...a, ...b]; | |
const sizeOf = (arg: { length: number }) => arg.length; | |
type Fn<A, B> = (arg: A) => B; |
NewerOlder