From 60893c0296b98c00c9bcde04a5f1277ac5f13a98 Mon Sep 17 00:00:00 2001 From: Gil Pedersen Date: Tue, 5 Dec 2023 12:32:48 +0100 Subject: [PATCH] Remove typeof property --- lib/index.js | 2 -- test/index.js | 49 ------------------------------------------------- 2 files changed, 51 deletions(-) diff --git a/lib/index.js b/lib/index.js index 00d4454..15897b2 100755 --- a/lib/index.js +++ b/lib/index.js @@ -84,8 +84,6 @@ exports.Boom = class Boom extends Error { Error.captureStackTrace(this, ctor); // Filter the stack to our external API this.#apply(data, statusCode, headers); - - Object.defineProperty(this, 'typeof', { value: ctor }); } static [Symbol.hasInstance](instance) { diff --git a/test/index.js b/test/index.js index 3d68284..34152a5 100755 --- a/test/index.js +++ b/test/index.js @@ -972,55 +972,6 @@ describe('Boom', () => { }); }); - describe('error.typeof', () => { - - const types = [ - 'badRequest', - 'unauthorized', - 'forbidden', - 'notFound', - 'methodNotAllowed', - 'notAcceptable', - 'proxyAuthRequired', - 'clientTimeout', - 'conflict', - 'resourceGone', - 'lengthRequired', - 'preconditionFailed', - 'entityTooLarge', - 'uriTooLong', - 'unsupportedMediaType', - 'rangeNotSatisfiable', - 'expectationFailed', - 'badData', - 'preconditionRequired', - 'tooManyRequests', - 'internal', - 'notImplemented', - 'badGateway', - 'serverUnavailable', - 'gatewayTimeout', - 'badImplementation' - ]; - - types.forEach((name) => { - - it(`matches typeof Boom.${name}`, () => { - - const error = Boom[name](); - types.forEach((type) => { - - if (type === name) { - expect(error.typeof).to.shallow.equal(Boom[name]); - } - else { - expect(error.typeof).to.not.shallow.equal(Boom[type]); - } - }); - }); - }); - }); - describe('reformat()', () => { it('displays internal server error messages in debug mode', () => {