1 min readAug 1, 2016
Excellent functional refactoring, Victor.
One bit of non-generic code remains:
type Predicate = (e: Employee) => boolean;
This infects and(), making it non-generic.
Easy to fix:
type Predicate<T> = (value: T) => boolean;
function and<T>(predicates: Predicate<T>[]): Predicate<T> { …
function filteredSalaries(employees: Employee[], conditions: Predicate<Employee>[]): number[] { …
I collected the code in a single gist with my tweaks: