Latest Threat Research:SANDWORM_MODE: Shai-Hulud-Style npm Worm Hijacks CI Workflows and Poisons AI Toolchains.Details
Socket
Book a DemoInstallSign in
Socket

jsonp

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jsonp - npm Package Compare versions

Comparing version
0.0.3
to
0.0.4
+4
-2
component.json

@@ -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"
}
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);
};
}
{
"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"
}
}

@@ -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