+4
-2
@@ -5,8 +5,10 @@ { | ||
| "description": "A sane JSONP implementation.", | ||
| "version": "0.0.3", | ||
| "version": "0.0.4", | ||
| "dependencies": { | ||
| "visionmedia/debug": "*" | ||
| }, | ||
| "scripts": ["index.js"], | ||
| "scripts": [ | ||
| "index.js" | ||
| ], | ||
| "main": "index.js" | ||
| } |
+10
-0
| 0.0.4 / 2014-03-11 | ||
| ================== | ||
| * simplify the variable name "id" creation logic | ||
| * Readme: add Installation notes | ||
| * fix jshint warnings | ||
| * add repository field to `package.json` | ||
| * fallback to `document.head` if there is not any script tags in the dom | ||
| * remove script safely | ||
| 0.0.3 / 2013-02-03 | ||
@@ -3,0 +13,0 @@ ================== |
+12
-12
@@ -1,2 +0,1 @@ | ||
| /** | ||
@@ -24,3 +23,3 @@ * Module dependencies | ||
| function noop(){}; | ||
| function noop(){} | ||
@@ -44,8 +43,9 @@ /** | ||
| } | ||
| if (!opts) opts = {}; | ||
| var opts = opts || {}; | ||
| var prefix = opts.prefix || '__jp'; | ||
| var param = opts.param || 'callback'; | ||
| var timeout = null != opts.timeout ? opts.timeout : 60000; | ||
| var enc = encodeURIComponent; | ||
| var target = document.getElementsByTagName('script')[0]; | ||
| var target = document.getElementsByTagName('script')[0] || document.head; | ||
| var script; | ||
@@ -55,3 +55,3 @@ var timer; | ||
| // generate a unique id for this request | ||
| var id = count++; | ||
| var id = prefix + (count++); | ||
@@ -61,3 +61,3 @@ if (timeout) { | ||
| cleanup(); | ||
| fn && fn(new Error('Timeout')); | ||
| if (fn) fn(new Error('Timeout')); | ||
| }, timeout); | ||
@@ -67,15 +67,15 @@ } | ||
| function cleanup(){ | ||
| target.parentNode.removeChild(script); | ||
| window['__jp' + id] = noop; | ||
| script.parentNode.removeChild(script); | ||
| window[id] = noop; | ||
| } | ||
| window['__jp' + id] = function(data){ | ||
| window[id] = function(data){ | ||
| debug('jsonp got', data); | ||
| if (timer) clearTimeout(timer); | ||
| cleanup(); | ||
| fn && fn(null, data); | ||
| if (fn) fn(null, data); | ||
| }; | ||
| // add qs component | ||
| url += (~url.indexOf('?') ? '&' : '?') + param + '=' + enc('__jp' + id + ''); | ||
| url += (~url.indexOf('?') ? '&' : '?') + param + '=' + enc(id); | ||
| url = url.replace('?&', '?'); | ||
@@ -89,2 +89,2 @@ | ||
| target.parentNode.insertBefore(script, target); | ||
| }; | ||
| } |
+5
-1
| { | ||
| "name": "jsonp", | ||
| "description": "A sane JSONP implementation.", | ||
| "version": "0.0.3", | ||
| "version": "0.0.4", | ||
| "dependencies": { | ||
@@ -12,3 +12,7 @@ "debug": "*" | ||
| } | ||
| }, | ||
| "repository": { | ||
| "type": "git", | ||
| "url": "https://github.com/LearnBoost/jsonp.git" | ||
| } | ||
| } |
+15
-1
@@ -6,2 +6,16 @@ | ||
| ## Installation | ||
| Install for node.js or browserify using `npm`: | ||
| ``` bash | ||
| $ npm install jsonp | ||
| ``` | ||
| Install for component(1) using `component`: | ||
| ``` bash | ||
| $ component install LearnBoost/jsonp | ||
| ``` | ||
| ## API | ||
@@ -13,3 +27,3 @@ | ||
| - `opts` (`Object`), optional | ||
| - `param` (`String`) name of the query string component to specify | ||
| - `param` (`String`) name of the query string parameter to specify | ||
| the callback (defaults to `callback`) | ||
@@ -16,0 +30,0 @@ - `timeout` (`Number`) how long after a timeout error is emitted. `0` to |
Non-existent author
Supply chain riskThe package was published by an npm account that no longer exists.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
3432
22.27%80
3.9%40
53.85%0
-100%0
-100%