1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 | var whenx = (function () {
|
7 | 'use strict';
|
8 |
|
9 | var version = "0.2.0";
|
10 |
|
11 | const thenx= (name, opts= {})=>{
|
12 |
|
13 | return new Promise((resolve, reject)=>{
|
14 | const 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 | let 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 | const whenx= function(){
|
44 | let _wx= {};
|
45 | for(let k in wx){
|
46 | if(typeof wx[k] === 'function'){
|
47 |
|
48 | _wx[k]= (v)=> thenx_1.call(this, k, v);
|
49 | }
|
50 | }
|
51 | return _wx
|
52 | }();
|
53 |
|
54 | |
55 |
|
56 |
|
57 |
|
58 |
|
59 | var whenx_1= whenx;
|
60 |
|
61 | var whenx$1 = ({
|
62 | default: whenx_1,
|
63 | __moduleExports: whenx_1
|
64 | });
|
65 |
|
66 | let main$1= whenx$1;
|
67 |
|
68 | main$1.whenx= whenx$1;
|
69 | main$1.thenx= thenx$1;
|
70 | main$1.version= version;
|
71 |
|
72 | return main$1;
|
73 |
|
74 | }());
|