Skip to content

Commit 6f0586f

Browse files
committed
Change exports usage
1 parent 0e838da commit 6f0586f

File tree

1 file changed

+22
-11
lines changed

1 file changed

+22
-11
lines changed

lib/utils.js

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ var compactQueue = function compactQueue(queue) {
3434
return obj;
3535
};
3636

37-
exports.arrayToObject = function arrayToObject(source, options) {
37+
var arrayToObject = function arrayToObject(source, options) {
3838
var obj = options && options.plainObjects ? Object.create(null) : {};
3939
for (var i = 0; i < source.length; ++i) {
4040
if (typeof source[i] !== 'undefined') {
@@ -45,7 +45,7 @@ exports.arrayToObject = function arrayToObject(source, options) {
4545
return obj;
4646
};
4747

48-
exports.merge = function merge(target, source, options) {
48+
var merge = function merge(target, source, options) {
4949
if (!source) {
5050
return target;
5151
}
@@ -70,14 +70,14 @@ exports.merge = function merge(target, source, options) {
7070

7171
var mergeTarget = target;
7272
if (Array.isArray(target) && !Array.isArray(source)) {
73-
mergeTarget = exports.arrayToObject(target, options);
73+
mergeTarget = arrayToObject(target, options);
7474
}
7575

7676
if (Array.isArray(target) && Array.isArray(source)) {
7777
source.forEach(function (item, i) {
7878
if (has.call(target, i)) {
7979
if (target[i] && typeof target[i] === 'object') {
80-
target[i] = exports.merge(target[i], item, options);
80+
target[i] = merge(target[i], item, options);
8181
} else {
8282
target.push(item);
8383
}
@@ -92,30 +92,30 @@ exports.merge = function merge(target, source, options) {
9292
var value = source[key];
9393

9494
if (has.call(acc, key)) {
95-
acc[key] = exports.merge(acc[key], value, options);
95+
acc[key] = merge(acc[key], value, options);
9696
} else {
9797
acc[key] = value;
9898
}
9999
return acc;
100100
}, mergeTarget);
101101
};
102102

103-
exports.assign = function assignSingleSource(target, source) {
103+
var assign = function assignSingleSource(target, source) {
104104
return Object.keys(source).reduce(function (acc, key) {
105105
acc[key] = source[key];
106106
return acc;
107107
}, target);
108108
};
109109

110-
exports.decode = function (str) {
110+
var decode = function (str) {
111111
try {
112112
return decodeURIComponent(str.replace(/\+/g, ' '));
113113
} catch (e) {
114114
return str;
115115
}
116116
};
117117

118-
exports.encode = function encode(str) {
118+
var encode = function encode(str) {
119119
// This code was originally written by Brian White (mscdex) for the io.js core querystring library.
120120
// It has been adapted here for stricter adherence to RFC 3986
121121
if (str.length === 0) {
@@ -167,7 +167,7 @@ exports.encode = function encode(str) {
167167
return out;
168168
};
169169

170-
exports.compact = function compact(value) {
170+
var compact = function compact(value) {
171171
var queue = [{ obj: { o: value }, prop: 'o' }];
172172
var refs = [];
173173

@@ -189,14 +189,25 @@ exports.compact = function compact(value) {
189189
return compactQueue(queue);
190190
};
191191

192-
exports.isRegExp = function isRegExp(obj) {
192+
var isRegExp = function isRegExp(obj) {
193193
return Object.prototype.toString.call(obj) === '[object RegExp]';
194194
};
195195

196-
exports.isBuffer = function isBuffer(obj) {
196+
var isBuffer = function isBuffer(obj) {
197197
if (obj === null || typeof obj === 'undefined') {
198198
return false;
199199
}
200200

201201
return !!(obj.constructor && obj.constructor.isBuffer && obj.constructor.isBuffer(obj));
202202
};
203+
204+
module.exports = {
205+
arrayToObject: arrayToObject,
206+
assign: assign,
207+
compact: compact,
208+
decode: decode,
209+
encode: encode,
210+
isBuffer: isBuffer,
211+
isRegExp: isRegExp,
212+
merge: merge
213+
};

0 commit comments

Comments
 (0)