1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 | var whenx = (function () {
|
7 | 'use strict';
|
8 |
|
9 | var version = "1.1.3";
|
10 |
|
11 | var thenx= (name, opts= {})=>{
|
12 |
|
13 | return new Promise((resolve, reject)=>{
|
14 | var method= wx[name]( Object.assign(opts, {
|
15 | success: res=> resolve(res)
|
16 | ,fail: err=> reject(err)
|
17 | ,complete: opts.complete
|
18 | }) );
|
19 | if(opts.progress){
|
20 | if(typeof opts.progress== "function"){
|
21 | var task= method;
|
22 | Function.call(opts.progress, task);
|
23 | }
|
24 | else console.warn(`[whenx]progress must be a function to call with task but not: ${typeof(opts.progress)}`);
|
25 | }
|
26 | })
|
27 | };
|
28 |
|
29 | |
30 |
|
31 |
|
32 |
|
33 |
|
34 |
|
35 |
|
36 | var thenx_1= thenx;
|
37 |
|
38 | var thenx$1 = ({
|
39 | default: thenx_1,
|
40 | __moduleExports: thenx_1
|
41 | });
|
42 |
|
43 | var whenx= function(){
|
44 | var _wx= {};
|
45 | for(var k in wx){
|
46 | if(typeof wx[k] === 'function'){
|
47 |
|
48 | _wx[k]= (v)=> thenx_1.call(this, k, v);
|
49 | }
|
50 | else{
|
51 |
|
52 | _wx[k]= wx[k];
|
53 | }
|
54 | }
|
55 | return _wx
|
56 | }();
|
57 |
|
58 | |
59 |
|
60 |
|
61 |
|
62 |
|
63 | var whenx_1= whenx;
|
64 |
|
65 | var whenx$1 = ({
|
66 | default: whenx_1,
|
67 | __moduleExports: whenx_1
|
68 | });
|
69 |
|
70 | var main$1= whenx$1;
|
71 |
|
72 | main$1.whenx= whenx$1;
|
73 | main$1.thenx= thenx$1;
|
74 | main$1._version_= version;
|
75 |
|
76 | return main$1;
|
77 |
|
78 | }());
|