0.0.2 • Published 2 years ago

pe-fp v0.0.2

Weekly downloads
-
License
ISC
Repository
github
Last release
2 years ago

pe-fp

Functional programming in plain english

TL;DR

Allows to turn this:

const cake = cooledOnDampTeaTowel(bakedIn(preheated("oven"))(whiskedUntilSmooth(mixed(["flour", "eggs", "sugar", "chocolate"]))))

expect(`A ${cake}`).toBe(
  "A room temperature cake made from whisked batter made out of flour, eggs, sugar and chocolate baked in a preheated oven"
);

Into this:

export const preparedCake = startsWith(mixed, "ingredients")
  .andThen(is(whiskedUntilSmooth))
  .andThen(is(bakedIn(preheated("oven"))))
  .andThen(is(cooledOnDampTeaTowel));
  
expect(`A ${preparedCake(["flour", "eggs", "sugar", "chocolate"])}`).toBe(
  "A room temperature cake made from whisked batter made out of flour, eggs, sugar and chocolate baked in a preheated oven"
);