Blame view

node_modules/we-cropper/src/utils/promisify.js 532 Bytes
ce4c83ff   wxy   初始提交
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
  export function wxPromise (fn) {
    return function (obj = {}, ...args) {
      return new Promise((resolve, reject) => {
        obj.success = function (res) {
          resolve(res)
        }
        obj.fail = function (err) {
          reject(err)
        }
        fn(obj, ...args)
      })
    }
  }
  
  export function draw (ctx, reserve = false) {
    return new Promise((resolve) => {
      ctx.draw(reserve, resolve)
    })
  }
  
  export const getImageInfo = wxPromise(wx.getImageInfo)
  
  export const canvasToTempFilePath = wxPromise(wx.canvasToTempFilePath)