promisify.js 710 B

123456789101112131415161718
  1. import { __assign } from "tslib";
  2. /*
  3. *@Description: 把所有my.xx的方法变成promise
  4. */
  5. function promisifyMy(name) {
  6. return function (options) {
  7. return new Promise(function (resolve, reject) {
  8. my[name](__assign(__assign({}, options), { success: resolve, fail: reject }));
  9. });
  10. };
  11. }
  12. export var chooseImage = promisifyMy('chooseImage');
  13. export var chooseVideo = promisifyMy('chooseVideo');
  14. export var chooseFileFromDisk = promisifyMy('chooseFileFromDisk');
  15. export var uploadFile = promisifyMy('uploadFile');
  16. export var getFileInfo = promisifyMy('getFileInfo');
  17. export var previewImage = promisifyMy('previewImage');
  18. export var downloadFile = promisifyMy('downloadFile');