From 5822596ab8f9f9b659a108e0a7f69d403cc86e41 Mon Sep 17 00:00:00 2001 From: David Majda Date: Tue, 13 Sep 2016 09:09:40 +0200 Subject: [PATCH] Replace classes.subclass with native classes See #442. --- lib/grammar-error.js | 18 ++++++++---------- lib/utils/classes.js | 12 ------------ package.json | 1 - 3 files changed, 8 insertions(+), 23 deletions(-) delete mode 100644 lib/utils/classes.js diff --git a/lib/grammar-error.js b/lib/grammar-error.js index 99c8215..d4905e5 100644 --- a/lib/grammar-error.js +++ b/lib/grammar-error.js @@ -1,18 +1,16 @@ "use strict"; -let classes = require("./utils/classes"); - /* Thrown when the grammar contains an error. */ -function GrammarError(message, location) { - this.name = "GrammarError"; - this.message = message; - this.location = location; +class GrammarError { + constructor(message, location) { + this.name = "GrammarError"; + this.message = message; + this.location = location; - if (typeof Error.captureStackTrace === "function") { - Error.captureStackTrace(this, GrammarError); + if (typeof Error.captureStackTrace === "function") { + Error.captureStackTrace(this, GrammarError); + } } } -classes.subclass(GrammarError, Error); - module.exports = GrammarError; diff --git a/lib/utils/classes.js b/lib/utils/classes.js deleted file mode 100644 index 49c1c45..0000000 --- a/lib/utils/classes.js +++ /dev/null @@ -1,12 +0,0 @@ -"use strict"; - -/* Class utilities */ -let classes = { - subclass: function(child, parent) { - function ctor() { this.constructor = child; } - ctor.prototype = parent.prototype; - child.prototype = new ctor(); - } -}; - -module.exports = classes; diff --git a/package.json b/package.json index 7b42b1a..8372e69 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,6 @@ "lib/parser.js", "lib/peg.js", "lib/utils/arrays.js", - "lib/utils/classes.js", "lib/utils/objects.js", "package.json" ],