qs 6.0.1 → 6.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/parse.js CHANGED
@@ -1,13 +1,8 @@
1
1
  'use strict';
2
2
 
3
- // Load modules
3
+ var Utils = require('./utils');
4
4
 
5
- const Utils = require('./utils');
6
-
7
-
8
- // Declare internals
9
-
10
- const internals = {
5
+ var internals = {
11
6
  delimiter: '&',
12
7
  depth: 5,
13
8
  arrayLimit: 20,
@@ -18,15 +13,13 @@ const internals = {
18
13
  allowDots: false
19
14
  };
20
15
 
21
-
22
16
  internals.parseValues = function (str, options) {
17
+ var obj = {};
18
+ var parts = str.split(options.delimiter, options.parameterLimit === Infinity ? undefined : options.parameterLimit);
23
19
 
24
- const obj = {};
25
- const parts = str.split(options.delimiter, options.parameterLimit === Infinity ? undefined : options.parameterLimit);
26
-
27
- for (let i = 0; i < parts.length; ++i) {
28
- const part = parts[i];
29
- const pos = part.indexOf(']=') === -1 ? part.indexOf('=') : part.indexOf(']=') + 1;
20
+ for (var i = 0; i < parts.length; ++i) {
21
+ var part = parts[i];
22
+ var pos = part.indexOf(']=') === -1 ? part.indexOf('=') : part.indexOf(']=') + 1;
30
23
 
31
24
  if (pos === -1) {
32
25
  obj[Utils.decode(part)] = '';
@@ -34,16 +27,14 @@ internals.parseValues = function (str, options) {
34
27
  if (options.strictNullHandling) {
35
28
  obj[Utils.decode(part)] = null;
36
29
  }
37
- }
38
- else {
39
- const key = Utils.decode(part.slice(0, pos));
40
- const val = Utils.decode(part.slice(pos + 1));
30
+ } else {
31
+ var key = Utils.decode(part.slice(0, pos));
32
+ var val = Utils.decode(part.slice(pos + 1));
41
33
 
42
- if (!Object.prototype.hasOwnProperty.call(obj, key)) {
43
- obj[key] = val;
44
- }
45
- else {
34
+ if (Object.prototype.hasOwnProperty.call(obj, key)) {
46
35
  obj[key] = [].concat(obj[key]).concat(val);
36
+ } else {
37
+ obj[key] = val;
47
38
  }
48
39
  }
49
40
  }
@@ -51,36 +42,31 @@ internals.parseValues = function (str, options) {
51
42
  return obj;
52
43
  };
53
44
 
54
-
55
45
  internals.parseObject = function (chain, val, options) {
56
-
57
46
  if (!chain.length) {
58
47
  return val;
59
48
  }
60
49
 
61
- const root = chain.shift();
50
+ var root = chain.shift();
62
51
 
63
- let obj;
52
+ var obj;
64
53
  if (root === '[]') {
65
54
  obj = [];
66
55
  obj = obj.concat(internals.parseObject(chain, val, options));
67
- }
68
- else {
56
+ } else {
69
57
  obj = options.plainObjects ? Object.create(null) : {};
70
- const cleanRoot = root[0] === '[' && root[root.length - 1] === ']' ? root.slice(1, root.length - 1) : root;
71
- const index = parseInt(cleanRoot, 10);
72
- const indexString = '' + index;
73
- if (!isNaN(index) &&
58
+ var cleanRoot = root[0] === '[' && root[root.length - 1] === ']' ? root.slice(1, root.length - 1) : root;
59
+ var index = parseInt(cleanRoot, 10);
60
+ if (
61
+ !isNaN(index) &&
74
62
  root !== cleanRoot &&
75
- indexString === cleanRoot &&
63
+ String(index) === cleanRoot &&
76
64
  index >= 0 &&
77
- (options.parseArrays &&
78
- index <= options.arrayLimit)) {
79
-
65
+ (options.parseArrays && index <= options.arrayLimit)
66
+ ) {
80
67
  obj = [];
81
68
  obj[index] = internals.parseObject(chain, val, options);
82
- }
83
- else {
69
+ } else {
84
70
  obj[cleanRoot] = internals.parseObject(chain, val, options);
85
71
  }
86
72
  }
@@ -88,37 +74,30 @@ internals.parseObject = function (chain, val, options) {
88
74
  return obj;
89
75
  };
90
76
 
91
-
92
- internals.parseKeys = function (key, val, options) {
93
-
94
- if (!key) {
77
+ internals.parseKeys = function (givenKey, val, options) {
78
+ if (!givenKey) {
95
79
  return;
96
80
  }
97
81
 
98
82
  // Transform dot notation to bracket notation
99
-
100
- if (options.allowDots) {
101
- key = key.replace(/\.([^\.\[]+)/g, '[$1]');
102
- }
83
+ var key = options.allowDots ? givenKey.replace(/\.([^\.\[]+)/g, '[$1]') : givenKey;
103
84
 
104
85
  // The regex chunks
105
86
 
106
- const parent = /^([^\[\]]*)/;
107
- const child = /(\[[^\[\]]*\])/g;
87
+ var parent = /^([^\[\]]*)/;
88
+ var child = /(\[[^\[\]]*\])/g;
108
89
 
109
90
  // Get the parent
110
91
 
111
- let segment = parent.exec(key);
92
+ var segment = parent.exec(key);
112
93
 
113
94
  // Stash the parent if it exists
114
95
 
115
- const keys = [];
96
+ var keys = [];
116
97
  if (segment[1]) {
117
98
  // If we aren't using plain objects, optionally prefix keys
118
99
  // that would overwrite object prototype properties
119
- if (!options.plainObjects &&
120
- Object.prototype.hasOwnProperty(segment[1])) {
121
-
100
+ if (!options.plainObjects && Object.prototype.hasOwnProperty(segment[1])) {
122
101
  if (!options.allowPrototypes) {
123
102
  return;
124
103
  }
@@ -129,13 +108,10 @@ internals.parseKeys = function (key, val, options) {
129
108
 
130
109
  // Loop through children appending to the array until we hit depth
131
110
 
132
- let i = 0;
111
+ var i = 0;
133
112
  while ((segment = child.exec(key)) !== null && i < options.depth) {
134
-
135
- ++i;
136
- if (!options.plainObjects &&
137
- Object.prototype.hasOwnProperty(segment[1].replace(/\[|\]/g, ''))) {
138
-
113
+ i += 1;
114
+ if (!options.plainObjects && Object.prototype.hasOwnProperty(segment[1].replace(/\[|\]/g, ''))) {
139
115
  if (!options.allowPrototypes) {
140
116
  continue;
141
117
  }
@@ -152,10 +128,8 @@ internals.parseKeys = function (key, val, options) {
152
128
  return internals.parseObject(keys, val, options);
153
129
  };
154
130
 
155
-
156
- module.exports = function (str, options) {
157
-
158
- options = options || {};
131
+ module.exports = function (str, opts) {
132
+ var options = opts || {};
159
133
  options.delimiter = typeof options.delimiter === 'string' || Utils.isRegExp(options.delimiter) ? options.delimiter : internals.delimiter;
160
134
  options.depth = typeof options.depth === 'number' ? options.depth : internals.depth;
161
135
  options.arrayLimit = typeof options.arrayLimit === 'number' ? options.arrayLimit : internals.arrayLimit;
@@ -166,22 +140,23 @@ module.exports = function (str, options) {
166
140
  options.parameterLimit = typeof options.parameterLimit === 'number' ? options.parameterLimit : internals.parameterLimit;
167
141
  options.strictNullHandling = typeof options.strictNullHandling === 'boolean' ? options.strictNullHandling : internals.strictNullHandling;
168
142
 
169
- if (str === '' ||
143
+ if (
144
+ str === '' ||
170
145
  str === null ||
171
- typeof str === 'undefined') {
172
-
146
+ typeof str === 'undefined'
147
+ ) {
173
148
  return options.plainObjects ? Object.create(null) : {};
174
149
  }
175
150
 
176
- const tempObj = typeof str === 'string' ? internals.parseValues(str, options) : str;
177
- let obj = options.plainObjects ? Object.create(null) : {};
151
+ var tempObj = typeof str === 'string' ? internals.parseValues(str, options) : str;
152
+ var obj = options.plainObjects ? Object.create(null) : {};
178
153
 
179
154
  // Iterate over the keys and setup the new object
180
155
 
181
- const keys = Object.keys(tempObj);
182
- for (let i = 0; i < keys.length; ++i) {
183
- const key = keys[i];
184
- const newObj = internals.parseKeys(key, tempObj[key], options);
156
+ var keys = Object.keys(tempObj);
157
+ for (var i = 0; i < keys.length; ++i) {
158
+ var key = keys[i];
159
+ var newObj = internals.parseKeys(key, tempObj[key], options);
185
160
  obj = Utils.merge(obj, newObj, options);
186
161
  }
187
162
 
package/lib/stringify.js CHANGED
@@ -1,25 +1,17 @@
1
1
  'use strict';
2
2
 
3
- // Load modules
3
+ var Utils = require('./utils');
4
4
 
5
- const Utils = require('./utils');
6
-
7
-
8
- // Declare internals
9
-
10
- const internals = {
5
+ var internals = {
11
6
  delimiter: '&',
12
7
  arrayPrefixGenerators: {
13
- brackets: function (prefix, key) {
14
-
8
+ brackets: function (prefix) {
15
9
  return prefix + '[]';
16
10
  },
17
11
  indices: function (prefix, key) {
18
-
19
12
  return prefix + '[' + key + ']';
20
13
  },
21
- repeat: function (prefix, key) {
22
-
14
+ repeat: function (prefix) {
23
15
  return prefix;
24
16
  }
25
17
  },
@@ -28,19 +20,15 @@ const internals = {
28
20
  encode: true
29
21
  };
30
22
 
31
-
32
- internals.stringify = function (obj, prefix, generateArrayPrefix, strictNullHandling, skipNulls, encode, filter, sort) {
33
-
23
+ internals.stringify = function (object, prefix, generateArrayPrefix, strictNullHandling, skipNulls, encode, filter, sort, allowDots) {
24
+ var obj = object;
34
25
  if (typeof filter === 'function') {
35
26
  obj = filter(prefix, obj);
36
- }
37
- else if (Utils.isBuffer(obj)) {
38
- obj = obj.toString();
39
- }
40
- else if (obj instanceof Date) {
27
+ } else if (Utils.isBuffer(obj)) {
28
+ obj = String(obj);
29
+ } else if (obj instanceof Date) {
41
30
  obj = obj.toISOString();
42
- }
43
- else if (obj === null) {
31
+ } else if (obj === null) {
44
32
  if (strictNullHandling) {
45
33
  return encode ? Utils.encode(prefix) : prefix;
46
34
  }
@@ -48,90 +36,78 @@ internals.stringify = function (obj, prefix, generateArrayPrefix, strictNullHand
48
36
  obj = '';
49
37
  }
50
38
 
51
- if (typeof obj === 'string' ||
52
- typeof obj === 'number' ||
53
- typeof obj === 'boolean') {
54
-
39
+ if (typeof obj === 'string' || typeof obj === 'number' || typeof obj === 'boolean') {
55
40
  if (encode) {
56
41
  return [Utils.encode(prefix) + '=' + Utils.encode(obj)];
57
42
  }
58
43
  return [prefix + '=' + obj];
59
44
  }
60
45
 
61
- let values = [];
46
+ var values = [];
62
47
 
63
48
  if (typeof obj === 'undefined') {
64
49
  return values;
65
50
  }
66
51
 
67
- let objKeys;
52
+ var objKeys;
68
53
  if (Array.isArray(filter)) {
69
54
  objKeys = filter;
70
- }
71
- else {
72
- const keys = Object.keys(obj);
55
+ } else {
56
+ var keys = Object.keys(obj);
73
57
  objKeys = sort ? keys.sort(sort) : keys;
74
58
  }
75
59
 
76
- for (let i = 0; i < objKeys.length; ++i) {
77
- const key = objKeys[i];
78
-
79
- if (skipNulls &&
80
- obj[key] === null) {
60
+ for (var i = 0; i < objKeys.length; ++i) {
61
+ var key = objKeys[i];
81
62
 
63
+ if (skipNulls && obj[key] === null) {
82
64
  continue;
83
65
  }
84
66
 
85
67
  if (Array.isArray(obj)) {
86
- values = values.concat(internals.stringify(obj[key], generateArrayPrefix(prefix, key), generateArrayPrefix, strictNullHandling, skipNulls, encode, filter));
87
- }
88
- else {
89
- values = values.concat(internals.stringify(obj[key], prefix + '[' + key + ']', generateArrayPrefix, strictNullHandling, skipNulls, encode, filter));
68
+ values = values.concat(internals.stringify(obj[key], generateArrayPrefix(prefix, key), generateArrayPrefix, strictNullHandling, skipNulls, encode, filter, sort, allowDots));
69
+ } else {
70
+ values = values.concat(internals.stringify(obj[key], prefix + (allowDots ? '.' + key : '[' + key + ']'), generateArrayPrefix, strictNullHandling, skipNulls, encode, filter, sort, allowDots));
90
71
  }
91
72
  }
92
73
 
93
74
  return values;
94
75
  };
95
76
 
96
-
97
- module.exports = function (obj, options) {
98
-
99
- options = options || {};
100
- const delimiter = typeof options.delimiter === 'undefined' ? internals.delimiter : options.delimiter;
101
- const strictNullHandling = typeof options.strictNullHandling === 'boolean' ? options.strictNullHandling : internals.strictNullHandling;
102
- const skipNulls = typeof options.skipNulls === 'boolean' ? options.skipNulls : internals.skipNulls;
103
- const encode = typeof options.encode === 'boolean' ? options.encode : internals.encode;
104
- const sort = typeof options.sort === 'function' ? options.sort : null;
105
- let objKeys;
106
- let filter;
77
+ module.exports = function (object, opts) {
78
+ var obj = object;
79
+ var options = opts || {};
80
+ var delimiter = typeof options.delimiter === 'undefined' ? internals.delimiter : options.delimiter;
81
+ var strictNullHandling = typeof options.strictNullHandling === 'boolean' ? options.strictNullHandling : internals.strictNullHandling;
82
+ var skipNulls = typeof options.skipNulls === 'boolean' ? options.skipNulls : internals.skipNulls;
83
+ var encode = typeof options.encode === 'boolean' ? options.encode : internals.encode;
84
+ var sort = typeof options.sort === 'function' ? options.sort : null;
85
+ var allowDots = typeof options.allowDots === 'undefined' ? false : options.allowDots;
86
+ var objKeys;
87
+ var filter;
107
88
  if (typeof options.filter === 'function') {
108
89
  filter = options.filter;
109
90
  obj = filter('', obj);
110
- }
111
- else if (Array.isArray(options.filter)) {
91
+ } else if (Array.isArray(options.filter)) {
112
92
  objKeys = filter = options.filter;
113
93
  }
114
94
 
115
- let keys = [];
116
-
117
- if (typeof obj !== 'object' ||
118
- obj === null) {
95
+ var keys = [];
119
96
 
97
+ if (typeof obj !== 'object' || obj === null) {
120
98
  return '';
121
99
  }
122
100
 
123
- let arrayFormat;
101
+ var arrayFormat;
124
102
  if (options.arrayFormat in internals.arrayPrefixGenerators) {
125
103
  arrayFormat = options.arrayFormat;
126
- }
127
- else if ('indices' in options) {
104
+ } else if ('indices' in options) {
128
105
  arrayFormat = options.indices ? 'indices' : 'repeat';
129
- }
130
- else {
106
+ } else {
131
107
  arrayFormat = 'indices';
132
108
  }
133
109
 
134
- const generateArrayPrefix = internals.arrayPrefixGenerators[arrayFormat];
110
+ var generateArrayPrefix = internals.arrayPrefixGenerators[arrayFormat];
135
111
 
136
112
  if (!objKeys) {
137
113
  objKeys = Object.keys(obj);
@@ -141,16 +117,14 @@ module.exports = function (obj, options) {
141
117
  objKeys.sort(sort);
142
118
  }
143
119
 
144
- for (let i = 0; i < objKeys.length; ++i) {
145
- const key = objKeys[i];
146
-
147
- if (skipNulls &&
148
- obj[key] === null) {
120
+ for (var i = 0; i < objKeys.length; ++i) {
121
+ var key = objKeys[i];
149
122
 
123
+ if (skipNulls && obj[key] === null) {
150
124
  continue;
151
125
  }
152
126
 
153
- keys = keys.concat(internals.stringify(obj[key], key, generateArrayPrefix, strictNullHandling, skipNulls, encode, filter, sort));
127
+ keys = keys.concat(internals.stringify(obj[key], key, generateArrayPrefix, strictNullHandling, skipNulls, encode, filter, sort, allowDots));
154
128
  }
155
129
 
156
130
  return keys.join(delimiter);
package/lib/utils.js CHANGED
@@ -1,28 +1,17 @@
1
1
  'use strict';
2
2
 
3
- // Load modules
4
-
5
-
6
- // Declare internals
7
-
8
- const internals = {};
9
-
10
-
11
- internals.hexTable = function () {
12
-
13
- const array = new Array(256);
14
- for (let i = 0; i < 256; ++i) {
3
+ var hexTable = (function () {
4
+ var array = new Array(256);
5
+ for (var i = 0; i < 256; ++i) {
15
6
  array[i] = '%' + ((i < 16 ? '0' : '') + i.toString(16)).toUpperCase();
16
7
  }
17
8
 
18
9
  return array;
19
- }();
20
-
10
+ }());
21
11
 
22
12
  exports.arrayToObject = function (source, options) {
23
-
24
- const obj = options.plainObjects ? Object.create(null) : {};
25
- for (let i = 0; i < source.length; ++i) {
13
+ var obj = options.plainObjects ? Object.create(null) : {};
14
+ for (var i = 0; i < source.length; ++i) {
26
15
  if (typeof source[i] !== 'undefined') {
27
16
  obj[i] = source[i];
28
17
  }
@@ -31,9 +20,7 @@ exports.arrayToObject = function (source, options) {
31
20
  return obj;
32
21
  };
33
22
 
34
-
35
23
  exports.merge = function (target, source, options) {
36
-
37
24
  if (!source) {
38
25
  return target;
39
26
  }
@@ -41,116 +28,100 @@ exports.merge = function (target, source, options) {
41
28
  if (typeof source !== 'object') {
42
29
  if (Array.isArray(target)) {
43
30
  target.push(source);
44
- }
45
- else if (typeof target === 'object') {
31
+ } else if (typeof target === 'object') {
46
32
  target[source] = true;
47
- }
48
- else {
49
- target = [target, source];
33
+ } else {
34
+ return [target, source];
50
35
  }
51
36
 
52
37
  return target;
53
38
  }
54
39
 
55
40
  if (typeof target !== 'object') {
56
- target = [target].concat(source);
57
- return target;
41
+ return [target].concat(source);
58
42
  }
59
43
 
60
- if (Array.isArray(target) &&
61
- !Array.isArray(source)) {
62
-
63
- target = exports.arrayToObject(target, options);
44
+ var mergeTarget = target;
45
+ if (Array.isArray(target) && !Array.isArray(source)) {
46
+ mergeTarget = exports.arrayToObject(target, options);
64
47
  }
65
48
 
66
- const keys = Object.keys(source);
67
- for (let i = 0; i < keys.length; ++i) {
68
- const key = keys[i];
69
- const value = source[key];
49
+ return Object.keys(source).reduce(function (acc, key) {
50
+ var value = source[key];
70
51
 
71
- if (!Object.prototype.hasOwnProperty.call(target, key)) {
72
- target[key] = value;
73
- }
74
- else {
75
- target[key] = exports.merge(target[key], value, options);
52
+ if (Object.prototype.hasOwnProperty.call(acc, key)) {
53
+ acc[key] = exports.merge(acc[key], value, options);
54
+ } else {
55
+ acc[key] = value;
76
56
  }
77
- }
78
-
79
- return target;
57
+ return acc;
58
+ }, mergeTarget);
80
59
  };
81
60
 
82
-
83
61
  exports.decode = function (str) {
84
-
85
62
  try {
86
63
  return decodeURIComponent(str.replace(/\+/g, ' '));
87
- }
88
- catch (e) {
64
+ } catch (e) {
89
65
  return str;
90
66
  }
91
67
  };
92
68
 
93
69
  exports.encode = function (str) {
94
-
95
70
  // This code was originally written by Brian White (mscdex) for the io.js core querystring library.
96
71
  // It has been adapted here for stricter adherence to RFC 3986
97
72
  if (str.length === 0) {
98
73
  return str;
99
74
  }
100
75
 
101
- if (typeof str !== 'string') {
102
- str = '' + str;
103
- }
76
+ var string = typeof str === 'string' ? str : String(str);
104
77
 
105
- let out = '';
106
- for (let i = 0; i < str.length; ++i) {
107
- let c = str.charCodeAt(i);
78
+ var out = '';
79
+ for (var i = 0; i < string.length; ++i) {
80
+ var c = string.charCodeAt(i);
108
81
 
109
- if (c === 0x2D || // -
82
+ if (
83
+ c === 0x2D || // -
110
84
  c === 0x2E || // .
111
85
  c === 0x5F || // _
112
86
  c === 0x7E || // ~
113
87
  (c >= 0x30 && c <= 0x39) || // 0-9
114
88
  (c >= 0x41 && c <= 0x5A) || // a-z
115
- (c >= 0x61 && c <= 0x7A)) { // A-Z
116
-
117
- out = out + str[i];
89
+ (c >= 0x61 && c <= 0x7A) // A-Z
90
+ ) {
91
+ out += string.charAt(i);
118
92
  continue;
119
93
  }
120
94
 
121
95
  if (c < 0x80) {
122
- out = out + internals.hexTable[c];
96
+ out = out + hexTable[c];
123
97
  continue;
124
98
  }
125
99
 
126
100
  if (c < 0x800) {
127
- out = out + (internals.hexTable[0xC0 | (c >> 6)] + internals.hexTable[0x80 | (c & 0x3F)]);
101
+ out = out + (hexTable[0xC0 | (c >> 6)] + hexTable[0x80 | (c & 0x3F)]);
128
102
  continue;
129
103
  }
130
104
 
131
105
  if (c < 0xD800 || c >= 0xE000) {
132
- out = out + (internals.hexTable[0xE0 | (c >> 12)] + internals.hexTable[0x80 | ((c >> 6) & 0x3F)] + internals.hexTable[0x80 | (c & 0x3F)]);
106
+ out = out + (hexTable[0xE0 | (c >> 12)] + hexTable[0x80 | ((c >> 6) & 0x3F)] + hexTable[0x80 | (c & 0x3F)]);
133
107
  continue;
134
108
  }
135
109
 
136
- ++i;
137
- c = 0x10000 + (((c & 0x3FF) << 10) | (str.charCodeAt(i) & 0x3FF));
138
- out = out + (internals.hexTable[0xF0 | (c >> 18)] + internals.hexTable[0x80 | ((c >> 12) & 0x3F)] + internals.hexTable[0x80 | ((c >> 6) & 0x3F)] + internals.hexTable[0x80 | (c & 0x3F)]);
110
+ i += 1;
111
+ c = 0x10000 + (((c & 0x3FF) << 10) | (string.charCodeAt(i) & 0x3FF));
112
+ out += (hexTable[0xF0 | (c >> 18)] + hexTable[0x80 | ((c >> 12) & 0x3F)] + hexTable[0x80 | ((c >> 6) & 0x3F)] + hexTable[0x80 | (c & 0x3F)]);
139
113
  }
140
114
 
141
115
  return out;
142
116
  };
143
117
 
144
- exports.compact = function (obj, refs) {
145
-
146
- if (typeof obj !== 'object' ||
147
- obj === null) {
148
-
118
+ exports.compact = function (obj, references) {
119
+ if (typeof obj !== 'object' || obj === null) {
149
120
  return obj;
150
121
  }
151
122
 
152
- refs = refs || [];
153
- const lookup = refs.indexOf(obj);
123
+ var refs = references || [];
124
+ var lookup = refs.indexOf(obj);
154
125
  if (lookup !== -1) {
155
126
  return refs[lookup];
156
127
  }
@@ -158,9 +129,9 @@ exports.compact = function (obj, refs) {
158
129
  refs.push(obj);
159
130
 
160
131
  if (Array.isArray(obj)) {
161
- const compacted = [];
132
+ var compacted = [];
162
133
 
163
- for (let i = 0; i < obj.length; ++i) {
134
+ for (var i = 0; i < obj.length; ++i) {
164
135
  if (typeof obj[i] !== 'undefined') {
165
136
  compacted.push(obj[i]);
166
137
  }
@@ -169,31 +140,23 @@ exports.compact = function (obj, refs) {
169
140
  return compacted;
170
141
  }
171
142
 
172
- const keys = Object.keys(obj);
173
- for (let i = 0; i < keys.length; ++i) {
174
- const key = keys[i];
143
+ var keys = Object.keys(obj);
144
+ for (var j = 0; j < keys.length; ++j) {
145
+ var key = keys[j];
175
146
  obj[key] = exports.compact(obj[key], refs);
176
147
  }
177
148
 
178
149
  return obj;
179
150
  };
180
151
 
181
-
182
152
  exports.isRegExp = function (obj) {
183
-
184
153
  return Object.prototype.toString.call(obj) === '[object RegExp]';
185
154
  };
186
155
 
187
-
188
156
  exports.isBuffer = function (obj) {
189
-
190
- if (obj === null ||
191
- typeof obj === 'undefined') {
192
-
157
+ if (obj === null || typeof obj === 'undefined') {
193
158
  return false;
194
159
  }
195
160
 
196
- return !!(obj.constructor &&
197
- obj.constructor.isBuffer &&
198
- obj.constructor.isBuffer(obj));
161
+ return !!(obj.constructor && obj.constructor.isBuffer && obj.constructor.isBuffer(obj));
199
162
  };