Factor out promise utility module 'P', shared with mw-latexer.

Change-Id: Ida24d906a37afa557b9b093f91e4ef038b37d6f1