promisify-wx
Advanced tools
Comparing version 0.1.0 to 0.2.0
39
index.js
@@ -43,17 +43,2 @@ const APIs = [ | ||
const EVENTs = [ | ||
'socketOpen', | ||
'socketError', | ||
'socketMessage', | ||
'socketClose', | ||
'backgroundAudioPlay', | ||
'backgroundAudioPause', | ||
'backgroundAudioStop', | ||
'accelerometerChange', | ||
'compassChange' | ||
]; | ||
const PROXYs = [ | ||
@@ -63,4 +48,13 @@ 'connectSocket', | ||
'closeSocket', | ||
'onSocketOpen', | ||
'onSocketError', | ||
'onSocketMessage', | ||
'onSocketClose', | ||
'createAudioContext', | ||
'createVideoContext', | ||
'onBackgroundAudioPlay', | ||
'onBackgroundAudioPause', | ||
'onBackgroundAudioStop', | ||
'onAccelerometerChange', | ||
'onCompassChange', | ||
'createAnimation', | ||
@@ -74,7 +68,2 @@ 'createContext', | ||
function capitalizeFirstLetter(string) { | ||
return string.charAt(0).toUpperCase() + string.slice(1); | ||
} | ||
let promisifyWx = {}; | ||
@@ -87,3 +76,3 @@ | ||
options.fail = reject; | ||
wx[api].call(options); | ||
wx[api].call(wx, options); | ||
}) | ||
@@ -93,11 +82,5 @@ } | ||
promisifyWx.on = function(eventId, callback) { | ||
if (EVENTs.indexOf(eventId) > -1) { | ||
wx[`on${capitalizeFirstLetter(eventId)}`].call(callback); | ||
} | ||
}; | ||
PROXYs.map((proxyApi) => { | ||
promisifyWx[proxyApi] = function(options) { | ||
return wx[proxyApi].call(options); | ||
return wx[proxyApi].call(wx, options); | ||
} | ||
@@ -104,0 +87,0 @@ }); |
{ | ||
"name": "promisify-wx", | ||
"version": "0.1.0", | ||
"version": "0.2.0", | ||
"description": "promisify wx api ", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
Sorry, the diff of this file is not supported yet
3851
79