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

dou

v0.0.11

Published

Light-weight javascript module framework

Downloads

54

Readme

dou

Light-weight javascript module framework (Inspired by flight - A component-based, event-driven JavaScript framework from Twitter http://flightjs.github.io/)

'dou' means ..

  • 都 (all) - Chinese pinyin
  • Do you .. - English

Features

  • Advice
  • Mixin
  • Event
  • Property
  • Life Cycle

Getting Started

It supports packages for nodejs, bower & rails.

As a gem for rails provides:

  • dou-rails

As a package for nodejs provides:

  • dou

As a package for bower provides:

  • dou

Install the nodejs module with:

npm install dou --save

Install the bower module with:

bower install dou --save

Configure for requirejs as follow:

requirejs.config({
	...
	paths: {
		'dou'           : 'bower_components/dou/dou'
	},
	shim: {
		dou: {
			exports: 'dou'
		}
	},
	...
});

Install the rails module with Gemfile

gem "dou-rails"

And run bundle install. The rest of the installation depends on whether the asset pipeline is being used.

Rails 3.1 or greater (with asset pipeline enabled)

The dou-rails files will be added to the asset pipeline and available for you to use. If they're not already in app/assets/javascripts/application.js by default, add these lines:

//= require dou-min

Usage

Define Class

var dou = require('dou');

var Super = dou.define({
	/* members are class members (methods or variable), not instance members */
	members: {
		methodA: function() {...},
		methodB: function() {...}
	}
});

var inst = new Super();

inst.methodA();

Extend


var Clazz = dou.define({
	extend : Super,
	members : {
		methodC: function() {...}
	}
});

var inst = new Clazz();

inst.methodA();
inst.methodB();
inst.methodC();

Constructor


var Clazz = dou.define({
		extend : Super
	}, 
	/* constructor */
	function(arg) {
		// construction goes here
	}
);

var inst = new Clazz(arg);

Mixin


function mixin1() {
	/* 'this' is prototype of Target Class. in this case Clazz.prototype */
	this.methodD = function() { return 'foo'; };
}

function mixin2() {
	/* 'this' is prototype of Target Class. in this case Clazz.prototype */
	this.methodE = function() { return 'bar'; };
}

var Clazz = dou.define({
	extend : Super,
	mixins : [mixin1, mixin2]
});

var inst = new Clazz();

inst.methodD();
inst.methodE();

Advice


function mixin() {
	this.before('methodA', function(arg) {
		/* before logic */
		...
	});
	this.after('methodB', function(arg) {
		/* after logic */
		...
	});
	this.around('methodC', function(origin, arg) {
		/* before logic */
		...
		
		/* origin logic */
		origin(arg);

		/* after logic */
		...
	});
}

var Clazz = dou.define({
	extend : Super,
	/* dou.with.advice should be mixed in. */
	mixins : [dou.with.advice, mixin]
});

var inst = new Clazz();

inst.methodA('abc');

Event


var Clazz = dou.define({
	mixins : [dou.with.event],
	members : {
		test: function(x) {
			this.trigger('test', x);
		}
	}
});

var inst = new Clazz();

inst.on('test', function(e) {
	console.log(e);
});

inst.test(1);

inst.off('test');

Property


var Clazz = dou.define({
	/* dou.with.property includes dou.with.event mixin */
	mixins : [dou.with.property]
});

var inst = new Clazz();

inst.on('change', function(e) {
	console.log(e.before);
	console.log(e.after);
});

inst.set('attr1', 'value1');

inst.set({
	attr1 : 'value1',
	attr2 : 'value2'
});

var val = inst.get('attr1'); // val should be 'value1'

Life Cycle

var Clazz = dou.define({
	/* dou.with.lifecycle includes 2 mixins (dou.with.property and dou.with.event) */
	mixins : [dou.with.lifecycle],
	members : {
		defaults : {
			attr1: 'A',
			attr2: 'B'
		}
	}
});

var inst = new Clazz();
inst.initialize({
	attr2: 'b'
});

var val1 = inst.get('attr1'); // val1 should be 'A'
var val2 = inst.get('attr2'); // val2 should be 'b'

License

Copyright (c) 2014 Hearty, Oh. Licensed under the MIT license.