UNPKG

1.57 kBJavaScriptView Raw
1/*
2 whenx v1.1.3
3 https://github.com/cdll/whenx
4 Released under the MIT License.
5*/
6var whenx = (function () {
7 'use strict';
8
9 var version = "1.1.3";
10
11 var thenx= (name, opts= {})=>{
12 // console.info(`func: ${name}`)
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 * @desc
31 * @module Function
32 * @param {string} name
33 * @param {object} opts
34 * @return {promise}
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 // console.info(`func: ${k}`)
48 _wx[k]= (v)=> thenx_1.call(this, k, v);
49 }
50 else{
51 // console.info(`val: ${k}`)
52 _wx[k]= wx[k];
53 }
54 }
55 return _wx
56 }();
57
58 /**
59 * @desc
60 * @module Object
61 * @return {bject}
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 // console.info(main)
72 main$1.whenx= whenx$1;
73 main$1.thenx= thenx$1;
74 main$1._version_= version;
75
76 return main$1;
77
78}());