# yiwn-inherit

> Extend functionality and setup prototype chain from subclasses.

Latest version **0.1.0** (published 2014-06-29) · 0 weekly downloads

## Install

```sh
npm install yiwn-inherit
pnpm add yiwn-inherit
yarn add yiwn-inherit
bun add yiwn-inherit
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.0 |
| Published | 2014-06-29 |
| First published | 2014-06-29 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=0.10.0 |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Mushex Antaranian |
| Maintainers | antaranian |
| Keywords | extend, yiwn |

## Links

- npm: https://www.npmjs.com/package/yiwn-inherit
- Repository: http://github.com/yiwn/inherit
- Homepage: https://github.com/yiwn/inherit
- Issues: https://github.com/yiwn/inherit/issues
- npm.io page: https://npm.io/package/yiwn-inherit

## Dependencies (1)

- [yiwn-extend](https://npm.io/package/yiwn-extend.md) ^1.0.1

## Recent versions

- 0.1.0 (latest) — 2014-06-29

## README

# inherit

Inherit functionality and setup prototype chain from subclasses.

## Installation

Using [component](https://github.com/component/component)

    $ component install yiwn/inherit

Using [npm](http://npmjs.org/) for [browserify](http://browserify.org/)

    $ npm install yiwn-inherit

## Usage

Example:

```js
var inherit = require('yiwn-inherit');

function Parent(b){
    this.a = 'Aaa!',
    this.b = b;
    return this;
}

Parent.extend = inherit.bind(null, Parent);

// 
var Child = Parent.extend({
        print: function(){
            console.log(this.a, this.b);
        }
    });

var child = new Child('Boo!');

child.print(); // -> 'Aaa!', 'Boo!'
```

Supports replacement of constructor function as third argument.

```js
var Child = Parent.extend({
        print: function() {
            console.log(this.a, this.b)
        }
    }, init);

function init(b) {
    this.b = b + '!!!';
    return this;
}

var child = new Child('Boo!');

child.print(); // -> undefined, 'Boo!!!!'
```

## Test

Run tests with [mocha](http://visionmedia.github.io/mocha)

    $ make test

## Origins

Script replicates functionality of [Backbone's `.extend`](http://backbonejs.org/docs/backbone.html#section-208), extracted from [Koboldmaki](https://github.com/manuelstofer/koboldmaki).

## License

The MIT License

---
_Source: https://npm.io/package/yiwn-inherit · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
