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 🙏

© 2025 – Pkg Stats / Ryan Hefner

cell-type

v0.0.1

Published

Prototypal(OLOO) inheritance algorithm.

Downloads

13

Readme

Build Status Coverage Status Inline docs MIT license

Prototypal(OLOO) inheritance algorithm.

Features

  • Fully tested
  • Fully documented
  • OLOO ready
  • Static & getter/setter inheritance
  • Dynamic prototype & property swapping
  • Supports symbols
  • Validations for overrides, static this usage, illegal private usage
  • Supports attributes! i.e. frozen, static, const etc.
  • Supports amd, node, globals, es6 modules
  • ES6 & ES5 binaries (as well as intermediate version)
  • Made with bits of love!

Installation

bower

bower install cell-type

npm

npm install cell-type

Usage

const Beginner = Type({properties: {
    init(skill)
    {
        this._x = 0;

        this.skills = ['html'];
        if(skill) {this.skills.push(skill)}

        return this
    },
    stringify()
    {
        return 'beginner'
    },
    get x()
    {
        return this._x - 1
    },
    set x(val)
    {
        return this._x = val + 2
    },
    staticMethod() {
    "<$attrs static>";  // attributes can be used to supply additional functionality
    {
        return 'iamstatic'
    }}
}});

const Specialist = Type({links: Beginner, properties: {
    init(skill)
    {
        this._upper(skill);
        this.skills.push('css');

        return this
    }
}});
// using the new keyword is also possible
const Expert = new Type({name: 'Expert', links: Specialist, properties: { // an additional name can be supplied for debugging purposes
    init(skill)
    {
        this._x = 7;

        this._upper(skill);
        this.skills.push('js');

        return this
    },
    stringify()
    {
        return 'expert'
    },
    get x()
    {
        return this._upper() - 3
    },
    set x(val)
    {
        this._x = this._upper(val) + 4
    },
    staticMethod() {
    "<$attrs static enumerable !configurable>";  // attributes can be used to supply additional functionality
    {
        return this._upper()
    }},
    staticProp: {[$attrs]: 'static', value: 10}
}});

const e1 = Object.create(Expert).init('xhtml');

// default inheritance features
expect(e1.skills).to.eql(["html", "xhtml", "css", "js"]);
expect(Beginner.isPrototypeOf(e1)).to.be.true;
expect(Specialist.isPrototypeOf(e1)).to.be.true;
expect(Expert.isPrototypeOf(e1)).to.be.true;

// inheritance for getters/setters
e1.x = 4;
expect(e1._x).to.deep.equal(10);
expect(e1.x).to.deep.equal(6);

// inheritance of static methods
expect(Expert.staticMethod()).to.eql('iamstatic');

// wrapping of static properties
e2 = Object.create(Expert);
e1.staticProp = 20;
expect(e1.staticProp).to.eql(20);
expect(e2.staticProp).to.eql(20);

// using attributes to supply additional functionality
expect(Object.getOwnPropertyDescriptor(Expert, 'init').enumerable).to.be.false; // by default enumerable is set to false
expect(Object.getOwnPropertyDescriptor(Expert, 'init').configurable).to.be.true; // by default configurable is set to true
expect(Object.getOwnPropertyDescriptor(Expert, 'staticMethod').enumerable).to.be.true; // using attributes this can be changed
expect(Object.getOwnPropertyDescriptor(Expert, 'staticMethod').configurable).to.be.false; // using attributes this can be changed

// validations
expect(console.warn.calledWith("[Expert]: No overriding attribute and not calling upper in overriding (value) property 'stringify'.")).to.be.true;

For more usage example see the unit tests @ /test/unit/Type-spec.js

Prototypal(OLOO) inheritance

By default prototypal(OLOO) inheritance is supported. Practically this means that types('classes') created by Type will just be simple objects that can be used as a prototype (no constructor function is supplied). In general I like to avoid any class related jargon. Therefore this._upper (instead of this._super) can be used to access a property higher up in the prototype chain. Statics will be directly available on the prototype. Static properties will be wrapped in a getter/setter so the value can be changed from this.

Documentation

Documentation can be generated by running the command below and is outputted @ /doc.

npm run docs

Make sure you'll run a npm install first.

Future work

  • Traits (coming up in the near future)
  • State properties
  • Dependency injection (in some form or another)