MCPcopy
hub / github.com/PokemonGoF/PokemonGo-Bot / wrappy

Function wrappy

map-chat/javascript/browserMqtt.js:1294–1320  ·  view source on GitHub ↗
(fn, cb)

Source from the content-addressed store, hash-verified

1292// decorations and such are not lost along the way.
1293module.exports = wrappy
1294function wrappy (fn, cb) {
1295 if (fn && cb) return wrappy(fn)(cb)
1296
1297 if (typeof fn !== 'function')
1298 throw new TypeError('need wrapper function')
1299
1300 Object.keys(fn).forEach(function (k) {
1301 wrapper[k] = fn[k]
1302 })
1303
1304 return wrapper
1305
1306 function wrapper() {
1307 var args = new Array(arguments.length)
1308 for (var i = 0; i < args.length; i++) {
1309 args[i] = arguments[i]
1310 }
1311 var ret = fn.apply(this, args)
1312 var cb = args[args.length-1]
1313 if (typeof ret === 'function' && ret !== cb) {
1314 Object.keys(cb).forEach(function (k) {
1315 ret[k] = cb[k]
1316 })
1317 }
1318 return ret
1319 }
1320}
1321
1322},{}],9:[function(require,module,exports){
1323var wrappy = require('wrappy')

Callers 1

browserMqtt.jsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected