2.0.3 • Published 8 years ago

inherify v2.0.3

Weekly downloads
3
License
-
Repository
github
Last release
8 years ago

Inherify

Build Status Coverage Status Slack Status Version Downloads Node License

Issues Open Issue Resolution

Inherify is a function constructor to make easy and clean inherits prototypes.

NPM GRID

Installation

Install with npm install inherify --save.

Usage

To use, add the require node module:

    const Inherify = require('inherify');

    const CustomError = Inherify(Error, {
        __constructor: function(settings) {
            settings = typeof(settings) === 'string' ? {
                message: settings
            } : settings || {};
            this.name = 'CustomError';
            this.type = settings.type || 'Application';
            this.message = settings.message || 'An error occurred.';
            this.detail = settings.detail || '';
            this.extendedInfo = settings.extendedInfo || '';
            this.errorCode = settings.errorCode || '';
            Error.captureStackTrace(this, CustomError);
        }
    });

    throw new CustomError('Custom error raised!');

WTF