JS Promises/A+ implementation