From 001134b10e7ff73c4892e1adf2242a4e4adfc345 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jimmy=20Wa=CC=88rting?= Date: Sat, 13 Nov 2021 01:27:13 +0100 Subject: [PATCH] remove inherits --- test/fixtures/internal-error.js | 6 +----- test/fixtures/nested-errors.js | 20 ++++++++++---------- 2 files changed, 11 insertions(+), 15 deletions(-) diff --git a/test/fixtures/internal-error.js b/test/fixtures/internal-error.js index 109dc6e..b4b2b4b 100644 --- a/test/fixtures/internal-error.js +++ b/test/fixtures/internal-error.js @@ -1,12 +1,8 @@ 'use strict'; const NestedError = require('nested-error-stacks'); -const util = require('util'); -function InternalError(message, nested) { - NestedError.call(this, message, nested); -} +class InternalError extends NestedError {} -util.inherits(InternalError, NestedError); InternalError.prototype.name = 'InternalError'; module.exports = function (cb, err) { diff --git a/test/fixtures/nested-errors.js b/test/fixtures/nested-errors.js index 034d957..7c43f79 100644 --- a/test/fixtures/nested-errors.js +++ b/test/fixtures/nested-errors.js @@ -1,9 +1,9 @@ 'use strict'; const NestedError = require('nested-error-stacks'); -const util = require('util'); const internal = require('./internal-error'); + function foo(cb) { bar(function nested(err) { cb(new FooError(`foo${err.message}`, err)); @@ -16,20 +16,20 @@ function bar(cb) { }); } -function FooError(message, nested) { - NestedError.call(this, message, nested); -} - -util.inherits(FooError, NestedError); +class FooError extends NestedError {} FooError.prototype.name = 'FooError'; -function BarError(message, nested) { - NestedError.call(this, message, nested); -} -util.inherits(BarError, NestedError); + + + +class BarError extends NestedError {} BarError.prototype.name = 'BarError'; + + + + module.exports.top = function(cb) { internal(function (err) { cb(err.stack);