@dwmt/comlink
Advanced tools
Comparing version 1.0.6 to 1.0.7
@@ -113,18 +113,2 @@ import Cookies from 'js-cookie'; | ||
var retry = function retry(fn) { | ||
var ms = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1000; | ||
var maxRetries = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 10; | ||
return new Promise(function (resolve, reject) { | ||
fn().then(resolve)["catch"](function () { | ||
setTimeout(function () { | ||
if (maxRetries === 0) { | ||
return reject(new Error('maximum retries exceeded')); | ||
} | ||
retry(fn, ms, maxRetries - 1).then(resolve); | ||
}, ms); | ||
}); | ||
}); | ||
}; | ||
function _finallyRethrows(body, finalizer) { | ||
@@ -162,2 +146,32 @@ try { | ||
function getLoader(channel, options) { | ||
var loader = new Loader(); | ||
if (typeof options.loader === 'boolean' && !options.loader) { | ||
return loader; | ||
} | ||
if (typeof options.loader === 'undefined') { | ||
loader = channel.loader; | ||
} | ||
return loader; | ||
} | ||
var retry = function retry(fn) { | ||
var ms = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1000; | ||
var maxRetries = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 10; | ||
return new Promise(function (resolve, reject) { | ||
fn().then(resolve)["catch"](function () { | ||
setTimeout(function () { | ||
if (maxRetries === 0) { | ||
return reject(new Error('maximum retries exceeded')); | ||
} | ||
retry(fn, ms, maxRetries - 1).then(resolve); | ||
}, ms); | ||
}); | ||
}); | ||
}; | ||
function httpStrategy(options) { | ||
@@ -365,2 +379,4 @@ return { | ||
value: function registerChannel(channel) { | ||
console.log('[Comlink]Registering channel to Comlink:', channel); | ||
if (channel.type === 'http') { | ||
@@ -447,3 +463,3 @@ var chn = httpStrategy.call(this, channel); | ||
var channel = _this3._channels[channelName]; | ||
var loader = options.loader || channel.loader; | ||
var loader = getLoader(channel, options); | ||
var errorHandler = options.onError || channel.onError; | ||
@@ -490,3 +506,3 @@ var loaderID = loader.work(); | ||
var channel = _this5._channels[channelName]; | ||
var loader = options.loader || channel.loader; | ||
var loader = getLoader(channel, options); | ||
var errorHandler = options.onError || channel.onError; | ||
@@ -533,3 +549,3 @@ var loaderID = loader.work(); | ||
var channel = _this7._channels[channelName]; | ||
var loader = options.loader || channel.loader; | ||
var loader = getLoader(channel, options); | ||
var errorHandler = options.onError || channel.onError; | ||
@@ -576,3 +592,3 @@ var loaderID = loader.work(); | ||
var channel = _this9._channels[channelName]; | ||
var loader = options.loader || channel.loader; | ||
var loader = getLoader(channel, options); | ||
var errorHandler = options.onError || channel.onError; | ||
@@ -703,3 +719,7 @@ var loaderID = loader.work(); | ||
key: "request", | ||
value: function request(path, data, options, _dialect) { | ||
value: function request(path, data) { | ||
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; | ||
var _dialect = arguments.length > 3 ? arguments[3] : undefined; | ||
try { | ||
@@ -710,3 +730,3 @@ var _this13 = this; | ||
var channel = _this13._channels[channelName]; | ||
var loader = options.loader || channel.loader; | ||
var loader = getLoader(channel, options); | ||
var errorHandler = options.onError || channel.onError; | ||
@@ -737,3 +757,7 @@ var loaderID = loader.work(); | ||
key: "inform", | ||
value: function inform(path, data, options, _dialect) { | ||
value: function inform(path, data) { | ||
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; | ||
var _dialect = arguments.length > 3 ? arguments[3] : undefined; | ||
try { | ||
@@ -744,3 +768,3 @@ var _this15 = this; | ||
var channel = _this15._channels[channelName]; | ||
var loader = options.loader || channel.loader; | ||
var loader = getLoader(channel, options); | ||
var errorHandler = options.onError || channel.onError; | ||
@@ -747,0 +771,0 @@ var loaderID = loader.work(); |
@@ -117,18 +117,2 @@ 'use strict'; | ||
var retry = function retry(fn) { | ||
var ms = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1000; | ||
var maxRetries = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 10; | ||
return new Promise(function (resolve, reject) { | ||
fn().then(resolve)["catch"](function () { | ||
setTimeout(function () { | ||
if (maxRetries === 0) { | ||
return reject(new Error('maximum retries exceeded')); | ||
} | ||
retry(fn, ms, maxRetries - 1).then(resolve); | ||
}, ms); | ||
}); | ||
}); | ||
}; | ||
function _finallyRethrows(body, finalizer) { | ||
@@ -166,2 +150,32 @@ try { | ||
function getLoader(channel, options) { | ||
var loader = new Loader(); | ||
if (typeof options.loader === 'boolean' && !options.loader) { | ||
return loader; | ||
} | ||
if (typeof options.loader === 'undefined') { | ||
loader = channel.loader; | ||
} | ||
return loader; | ||
} | ||
var retry = function retry(fn) { | ||
var ms = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1000; | ||
var maxRetries = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 10; | ||
return new Promise(function (resolve, reject) { | ||
fn().then(resolve)["catch"](function () { | ||
setTimeout(function () { | ||
if (maxRetries === 0) { | ||
return reject(new Error('maximum retries exceeded')); | ||
} | ||
retry(fn, ms, maxRetries - 1).then(resolve); | ||
}, ms); | ||
}); | ||
}); | ||
}; | ||
function httpStrategy(options) { | ||
@@ -369,2 +383,4 @@ return { | ||
value: function registerChannel(channel) { | ||
console.log('[Comlink]Registering channel to Comlink:', channel); | ||
if (channel.type === 'http') { | ||
@@ -451,3 +467,3 @@ var chn = httpStrategy.call(this, channel); | ||
var channel = _this3._channels[channelName]; | ||
var loader = options.loader || channel.loader; | ||
var loader = getLoader(channel, options); | ||
var errorHandler = options.onError || channel.onError; | ||
@@ -494,3 +510,3 @@ var loaderID = loader.work(); | ||
var channel = _this5._channels[channelName]; | ||
var loader = options.loader || channel.loader; | ||
var loader = getLoader(channel, options); | ||
var errorHandler = options.onError || channel.onError; | ||
@@ -537,3 +553,3 @@ var loaderID = loader.work(); | ||
var channel = _this7._channels[channelName]; | ||
var loader = options.loader || channel.loader; | ||
var loader = getLoader(channel, options); | ||
var errorHandler = options.onError || channel.onError; | ||
@@ -580,3 +596,3 @@ var loaderID = loader.work(); | ||
var channel = _this9._channels[channelName]; | ||
var loader = options.loader || channel.loader; | ||
var loader = getLoader(channel, options); | ||
var errorHandler = options.onError || channel.onError; | ||
@@ -707,3 +723,7 @@ var loaderID = loader.work(); | ||
key: "request", | ||
value: function request(path, data, options, _dialect) { | ||
value: function request(path, data) { | ||
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; | ||
var _dialect = arguments.length > 3 ? arguments[3] : undefined; | ||
try { | ||
@@ -714,3 +734,3 @@ var _this13 = this; | ||
var channel = _this13._channels[channelName]; | ||
var loader = options.loader || channel.loader; | ||
var loader = getLoader(channel, options); | ||
var errorHandler = options.onError || channel.onError; | ||
@@ -741,3 +761,7 @@ var loaderID = loader.work(); | ||
key: "inform", | ||
value: function inform(path, data, options, _dialect) { | ||
value: function inform(path, data) { | ||
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; | ||
var _dialect = arguments.length > 3 ? arguments[3] : undefined; | ||
try { | ||
@@ -748,3 +772,3 @@ var _this15 = this; | ||
var channel = _this15._channels[channelName]; | ||
var loader = options.loader || channel.loader; | ||
var loader = getLoader(channel, options); | ||
var errorHandler = options.onError || channel.onError; | ||
@@ -751,0 +775,0 @@ var loaderID = loader.work(); |
{ | ||
"name": "@dwmt/comlink", | ||
"version": "1.0.6", | ||
"version": "1.0.7", | ||
"description": "Communication library for lazy enthusiasts", | ||
@@ -5,0 +5,0 @@ "main": "dist/Comlink.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
66609
1918