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

classifyjs-observer

v0.11.0

Published

Classify-Ovserver is a mutator for Classify.js[https://github.com/weikinhuang/Classify] that allows for simple getters and setters, and on value change events listeners for object properties.

Downloads

8

Readme

Classify-Observer.js

Classify-Ovserver is a mutator for Classify.js[https://github.com/weikinhuang/Classify] that allows for simple getters and setters, and on value change events listeners for object properties.

Classify-Observer is tested in IE 6+, Firefox 2+, Safari 3+, Chrome 3+, and Opera 10+, NodeJs.

Usage

Defining a observable property

var test = Classify({
	__observable_x : 10,
	__observable_y : {
		value : 100,
		get : function(value) {
			return value * 10;
		},
		set : function(value, original) {
			return this.a();
		}
	}
});
var instance = new test();

// test that observers are created
instance.x instanceof Classify.Observer;

// Calling observer from object context.
instance.x.get() === 10;
// Calling observer from object context with defined getter.
instance.y.get() === 1000;
// The return value of setter function is a chain of parent instance.
instance.y.set(10) === instance;
// Calling observer from object context with setter referencing parent function.
instance.y.get() === 10;

// add an event listener
instance.y.addListener(function(value) {
	console.log(value);
});
// event fired
instance.y.set(1);

// test separate instances of instantiated class
var instance2 = new test();
instance.x !== instance2.x; //"Separate instances of classes have different observers.";

Environments

Classify is CommonJS compliant and can be used in the browser scope or the server scope.

In the browser:

<script src="path/to/classify.js" type="text/javascript"></script>
<script src="path/to/classify-observer.js" type="text/javascript"></script>
<!-- Classify() is now in the global context -->

In NodeJs environment:

npm install classifyjs
npm install classifyjs-observer
var Classify = require("classifyjs").Classify;
// only needed once where classifyjs is first required
require("classifyjs-observable");

With an AMD loader like RequireJS:

require({
	"paths" : {
		"classify-observer" : "path/to/classify-observer"
	}
}, [ "classify-observer" ], function(Classify) {
	console.log(Classify.Observer);
});

Building the Source

Classify-Observer uses the grunt build system. Building Classify-Observer requires node.js and a command line gzip program.

# Install grunt.
$ npm install -g grunt-cli

# Clone the Classify-Observer git repo.
$ git clone git://github.com/weikinhuang/Classify-Observer.git
$ cd Classify-Observer
$ git submodule update --init

# Install node modules.
$ npm install

# Run grunt.
$ grunt

Running the tests:

$ grunt test

There are many other tasks that can be run through grunt. For a list of all tasks:

$ grunt --help

Changelog

v0.11.0

Initial split from core Classify[https://github.com/weikinhuang/Classify] mutator

About

Classify copyright 2011-2013 by Wei Kin Huang.

Build Tools: Grunt, QUnit, Benchmark.js, UglifyJS, JsHint, JsCoverage.

All code released under the MIT License.

Fork me to show support and help fix bugs!