inherify

2.0.3 • Public • Published

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

Readme

Keywords

none

Package Sidebar

Install

npm i inherify

Weekly Downloads

2

Version

2.0.3

License

none

Last publish

Collaborators

  • rubeniskov