Implementation of EcmaScript6 promises