qs 6.0.0 → 6.0.4

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