Skip to content

Commit c3733e3

Browse files
committed
remove .stringify()
1 parent 8e13b6e commit c3733e3

File tree

3 files changed

+2
-54
lines changed

3 files changed

+2
-54
lines changed

README.md

-2
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@ so you never have to check its type.
1818

1919
A drop-in implementation for `require('querystring')`.
2020

21-
### qs.stringify()
22-
2321
### qs.parse()
2422

2523
[npm-image]: https://img.shields.io/npm/v/qs-strict.svg?style=flat-square

index.js

+2-42
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ var methods = [
88
'unescapeBuffer',
99
'unescape',
1010
'escape',
11+
'stringify',
12+
'encode',
1113
];
1214

1315
methods.forEach(function (method) {
@@ -19,47 +21,6 @@ methods.forEach(function (method) {
1921
* As of version: https://github.com/iojs/io.js/blob/10e31ba56c676bdcad39ccad22ea9117733b8eb5/lib/querystring.js
2022
*/
2123

22-
var stringifyPrimitive = function(v) {
23-
if (typeof v === 'string')
24-
return v;
25-
if (typeof v === 'number' && isFinite(v))
26-
return '' + v;
27-
if (typeof v === 'boolean')
28-
return v ? 'true' : 'false';
29-
return '';
30-
};
31-
32-
QueryString.stringify = QueryString.encode = function(obj, sep, eq, options) {
33-
sep = sep || '&';
34-
eq = eq || '=';
35-
36-
var encode = QueryString.escape;
37-
if (options && typeof options.encodeURIComponent === 'function') {
38-
encode = options.encodeURIComponent;
39-
}
40-
41-
if (obj !== null && typeof obj === 'object') {
42-
var keys = Object.keys(obj);
43-
var len = keys.length;
44-
var flast = len - 1;
45-
var fields = '';
46-
for (var i = 0; i < len; ++i) {
47-
var k = keys[i];
48-
var v = obj[k];
49-
var ks = encode(stringifyPrimitive(k)) + eq;
50-
51-
if (Array.isArray(v))
52-
v = v.join(',');
53-
54-
fields += ks + encode(stringifyPrimitive(v));
55-
if (i < flast)
56-
fields += sep;
57-
}
58-
return fields;
59-
}
60-
return '';
61-
};
62-
6324
// Parse a key=val string.
6425
QueryString.parse = QueryString.decode = function(qs, sep, eq, options) {
6526
sep = sep || '&';
@@ -89,7 +50,6 @@ QueryString.parse = QueryString.decode = function(qs, sep, eq, options) {
8950
decode = options.decodeURIComponent;
9051
}
9152

92-
var keys = [];
9353
for (var i = 0; i < len; ++i) {
9454
var x = qs[i].replace(regexp, '%20'),
9555
idx = x.indexOf(eq),

test/test.js

-10
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,6 @@ var assert = require('assert');
44

55
var qs = require('..');
66

7-
describe('.stringify()', function () {
8-
it('should .join(";") arrays', function () {
9-
var string = qs.stringify({
10-
value: [1, 2]
11-
});
12-
13-
assert.equal(string, 'value=' + qs.escape('1,2'));
14-
})
15-
})
16-
177
describe('.parse()', function () {
188
describe('when there are duplicate keys', function () {
199
it('should only use the last value', function () {

0 commit comments

Comments
 (0)