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 🙏

© 2024 – Pkg Stats / Ryan Hefner

sooper

v2.2.0

Published

Simple Object Oriented Programming inheritance and implementation framework for JavaScript.

Downloads

2

Readme

sooper

Simple Object Oriented Programming inheritance and implementation framework for JavaScript (unlike some of the Extra Ridiculous complex frameworks out there).

Requirements:

  • ECMAScript 5 features

Why use an inheritance framework at all? ECMAScript 6 will have native class support in 2015, these frameworks will soon be useless!

  • The proposed class implementation in ECMAScript 6 does not provide a way to implement interfaces or mixins.
  • It only allows class functions, not class properties! They have to be put on the instances via the constructor (which uses more memory for every instance) or added to the class after definition.
  • Several of the features in ECMAScript 5+ take several lines of code to implement when a framework could do it in less (e.g. adding properties with non-default descriptors)

Why use this framework?

To help answer that, here is a list of requirements that initially drove the creation of sooper:

  • Keep it simple and efficient
  • Provide a way to define a class that can inherit a super class and implement many interfaces (ala mixin).
  • Do not introduce any unnecessary closure, which allows class instances to be created faster and use less memory.
  • Make it node and browser compatible (based off of the ECMAScript 5 standard).
  • Do not pollute native class prototypes (e.g. do not put any helper methods on Object.prototype)

Current features:

  • class definition via sooper.define
  • class inheritance via inherits property
  • interface implementation (mixin style) via implements property
  • static properties/methods
  • automatic namespace generation
  • quick access to super constructor and super functions
  • builds to a browser friendly version (see releases for minified version)

But those features don't include something the other frameworks have. I wish sooper had those features!

I will add any feature as long as it has 2 important properties: keeps sooper simple and makes class creation easier than native JavaScript. There are a LOT of javascript inheritance frameworks out there. Some of the features in them are not necessary (because native JavaScript is just as easy), some are complex and better suited for complex frameworks (which sooper is not meant to be), and some are definitely useful (makes it much easier than native JavaScript). I would like to add any features that fall under that last category, so if anyone has any particular requests, add them to the github issues for this project.

Usage

###Defining a class Notes:

  • A constructor is optional
  • A class may have an optional namespace 0 or more levels deep ('.' delimited)
  • Property descriptors (configurable, enumerable, writable, etc...) will be preserved
  • Reserved properties:
    • constructor
    • statics
    • inherits
    • implements
    • super

####With auto-generated namespace

sooper.define('app.namespace.TestClass', {
	value: 42,
	getValue: function() { return this.value; }
});

var test = new app.namespace.TestClass();
test.getValue(); //42

####As a module

var TestClass = (function(){
	return sooper.define({
		value: 42,
		getValue: function() { return this.value; }
	});
}();

var test = new TestClass();
test.getValue(); //42

###With statics

var TestClass = sooper.define({
	statics: {
		ANSWER: 42
	}
});

TestClass.ANSWER; //42

###Inheriting a super class

sooper.define('SuperClass', {
	value: 0,
	constructor: function(value) { this.value = value; },
	func: function() { return 1; }
});

sooper.define('TestClass', {
	inherits: SuperClass,
	constructor: function(value) {
		this.super(value);
		this.value++;
	},
	func: function me() {
		return me.super.call(this)+1;
	}
});

var test = new TestClass(41);
test.value; //42
test.func(); //2

###Implementing interfaces

sooper.define('Interface1', {
	func1: function() { return 1; }
});

sooper.define('Interface2', {
	func2: function() { return 2; }
});

sooper.define('TestClass', {
	implements: [Interface1,Interface2],
	func1: function me() {
		return me.super.call(this)+1;
	},
	func2: function me() {
		return me.super.call(this)+2;
	}
});

var test = new TestClass();
test.func1(); //2
test.func2(); //4

###Testing and Building (For development on this project)

This project is configured for Grunt. The first time testing or building, run the following steps on the command line at the root of the project:

npm install -g grunt-cli
npm install

To run the tests (jasmine using PhantomJS set to autoWatch), run:

grunt test

To build sooper.js, run:

grunt build