Skip to content

Commit

Permalink
[Refactor] simplify checking for undefined
Browse files Browse the repository at this point in the history
  • Loading branch information
Connormiha committed Dec 27, 2021
1 parent 408ff95 commit 852cab8
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/parse.js
Expand Up @@ -210,13 +210,13 @@ var normalizeParseOptions = function normalizeParseOptions(opts) {
throw new TypeError('Decoder has to be a function.');
}

if (typeof opts.charset !== 'undefined' && opts.charset !== 'utf-8' && opts.charset !== 'iso-8859-1') {
if (opts.charset !== undefined && opts.charset !== 'utf-8' && opts.charset !== 'iso-8859-1') {
throw new TypeError('The charset option must be either utf-8, iso-8859-1, or undefined');
}
var charset = typeof opts.charset === 'undefined' ? defaults.charset : opts.charset;
var charset = opts.charset === undefined ? defaults.charset : opts.charset;

return {
allowDots: typeof opts.allowDots === 'undefined' ? defaults.allowDots : !!opts.allowDots,
allowDots: opts.allowDots === undefined ? defaults.allowDots : !!opts.allowDots,
allowPrototypes: typeof opts.allowPrototypes === 'boolean' ? opts.allowPrototypes : defaults.allowPrototypes,
allowSparse: typeof opts.allowSparse === 'boolean' ? opts.allowSparse : defaults.allowSparse,
arrayLimit: typeof opts.arrayLimit === 'number' ? opts.arrayLimit : defaults.arrayLimit,
Expand All @@ -239,7 +239,7 @@ var normalizeParseOptions = function normalizeParseOptions(opts) {
module.exports = function (str, opts) {
var options = normalizeParseOptions(opts);

if (str === '' || str === null || typeof str === 'undefined') {
if (str === '' || str === null || str === undefined) {
return options.plainObjects ? Object.create(null) : {};
}

Expand Down

0 comments on commit 852cab8

Please sign in to comment.