Skip to content

Commit

Permalink
[Refactor] Use typeof for compibility with ES3
Browse files Browse the repository at this point in the history
  • Loading branch information
Connormiha committed Dec 27, 2021
1 parent 408ff95 commit de140f3
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/stringify.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ var stringify = function stringify(
var tmpSc = sideChannel;
var step = 0;
var findFlag = false;
while ((tmpSc = tmpSc.get(sentinel)) !== undefined && !findFlag) {
while (typeof (tmpSc = tmpSc.get(sentinel)) !== 'undefined' && !findFlag) {
// Where object last appeared in the ref tree
var pos = tmpSc.get(object);
step += 1;
Expand Down Expand Up @@ -142,7 +142,7 @@ var stringify = function stringify(
var objKeys;
if (generateArrayPrefix === 'comma' && isArray(obj)) {
// we need to join elements in
objKeys = [{ value: obj.length > 0 ? obj.join(',') || null : undefined }];
objKeys = [{ value: obj.length > 0 ? obj.join(',') || null : (void 0) }];
} else if (isArray(filter)) {
objKeys = filter;
} else {
Expand All @@ -152,7 +152,7 @@ var stringify = function stringify(

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

if (skipNulls && value === null) {
continue;
Expand Down Expand Up @@ -192,7 +192,7 @@ var normalizeStringifyOptions = function normalizeStringifyOptions(opts) {
return defaults;
}

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

Expand Down

0 comments on commit de140f3

Please sign in to comment.