Helper functions for prototypical inheritance in JavaScript
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.

Heir npm

Helper functions for prototypical inheritance in JavaScript.

Use the source code and JSDoc comments as documentation, here's a quick example to get you started.

const heir = require('heir')

// Create the base class.
function Base() {}

// Add a method. = function () {
  return 'Base#foo'

// Create a sub class which inherits from base.
function Sub() {}
heir.inherit(Sub, Base)

// Mix in some functionality enhancing objects.
heir.mixin(Sub, events)
heir.mixin(Sub, pooling)

// Change the original method. = function () {
  return [
  ].join(', ')

// Create an instance of Sub and call it's method.
const s = new Sub() // Returns "Sub#foo, Base#foo"


This project is given to you under the unlicense, as documented in the UNLICENSE file in this directory. Enjoy.