JavaScript utility for expressing the chain of calls pattern