A simple implementation of Promise pattern for JavaScript