In the process of implementing a basic graph system with nodes that point to other nodes (node → node) using an identifier code, we got to this simple but acceptable solution:
interface GraphNode {
code: number;
next: number | null;| class Quality {} | |
| class PerfectQuality extends Quality {} | |
| class ImperfectQuality extends Quality {} | |
| abstract class NotationSystem<T> implements Parser<T> {} | |
| abstract class Parser<T> { | |
| bool matches(String source); | |
| } |
| type ResultSuccess<T> = { success: true; value: T }; | |
| type ResultFailure<T> = { success: false; error: T }; | |
| type ExtractFailure<T> = T extends ResultFailure<infer U> ? U : never; | |
| type ExtractSuccess<T> = T extends ResultSuccess<infer U> ? U : never; | |
| /** | |
| * Represents the awaited results of an array of promises, each of which can resolve | |
| * to either `ResultSuccess` or `ResultFailure`. | |
| * |
| /** | |
| * Converts the given string from camel-case to kebab-case. | |
| * @template T The string to convert the case. | |
| * @see https://gist.github.com/albertms10/09f14ef7ebdc3ce0e95683c728616253 | |
| * @example | |
| * type Kebab = CamelToKebab<'exampleVarName'>; | |
| * // 'example-var-name' | |
| */ | |
| type CamelToKebab<S extends string> = S extends `${infer T}${infer U}` | |
| ? U extends Uncapitalize<U> |
| /** | |
| * Removes nullable properties (with `null` or `undefined` values) from an object or array. | |
| * @template T The object or array to remove nullable properties from. | |
| * @see https://gist.github.com/albertms10/fb5a6d87a97db584086241d5bad74a41 | |
| * @example | |
| * type A = { a?: string; b: null; c?: number | null }; | |
| * type B = NonNullableCollection<A>; | |
| * // { a: string; c: number; } | |
| * @example | |
| * type A = [string, undefined, number, null]; |
| import { execSync } from 'child_process'; | |
| import { parseArgs } from 'node:util'; | |
| export const { values: args } = parseArgs({ | |
| options: { | |
| workspace: { type: 'string', short: 'w' }, | |
| }, | |
| }); | |
| const foundDependencies = new Set(); |
| /** | |
| * Object type that represents all possible paths of an object, | |
| * including optional members. | |
| * @template T The object type to get the paths from. | |
| * @see https://stackoverflow.com/a/76131375/10851645 | |
| * @see https://gist.github.com/albertms10/5a8b83e436a1689aa4b425ec22058301 | |
| * @example | |
| * interface Package { | |
| * name: string; | |
| * man?: string[]; |
| void main() { | |
| print(DateTime(2000, 1, 0)); // previous day | |
| print(DateTime(2000, 1, 1)); // proper day | |
| } |
| import collections | |
| import itertools | |
| import operator | |
| import random | |
| import sys | |
| from enum import Enum | |
| class Outcomes(Enum): | |
| H = 0 |