npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@mlhaufe/comb-inheritance

v1.0.0

Published

A JavaScript implementation of Comb Inheritance inspired by NewtonScript

Readme

comb-inheritance

A JavaScript implementation of Comb Inheritance inspired by NewtonScript.

Overview

Comb-Inheritance provides a form of multiple inheritance with two paths:

  1. Native JavaScript prototype chain - Replaces NewtonScript's _proto
  2. Parent instance chain via _parent - NewtonScript's _parent concept

Lookup Order

When accessing a property, the lookup follows this order:

  1. Own properties
  2. Prototype chain (JavaScript's native mechanism via extends)
  3. Parent instance chain (custom via Proxy)

Installation

npm install @mlhaufe/comb-inheritance

Usage

import { Component } from '@mlhaufe/comb-inheritance'

class MyClass extends Component {
    // Your class implementation
}

// Create an instance with a parent
const parentInstance = new MyClass()
const childInstance = new MyClass(parentInstance)

// The child can access properties from:
// 1. Its own properties
// 2. MyClass.prototype chain (via extends)
// 3. The parent instance (via parent parameter)

Example: Logger Chain with Super Delegation

import { Component } from '@mlhaufe/comb-inheritance'

class InfoLogger extends Component {
    log(request) {
        return request.level === 1
            ? `Info: ${request.message}`
            : super.log(request) // Delegates to parent instance
    }
}

class WarningLogger extends Component {
    log(request) {
        return request.level === 2
            ? `Warning: ${request.message}`
            : super.log(request)
    }
}

class ErrorLogger extends Component {
    log(request) {
        return request.level === 3
            ? `Error: ${request.message}`
            : super.log(request)
    }
}

// Build the chain
const error = new ErrorLogger()
const warning = new WarningLogger(error)
const info = new InfoLogger(warning)

// Messages bubble through the chain
info.log({ level: 1, message: 'Info message' })
info.log({ level: 2, message: 'Warning message' })
info.log({ level: 3, message: 'Error message' })

Example: Document Hierarchy

import { Component } from '@mlhaufe/comb-inheritance'

class DocTemplate extends Component {
    paperSize = 'standard'
}

class PageTemplate extends DocTemplate {
    topMargin = 1
    bottomMargin = 2
}

// Create a document hierarchy
const myDoc = new DocTemplate()
myDoc.footer = 2

const myPage = new PageTemplate(myDoc)
myPage.leftMargin = 0.75

// Access properties from multiple sources:
console.log(myPage.leftMargin)   // 0.75 (own property)
console.log(myPage.topMargin)    // 1 (from PageTemplate prototype)
console.log(myPage.footer)       // 2 (from parent myDoc instance)
console.log(myPage.paperSize)    // 'standard' (from DocTemplate prototype)

How It Works

  • Prototype Chain (horizontal): Inherited class members and methods via standard JavaScript extends
  • Parent Chain (vertical): Instance-specific properties and behaviors via the constructor's parent parameter

This creates a "comb" structure where:

  • The teeth of the comb are the prototype chains (class hierarchies)
  • The spine of the comb is the parent instance chain (runtime composition)

API

Component

The base class for comb inheritance.

Constructor:

  • new Component(parent = null) - Creates a new component with an optional parent instance

Properties:

  • parent - Getter that returns the parent instance (read-only)

Development

Running Tests

npm test

Requirements

  • Node.js >= 18.0.0

License

AGPL-3.0-only

Author

Michael L Haufe [email protected] (https://thenewobjective.com)

Links