philbooth/trier.js — pull request #3 by philbooth (2013-09-21 17:35:41+00:00)
Title: Reduce API footprint

VERY UNSURE ABOUT THIS CHANGE, COMMENTS WELCOME! :)

Originally, the API had two methods, `when` and `until`, to cater for the different cases of conditional invocation and repeated invocation.

However, when it came to writing the docs, I suddenly realised that I wasn't catering for the case where someone might need to invoke both conditionally and repeatedly. That behaviour could be achieved by composing something out of separate calls to `when` and `until`, but it seems like that is an unnecessary barrier to entry.

This change, then, reduces the surface area of the API by replacing those two methods with `exec`, which itself accepts two predicates named `when` and `until`. Thus the aggregate behaviour is now possible with a single call to the library.

Subjectively that seems like an improvement to me, although `trier.exec` doesn't quite read as well as `trier.when` and `trier.until`. I'd very much appreciate other people's advice if they have time to furnish it.