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

ryoc

v0.0.3

Published

Simple nonintrusive javascript prototypical inheritance through fluent api

Readme

Build Status

ryoc

$ npm install ryoc

Simple nonintrusive javascript prototypical inheritance through fluent api.

Works in node. No guarantees for other environments.

##Quick syntax

var klass = require('ryoc')()
    .inherit([Object|Function])
    .construct([Function])
    .mixin([Object|Array of Object, ...])
    .method([name],[Function])
    .abstract([name])
    .property([name],[default value = undefined],[readonly = false])
    .getter([name],[Function])
    .setter([name],[Function])
    .toClass();

var instance = new klass([constructor arguments]);
var other = klass([constructor arguments]);

abstract(name) is a convenience method for method(name, function (){ throw new TypeError(....

Order of application in toClass():

  1. mixin()
  2. method()
  3. property() / getter() / setter() merged by name
  4. construct()

##Annotated sample code


var ryoc = require('ryoc');
  
// Define base class for shapes
var Shape = ryoc()
    // Define a propery with a backing field
    .property('geometry', '[generic shape]')
    // Define a readonly property that is evaluated by a function
    .getter('area', function () { return this.calculateArea(); })
    // Define a method. calculateArea in this case mimics an abstract method
    .method('calculateArea', function () { throw new Error('method calculateArea is not implemented');})
    // dump calls 'virtual' functions in descendants
    .method('dump', function () { console.log('%s (%j), area is %s', this.geometry, this, this.area) })
    // Construct a new class
    .toClass();
                                        
// Circular shapes
// - a Circle is a Shape
// - a Circle must be initialized with a radius
// - Circles have a special formula for area 
var Circle = ryoc()
    .inherit(Shape)
    .construct(function (radius) {
        Shape.call(this); // always nice to initialize base class
        this.geometry = 'circle'; 
        this.radius = radius; 
    })
    .method('calculateArea', function () { return Math.PI * this.radius * this.radius; })
    .toClass();

// Rectangular shapes
// - a Rectangel is a Shape
// - a Rectangle must be initialized with width and height
// - Rectangles have a special formula for area 
var Rectangle = ryoc()
    .inherit(Shape)
   .construct(function (width, height) {
        Shape.call(this); // Construct base class
        this.geometry = 'rectangle'; 
        this.w = width; 
        this.h = height; 
    })
    .method('calculateArea', function () { return this.w * this.h; })
    .toClass();

// Create a circle and let it tell something about itself
new Circle(1).dump();
// Create a rectangle and let it tell something about itself
new Rectangle(2,3).dump();

// Create another circle. Notice how we can skip the new keyword
Circle(1).dump();

What ryoc doesnt do

  • mimic class semantics from other languages. In fact, the concept of classes in Javascript is quite meaningless.
  • constructors in base classes are not automatically applied - this will be your responsibility
  • introduce alien and weird meta stuff like $super. The only things in generated classes are what you explicitly put there.