Skip to content

Commit 7d4582d

Browse files
committed
chore(): update README
1 parent b2e7f74 commit 7d4582d

File tree

7 files changed

+17
-35
lines changed

7 files changed

+17
-35
lines changed

.npmignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
test/
21
Makefile
32
.travis.yml
43
logo.png
54
.jshintignore
65
.jshintrc
76
.gitingore
87
coverage/
8+
test/

LICENSE.txt

Lines changed: 0 additions & 21 deletions
This file was deleted.

Makefile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ test-cov cov: install
2626
--timeout $(TIMEOUT) \
2727
$(MOCHA_OPTS) \
2828
$(TESTS)
29-
@./node_modules/.bin/cov coverage
3029

3130
test-travis: install
3231
@NODE_ENV=test node --harmony \

README.md

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,18 @@ app.use(function* () {
4646
});
4747
```
4848

49-
## Options
49+
## API Reference
5050

51-
- __limit__: length limit for callback function name, default to 512
52-
- __replacer__: replacer in `JSON.stringify(obj, [replacer, [space]])`
53-
- __space__: space in `JSON.stringify(obj, [replacer, [space]])`
51+
### #jsonp(obj, callback, options)
52+
53+
Get `obj` jsonp string response with `callback`.
54+
55+
- __obj__: object convert to JSON string
56+
- __callback__: callback function name
57+
- __options__: optional for `JSON.stringify`
58+
- __limit__: length limit for `callback`, default to `512`
59+
- __replacer__: replacer in `JSON.stringify(obj, [replacer, [space]])`
60+
- __space__: space in `JSON.stringify(obj, [replacer, [space]])`
5461

5562
## License
5663

index.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ function jsonp(obj, callback, options) {
2525
options = options || {};
2626
var limit = options.limit || 512;
2727

28+
// replace chars not allowed in JavaScript that are in JSON
2829
// JSON parse vs eval fix. @see https://github.com/rack/rack-contrib/pull/37
2930
var body = JSON.stringify(obj, options.replacer, options.space)
3031
.replace(/\u2028/g, '\\u2028')
@@ -46,5 +47,7 @@ function jsonp(obj, callback, options) {
4647
// @see https://web.nvd.nist.gov/view/vuln/detail?vulnId=CVE-2014-4671
4748
// @see http://miki.it/blog/2014/7/8/abusing-jsonp-with-rosetta-flash/
4849
// @see http://drops.wooyun.org/tips/2554
50+
//
51+
// the typeof check is just to reduce client error noise
4952
return '/**/ typeof ' + cb + ' === \'function\' && ' + cb + '(' + body + ');';
5053
}

package.json

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,16 @@
66
"scripts": {
77
"test": "make test-all"
88
},
9-
"config": {
10-
"cov": {
11-
"threshold": 100
12-
}
13-
},
149
"dependencies": {
1510

1611
},
1712
"devDependencies": {
1813
"autod": "*",
1914
"contributors": "*",
20-
"cov": "*",
2115
"istanbul-harmony": "*",
2216
"jshint": "*",
2317
"mocha": "*",
24-
"should": "~4.0.4"
18+
"should": "~4.2.1"
2519
},
2620
"homepage": "https://github.com/node-modules/jsonp-body",
2721
"repository": {

test/index.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**!
22
* jsonp-body - test/index.test.js
33
*
4-
* Copyright(c) 2014 fengmk2 and other contributors.
4+
* Copyright(c) fengmk2 and other contributors.
55
* MIT Licensed
66
*
77
* Authors:

0 commit comments

Comments
 (0)