From 6d53d893a80332ca3e437a166c5c41b8f30ce63a Mon Sep 17 00:00:00 2001 From: Schuyler Cebulskie Date: Sun, 19 Nov 2017 22:46:38 -0500 Subject: [PATCH] Make Structures.extend static and tweak error messages --- src/util/Structures.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/util/Structures.js b/src/util/Structures.js index 8a22ee703..d118ebb0a 100644 --- a/src/util/Structures.js +++ b/src/util/Structures.js @@ -24,19 +24,19 @@ class Structures { * } * ); */ - extend(name, extender) { + static extend(name, extender) { if (!structures[name]) throw new RangeError(`"${name}" is not a valid extensible structure.`); if (typeof extender !== 'function') { - throw new TypeError('The extender must be a function that returns the extended class.'); + throw new TypeError('The extender must be a function that returns the extended structure class/prototype.'); } const custom = extender(structures[name]); if (typeof custom !== 'function') { - throw new TypeError('The extender function should return the extended class/prototype.'); + throw new TypeError('The extender function must return the extended structure class/prototype.'); } if (Object.getPrototypeOf(custom) !== structures[name]) { throw new Error( - 'The class/prototype returned from the extender function must extend the existing structure class/prototype.' + "The class/prototype returned from the extender function doesn't extend the existing structure class/prototype." ); }