Skip to content

Commit 0a1d3e8

Browse files
Connormihaljharb
authored andcommitted
[Robustness] stringify: avoid relying on a global undefined
1 parent 408ff95 commit 0a1d3e8

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

lib/stringify.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ var stringify = function stringify(
8080
var tmpSc = sideChannel;
8181
var step = 0;
8282
var findFlag = false;
83-
while ((tmpSc = tmpSc.get(sentinel)) !== undefined && !findFlag) {
83+
while ((tmpSc = tmpSc.get(sentinel)) !== void undefined && !findFlag) {
8484
// Where object last appeared in the ref tree
8585
var pos = tmpSc.get(object);
8686
step += 1;
@@ -142,7 +142,7 @@ var stringify = function stringify(
142142
var objKeys;
143143
if (generateArrayPrefix === 'comma' && isArray(obj)) {
144144
// we need to join elements in
145-
objKeys = [{ value: obj.length > 0 ? obj.join(',') || null : undefined }];
145+
objKeys = [{ value: obj.length > 0 ? obj.join(',') || null : void undefined }];
146146
} else if (isArray(filter)) {
147147
objKeys = filter;
148148
} else {
@@ -152,7 +152,7 @@ var stringify = function stringify(
152152

153153
for (var j = 0; j < objKeys.length; ++j) {
154154
var key = objKeys[j];
155-
var value = typeof key === 'object' && key.value !== undefined ? key.value : obj[key];
155+
var value = typeof key === 'object' && typeof key.value !== 'undefined' ? key.value : obj[key];
156156

157157
if (skipNulls && value === null) {
158158
continue;
@@ -192,7 +192,7 @@ var normalizeStringifyOptions = function normalizeStringifyOptions(opts) {
192192
return defaults;
193193
}
194194

195-
if (opts.encoder !== null && opts.encoder !== undefined && typeof opts.encoder !== 'function') {
195+
if (opts.encoder !== null && typeof opts.encoder !== 'undefined' && typeof opts.encoder !== 'function') {
196196
throw new TypeError('Encoder has to be a function.');
197197
}
198198

0 commit comments

Comments
 (0)