3.0.0 • Published 5 years ago

abstract-class-error v3.0.0

Weekly downloads
1
License
ISC
Repository
-
Last release
5 years ago

AbstractConstructError

An error designed for being thrown when a class is instantiated, an object created, or a method is not overridden that, was intended to be abstract.

import AbstractConstructError from 'abstract-class-error';

class AbstractParent {
    constructor() {
        if (new.target === AbstractParent) {
            throw new AbstractConstructError('Cannot construct class AbstractParent instances directly');
        }

        if (this.abstractMethod === AbstractParent.prototype.abstractMethod) {
            throw new AbstractConstructError('Method "abstractMethod" must be overridden in class AbstractParent');
        }
    }

    abstractMethod() {}
}

Feedback ✉️

Website 🌐

js@jacobsmith.tech

https://github.com/limeandcoconut

@limeandcoconut 🐦

Cheers!

License

ISC, see license for details.

Usage

NPM

License

ISC, see LICENSE.md for details.

3.0.0

5 years ago

2.0.0

5 years ago

1.0.1

9 years ago

1.0.0

9 years ago