Functional programming for node fs