From 8c5296ae09b639f279b91cb33403c322fbe21809 Mon Sep 17 00:00:00 2001 From: Kyle Maas Date: Wed, 24 Feb 2021 07:46:31 -0500 Subject: [PATCH 1/3] Fix incompatibility with zii via @rvagg's fix --- src/index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/index.js b/src/index.js index df66bad..8bda372 100644 --- a/src/index.js +++ b/src/index.js @@ -114,9 +114,9 @@ function validEncode (name, buf) { * @throws {Error} Will throw if the encoding is not supported */ function encoding (nameOrCode) { - if (constants.names[/** @type {BaseName} */(nameOrCode)]) { + if (constants.names.hasOwnProperty(/** @type {BaseName} */(nameOrCode))) { return constants.names[/** @type {BaseName} */(nameOrCode)] - } else if (constants.codes[/** @type {BaseCode} */(nameOrCode)]) { + } else if (constants.codes.hasOwnProperty(/** @type {BaseCode} */(nameOrCode))) { return constants.codes[/** @type {BaseCode} */(nameOrCode)] } else { throw new Error(`Unsupported encoding: ${nameOrCode}`) From 1c6e1b99620cf2232f8379fd76a21e15bca0424f Mon Sep 17 00:00:00 2001 From: Kyle Maas Date: Wed, 24 Feb 2021 07:50:46 -0500 Subject: [PATCH 2/3] Remove type casts --- src/index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/index.js b/src/index.js index 8bda372..8533245 100644 --- a/src/index.js +++ b/src/index.js @@ -114,9 +114,9 @@ function validEncode (name, buf) { * @throws {Error} Will throw if the encoding is not supported */ function encoding (nameOrCode) { - if (constants.names.hasOwnProperty(/** @type {BaseName} */(nameOrCode))) { + if (constants.names.hasOwnProperty(nameOrCode)) { return constants.names[/** @type {BaseName} */(nameOrCode)] - } else if (constants.codes.hasOwnProperty(/** @type {BaseCode} */(nameOrCode))) { + } else if (constants.codes.hasOwnProperty(nameOrCode)) { return constants.codes[/** @type {BaseCode} */(nameOrCode)] } else { throw new Error(`Unsupported encoding: ${nameOrCode}`) From 4fc96b264086fe00e6d81492562fccac94f17244 Mon Sep 17 00:00:00 2001 From: Kyle Maas Date: Wed, 24 Feb 2021 07:55:37 -0500 Subject: [PATCH 3/3] Use Object.prototype.hasOwnProperty.call instead so that this passes linting --- src/index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/index.js b/src/index.js index 8533245..a9baaed 100644 --- a/src/index.js +++ b/src/index.js @@ -114,9 +114,9 @@ function validEncode (name, buf) { * @throws {Error} Will throw if the encoding is not supported */ function encoding (nameOrCode) { - if (constants.names.hasOwnProperty(nameOrCode)) { + if (Object.prototype.hasOwnProperty.call(constants.names, /** @type {BaseName} */(nameOrCode))) { return constants.names[/** @type {BaseName} */(nameOrCode)] - } else if (constants.codes.hasOwnProperty(nameOrCode)) { + } else if (Object.prototype.hasOwnProperty.call(constants.codes, /** @type {BaseCode} */(nameOrCode))) { return constants.codes[/** @type {BaseCode} */(nameOrCode)] } else { throw new Error(`Unsupported encoding: ${nameOrCode}`)