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
2
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.1.0
to
0.2.0
+7
.travis.yml
language: node_js
node_js:
- '0.10'
env:
global:
- secure: UOzXsaDRo/x7DYmfkhWHCSMf42tqJY7kuL+YcId8kK84Ffn6UN3FVHQBzIE4Ri7zH3h83lGrjkp8FZeONovRXWC/2HF5idI3FwKDiAFhpRkJvXDH72CcmLr9atMV66WVUWLWUUWbMRL8TNRk5Hhgm/y70fcy+jTYInUyX4X+lqA=
- secure: R0xq3sNFDJRI08/25Vz0cJ14rEo6U/aL3D0J8QkoBb21ZQORqzTL6/3WR3tSnh+X+VKELpjS5L0G4qVgJmFQcQkyBFz+rTkcJHkE/IjO9EMV+P3EAetXirTaHBahcg33i3kOAJl4qCi9b/Y4c3atkt+ooGz3Hc67IEkHddYqp/E=
ui: tape
browsers:
- name: chrome
version: 26..latest
- name: firefox
version: 21..latest
- name: safari
version: 5..latest
- name: ie
version: 6..latest
- name: opera
version: 11..latest
- name: iphone
version: 4.3..latest
- name: ipad
version: 4.3..latest
- name: android
version: 4.0..latest
{
"name": "jsonp",
"main": "index.js",
"version": "0.1.0",
"homepage": "https://github.com/webmodules/jsonp",
"description": "A sane JSONP implementation.",
"keywords": [
"jsonp"
],
"license": "MIT",
"ignore": [
"**/.*",
"node_modules",
"bower_components",
"test",
"tests"
]
}
var jsonp = require('../');
var querystring = require('querystring');
var test = require('tape');
// See http://doc.jsfiddle.net/use/echo.html
var ENDPOINT = 'http://jsfiddle.net/echo/jsonp/';
test('basic jsonp', function (t) {
t.plan(1);
var obj = {
beep: 'boop',
yo: 'dawg'
};
var q = querystring.encode(obj);
jsonp(ENDPOINT + '?' + q, function (err, data) {
if (err) throw err;
t.deepEqual(data, obj);
});
});
test('timeout', function (t) {
t.plan(1);
var obj = {
delay: 5 // time in seconds after which data should be returned
};
var q = querystring.encode(obj);
jsonp(ENDPOINT + '?' + q, { timeout: 3000 }, function (err, data) {
t.ok(err instanceof Error);
});
});
test('named callback', function (t) {
t.plan(1);
var obj = {
beep: 'boop',
yo: 'dawg'
};
var q = querystring.encode(obj);
jsonp(ENDPOINT + '?' + q, { name: 'namedCb' }, function (err, data) {
if (err) throw err;
t.deepEqual(data, obj);
});
});
+8
-0
0.2.0 / 2015-03-18
==================
* add `bower.json`
* add travis/zuul/saucelabs testing
* add support for custom callback `name`
* pin `debug` dep
0.1.0 / 2014-12-30

@@ -3,0 +11,0 @@ ==================

+7
-2

@@ -30,2 +30,4 @@ /**

* - param {String} qs parameter (`callback`)
* - prefix {String} qs parameter (`__jp`)
* - name {String} qs parameter (`prefix` + incr)
* - timeout {Number} how long after a timeout error is emitted (`60000`)

@@ -46,2 +48,7 @@ *

var prefix = opts.prefix || '__jp';
// use the callback name that was passed if one was provided.
// otherwise generate a unique name by incrementing our counter.
var id = opts.name || (prefix + (count++));
var param = opts.param || 'callback';

@@ -54,4 +61,2 @@ var timeout = null != opts.timeout ? opts.timeout : 60000;

// generate a unique id for this request
var id = prefix + (count++);

@@ -58,0 +63,0 @@ if (timeout) {

{
"name": "jsonp",
"description": "A sane JSONP implementation.",
"version": "0.1.0",
"version": "0.2.0",
"dependencies": {
"debug": "*"
"debug": "2.1.3"
},

@@ -16,3 +16,11 @@ "component": {

"url": "https://github.com/LearnBoost/jsonp.git"
},
"devDependencies": {
"tape": "^3.5.0",
"zuul": "^1.17.1"
},
"scripts": {
"test": "zuul -- test/*.js",
"test-local": "zuul --local -- test/*.js"
}
}

@@ -6,2 +6,4 @@

[![saucelabs][saucelabs-image]][saucelabs-url]
## Installation

@@ -21,2 +23,8 @@

Install for browser using `bower`:
``` bash
$ bower install jsonp
```
## API

@@ -34,2 +42,4 @@

handle jsonp responses (defaults to `__jp`)
- `name` (`String`) name of the global callback functions that
handle jsonp responses (defaults to `prefix` + incremented counter)
- `fn` callback

@@ -48,1 +58,4 @@

MIT
[saucelabs-image]: https://saucelabs.com/browser-matrix/jsonp.svg
[saucelabs-url]: https://saucelabs.com/u/jsonp