steal source from epub.js and its example "promises"