UNPKG

1.31 kBJavaScriptView Raw
1/*
2 whenx v0.1.0
3 https://github.com/cdll/whenx
4 Released under the MIT License.
5*/
6(function () {
7 var version = "0.1.0";
8
9 const whenx= function(){
10 let _wx= {};
11 for(let k in wx){
12 if(typeof wx[k] === 'function'){
13 // console.info(`func: ${k}`)
14 _wx[k]= (v)=> whenx_1$$1.call(this, k, v);
15 }
16 }
17 return _wx
18 }();
19
20 /**
21 * @desc
22 * @module Object
23 * @return {bject}
24 */
25 var whenx_1$$1= whenx;
26
27 var whenx$1 = ({
28 default: whenx_1$$1,
29 __moduleExports: whenx_1$$1
30 });
31
32 const thenx= (name, opts= {})=>{
33 // console.info(`func: ${name}`)
34 return new Promise((resolve, reject)=>{
35 wx[name]( Object.assign(opts, {
36 success: res=> resolve(res)
37 ,fail: err=> reject(err)
38 ,complete: opts.complete
39 }) );
40 })
41 };
42
43 /**
44 * @desc
45 * @module Function
46 * @param {string} name
47 * @param {object} opts
48 * @return {promise}
49 */
50 var thenx_1= thenx;
51
52 var thenx$1 = ({
53 default: thenx_1,
54 __moduleExports: thenx_1
55 });
56
57 let main$1= whenx$1;
58 // console.info(main)
59 main$1.whenx= whenx$1;
60 main$1.thenx= thenx$1;
61 main$1.version= version;
62
63 /**
64 * @desc
65 * @module Object
66 * @return {object}
67 * @member {function} whenx
68 * @member {function} thenx
69 */
70 module.exports= main$1;
71
72}());