@zodash/jsonp
Advanced tools
Comparing version 0.0.3 to 0.0.4
@@ -6,2 +6,10 @@ # Change Log | ||
## [0.0.4](https://github.com/zcorky/zodash/compare/@zodash/jsonp@0.0.3...@zodash/jsonp@0.0.4) (2020-12-16) | ||
**Note:** Version bump only for package @zodash/jsonp | ||
## [0.0.3](https://github.com/zcorky/zodash/compare/@zodash/jsonp@0.0.2...@zodash/jsonp@0.0.3) (2020-12-16) | ||
@@ -8,0 +16,0 @@ |
export interface IOptions { | ||
callbackParam?: string; | ||
callbackName?: string; | ||
@@ -3,0 +4,0 @@ timeout?: number; |
@@ -17,5 +17,6 @@ "use strict"; | ||
function jsonp(url, options) { | ||
var _a; | ||
var _a, _b; | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const timeout = (_a = options === null || options === void 0 ? void 0 : options.timeout) !== null && _a !== void 0 ? _a : 10000; | ||
const callbackParam = (_b = options === null || options === void 0 ? void 0 : options.callbackParam) !== null && _b !== void 0 ? _b : 'callback'; | ||
return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () { | ||
@@ -32,4 +33,11 @@ try { | ||
const _search = url.slice(_q_index); | ||
const _url = `${_prefix}?${add_1.add(_search, { callback: callbackName })}`; | ||
yield load_js_1.loadJs(url, { enableCache: false }); | ||
const _url = `${_prefix}?${add_1.add(_search, { [callbackParam]: callbackName })}`; | ||
let it = setTimeout(() => { | ||
reject(new Error('timeout')); | ||
}, timeout); | ||
yield load_js_1.loadJs(_url, { enableCache: false }); | ||
if (it) { | ||
clearTimeout(it); | ||
it = null; | ||
} | ||
} | ||
@@ -36,0 +44,0 @@ catch (error) { |
{ | ||
"name": "@zodash/jsonp", | ||
"version": "0.0.3", | ||
"version": "0.0.4", | ||
"description": "A simple jsonp function", | ||
@@ -69,6 +69,6 @@ "keywords": [ | ||
"@zcorky/query-string": "^1.0.2", | ||
"@zodash/load-js": "^0.2.6", | ||
"@zodash/load-js": "^0.2.7", | ||
"@zodash/uuid": "^0.1.3" | ||
}, | ||
"gitHead": "e1b3526fc7c629ff86ec38e7d4031facefd11806" | ||
"gitHead": "591a0f9e844b14d64a48343410878c8a3a28dabb" | ||
} |
Sorry, the diff of this file is not supported yet
6620
56
Updated@zodash/load-js@^0.2.7