Skip to content

Instantly share code, notes, and snippets.

View bulebrainbrand's full-sized avatar

bulebrainbrand bulebrainbrand

  • Japan
View GitHub Profile
import { styleText } from 'node:util';
type Format = Extract<Parameters<typeof styleText>[0], string>;
type Chalk = ((text: string) => string) & { [K in Format]: Chalk };
const create = (format: Format[]) =>
new Proxy((text: string) => text, {
get: (_, prop) => create([...format, prop as Format]),
apply: (_, __, [text]: [string]) => styleText(format, text),
}) as Chalk;
@mst-mkt
mst-mkt / nabeatsu.d.ts
Last active July 14, 2026 06:42
TypeScriptの型で世界のナベアツ
type Natural = 0[];
type Zero = [];
type One = [0];
type AhoSuffix = '(アホ)';
type Length<Array extends unknown[]> = Extract<Array['length'], number>;
type Add<N1 extends Natural, N2 extends Natural> = [...N1, ...N2];
type AddNum<N1 extends number, N2 extends number> = Length<[...NumToNat<N1>, ...NumToNat<N2>]>;
type Sub<N1 extends Natural, N2 extends Natural> = N1 extends [...N2, ...infer M]
? M