Skip to content

Instantly share code, notes, and snippets.

Avatar
💙

vera kelsny

💙
View GitHub Profile
@kelsny
kelsny / README.md
Last active Feb 13, 2022
CodeWars RoboScript Kata Solutions
View README.md

These are my solutions to the RoboScript series of katas on CodeWars.

This Kata Series is based on a fictional story about a computer scientist and engineer who owns a firm that sells a toy robot called MyRobot which can interpret its own (esoteric) programming language called RoboScript. Naturally, this Kata Series deals with the software side of things (I'm afraid Codewars cannot test your ability to build a physical robot!).

@kelsny
kelsny / better-rxjs-pipe.ts
Created Nov 9, 2021
Extension of my previous gist specialized for RxJS
View better-rxjs-pipe.ts
type UnaryFunction<T, R> = (source: T) => R;
type Identity = <T>(source: T) => T;
type Pipe<T, L = void, R extends UnaryFunction<any, any>[] = []> =
T extends []
? R
: L extends void
? T extends [(_: infer P) => infer V, ...infer Rest]
? Pipe<Rest, V, [...R, UnaryFunction<P, V>]>
@kelsny
kelsny / pipe.ts
Last active Nov 9, 2021
Arbitrary arity pipe function typings
View pipe.ts
type UnaryFunction<T, R> = (source: T) => R;
type Pipe<T, L = void, R extends UnaryFunction<any, any>[] = []> =
T extends []
? R
: L extends void
? T extends [(_: infer P) => infer V, ...infer Rest]
? Pipe<Rest, V, [...R, UnaryFunction<P, V>]>
: never[]
: T extends [(_: L) => infer V, ...infer Rest]