Add support for Promise API

Fixes #5