better-jsonp
Advanced tools
Comparing version 1.0.0 to 1.0.1
/*! | ||
* better-jsonp v0.2.16 | ||
* Copyrights (c) 2018-2018 Bowen (lbwa) | ||
* better-jsonp v1.0.1 | ||
* Copyrights (c) 2018 Bowen (lbwa) | ||
* Released under the MIT License. | ||
@@ -62,3 +62,2 @@ */ | ||
if (!options.url) throw new Error('Please check your request url.'); | ||
// if (!options.callback) throw new Error('Please check your callback parameter.') | ||
@@ -65,0 +64,0 @@ this.options = options; |
/*! | ||
* better-jsonp v0.2.16 | ||
* Copyrights (c) 2018-2018 Bowen (lbwa) | ||
* better-jsonp v1.0.1 | ||
* Copyrights (c) 2018 Bowen (lbwa) | ||
* Released under the MIT License. | ||
@@ -66,3 +66,2 @@ */ | ||
if (!options.url) throw new Error('Please check your request url.'); | ||
// if (!options.callback) throw new Error('Please check your callback parameter.') | ||
@@ -69,0 +68,0 @@ this.options = options; |
/*! | ||
* better-jsonp v0.2.16 | ||
* Copyrights (c) 2018-2018 Bowen (lbwa) | ||
* better-jsonp v1.0.1 | ||
* Copyrights (c) 2018 Bowen (lbwa) | ||
* Released under the MIT License. | ||
*/ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):e.Jsonp=t()}(this,function(){"use strict";function e(){}function t(e,t,n){Reflect.defineProperty(e,t,{enumerable:!1,writable:!0,value:n})}function n(e){return encodeURIComponent(e)}var i=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")},r=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}(),a={timeout:6e3,prefix:"callback",callbackParams:"jsonpCallback",urlParams:{}},l=function(){function l(){i(this,l)}return r(l,[{key:"checkOptions",value:function(e){if(!e.url)throw new Error("Please check your request url.");this.options=e}},{key:"generateJsonpCallback",value:function(e){if(e.jsonpCallback)this._jsonpCallback=e.jsonpCallback;else{var t=a.prefix;this._jsonpCallback=t+Date.now()}}},{key:"defineGlobalCallback",value:function(){var e=this;return new Promise(function(t,n){window[e._jsonpCallback]=function(n){e.cleanScript(),t(n)}})}},{key:"generateTimer",value:function(t){var n=this,i=t.timeout||a.timeout;i&&(this._timer=setTimeout(function(){throw window[n._jsonpCallback]=e,n._timer=null,n.cleanScript(),new Error("JSONP request unsuccessfully (eg.timeout or wrong url).")},i))}},{key:"initState",value:function(e){t(this,"_timer",null),t(this,"_request",null),t(this,"_jsonpCallback",null),t(this,"_insertScript",null),t(this,"_target",null),this.generateJsonpCallback(e),t(this,"_globalCallback",this.defineGlobalCallback()),this.generateTimer(e)}},{key:"encodeURL",value:function(e){var t=this.options.callbackParams||a.callbackParams,i=n(this._jsonpCallback);e+=(e.indexOf("?")<0?"?":"&")+t+"="+i;var r=this.options.urlParams||a.urlParams;Object.keys(r).forEach(function(t){var i=void 0!==r[t]?r[t]:"";e+="&"+t+"="+n(i)}),this._request=e}},{key:"insertToElement",value:function(e){this._target=document.getElementsByTagName("script")[0]||document.body.lastElementChild,this._insertScript=document.createElement("script"),this._insertScript.src=e,this._target.parentNode.insertBefore(this._insertScript,this._target)}},{key:"cleanScript",value:function(){this._insertScript.parentNode&&(this._target.parentNode.removeChild(this._insertScript),this._insertScript=null),window[this._jsonpCallback]=e,this._timer&&clearTimeout(this._timer)}}]),l}();return function(e){var t=new l;return t.checkOptions(e),t.initState(e),t.encodeURL(t.options.url),t.insertToElement(t._request),t._globalCallback}}); |
@@ -13,3 +13,2 @@ import { noop, defineEnumerable, euc } from '../utils/index.js' | ||
if (!options.url) throw new Error('Please check your request url.') | ||
// if (!options.callback) throw new Error('Please check your callback parameter.') | ||
@@ -16,0 +15,0 @@ this.options = options |
{ | ||
"name": "better-jsonp", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "A simple JSONP implementation", | ||
@@ -22,3 +22,3 @@ "main": "dist/better-jsonp.common.js", | ||
"cleaner": "rm -vrf dist/*", | ||
"commit": "git add . && git-cz" | ||
"commit": "yarn run build && git add . && git-cz" | ||
}, | ||
@@ -25,0 +25,0 @@ "repository": { |
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
0
22196
462