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

tots

v1.0.1

Published

Compositional inheritance - Make little chunks of mashed together things.

Downloads

6

Readme

tots

Compositional inheritance - Make little chunks of mashed together things.

Premise

  1. Factories should be composable
  2. Any factory should be able to be blended with any other factory.
  3. Factories should be able to be ordered arbitrarily, and produce different results

1. A grayhound is a doggo is an animal.


// An animal factory
var animal = tots.create('animal', function(name){
    this.speed = 10;
});

// How a dog runs.
function run(){
    return 'running at ' + this.speed;
}

// A dog factory
var dog = tots.create('dog', function(name){
    this.name = name;
    this.legs = 4;
    this.good = true;
    this.speed = 30;
    tots.bindMethods(this, { run });
}, [animal]);

// A greyhound factory
var grayhound = tots.create('grayhound', function(name){
    this.speed = 60;
}, [dog]); // <- A greyhound is a dog!

// Make a grayhound
var mia = grayhound('mia');

mia.name -> 'mia'
mia.speed -> 60
mia.run() -> 'running at 60'
tots.is(mia, dog) -> true
tots.is(mia, grayhound) -> true

2. A goanna is a dog lizard.


// How a lizard runs.
function lizardRun(){
    return 'running like a lizard at ' + this.speed;
}

// A Lizard factory
var lizard = tots.create('lizard', function(name){
    this.name = name;
    this.legs = 4;
    this.scaley = true;
    tots.bindMethods(this, { run: lizardRun });
}, [animal]);

// Make a dog
var fluffy = dog('fluffy'); -> looks like a dog.

// Make a lizard
var scaley = lizard('scaley'); -> looks like a lizard.

// A dogLizard factory
var dogLizard = tots.mix('dogLizard', [dog, lizard]);

// Make a dogLizard
var goanna = dogLizard('goanna'); -> looks like a goanna.

tots.is(goanna, dog) -> true // like a dog..
goanna.factory === dog -> false // .. but not.
goanna.good -> true // is a good goanna, yes you are!
goanna.scaley -> true // still scaley

3. dog lizards are not lizard dogs.


// A dogLizard factory
var dogLizard = tots.mix('dogLizard', [dog, lizard]);

// A lizardDog factory
var lizardDog = tots.mix('lizardDog', [lizard, dog]);

// Make a lizard
var larry = lizard('larry'); -> looks like a lizard.

// Make a dogLizard
var goanna = dogLizard('goanna'); -> looks mostly like a lizard.

// Make a lizardDog
var peruvianIncaOrchid = lizardDog('peruvianIncaOrchid'); -> looks mostly like a dog.

larry.run() -> 'runs like a lizard at 10'
goanna.run() -> 'runs like a lizard at 30'
peruvianIncaOrchid.run() -> 'runs at 30'

tots.is(goanna, lizardDog) -> false // not a lizard dog
tots.is(peruvianIncaOrchid, dogLizard) -> false // not a dog lizard