npm.io
2.0.3 • Published 10 years ago

inherify

Licence
Version
2.0.3
Deps
0
Vulns
0
Weekly
0
Stars
1

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