The JavaScript blog.


libraries oo touch commonjs

Caress, cjs2web, zoe.js

Posted on .


Caress (GitHub: ekryski / caress-server, License: MIT, npm: caress-server) by Eric Kryski converts TUIO events to browser events (W3C Touch Events version 2), allowing desktop browsers to be driven by multitouch devices. This includes Apple's Magic Trackpad, Android, and iOS devices.

Caress uses Node and Socket.IO to send TUIO messages to the browser -- this is usually done using UDP, but Node and Socket.IO seem to work well. Since Caress can be used with the Magic Trackpad, it might work well as a shortcut for testing touch-based interfaces during development.


cjs2web (GitHub: cjs2web, License: MIT, npm: cjs2web) by Alex Lawrence is a CommonJS module-to-browser translation tool. It currently supports mapping local modules, and the exports object (including module.exports). It doesn't support Node's process and global modules, so it's useful for lightweight porting of browser-friendly code. This is in contrast to something like OneJS that actually aims to create a Node-like environment in the browser.

Jasmine specs are included, and the Grunt build script used to run them.


zoe.js (GitHub: zestjs / zoe, License: MIT, npm: zoe, component: zestjs/zoe) by Guy Bedford is a Node/AMD/browser library for working with multiple inheritance:

The basic principle is that inheritance is a form of object extension. A core object is extended with a number of implemented definitions. When that object is extended, a new object is created implementing the core definitions as well as any new definitions. This is the inheritance system of zoe.create.

Objects created this way can be configured with "function chains", which allows the library to support asynchronous code and various forms of the observer pattern.

Basic object extension uses zoe.create:

var baseClass = {  
  hello: 'world'

var derivedClass = zoe.create([baseClass], {  
  another: 'property'

If an _extend property is supplied, zoe will use it to apply various rules. In this example, chaining is used which will cause both greet methods to run:

var greetClass = {  
  _extend: {
    greet: 'CHAIN'
  greet: function() {
    return 'howdy';

var myClass = zoe.create([greetClass], {  
  greet: function() {



libraries oo databases

BreezeJS, Automaton, dejavu

Posted on .


BreezeJS (GitHub: IdeaBlade / Breeze, License: MIT) by IdeaBlade is a data management library -- it can be used to build queries, track changes, bind to MVC libraries like Knockout, and cache data in the client.

The query interface is like LINQ, but it doesn't specifically require .NET:

var query = breeze.EntityQuery  
           .where('CompanyName', 'startsWith', 'A')

BreezeJS supports asynchronous queries through promises:

var promise = manager.executeQuery(query)  

Although it's open source, the company behind it has commercial support packages. There are also BreezeJS tutorials for getting started. It can work with various SQL and NoSQL databases -- the nature of this and the relationship to the .NET Entity Framework is explained in the BreezeJS FAQ (before complaining about .NET in the comments read the FAQ first).


Automaton (GitHub: IndigoUnited / automaton, License: MIT, npm: automaton) from Indigo United is a task automation tool, similar to Grunt but (from what I can gather) the way tasks are reused works differently.

It's designed to be used with Node and installed through npm, and it has an API for programatically running tasks. The documentation is good, and it makes it clear what parts of the API use streams or other things you can easily hook into with Node.



dejavu (GitHub: IndigoUnited / dejavu, License: MIT, npm: dejavu) also from Indigo United is a classical OO toolkit that can be used with browsers or Node. It can work with AMD, and in that case the syntax reminds me of Backbone projects written using RequireJS.

It supports the usual features: classes, inheritance, mixins, private and protected members, and also adds some type checking tools like method signature checks and a custom instanceOf. The authors have provided benchmarks, which is good, because I've seen too many libraries that say they're fast without any proof.

After writing JS101, which has some coverage of working with prototypes and JavaScript objects in general, seeing "classical OO" libraries makes me extremely wary. However, I've given dejavu a cursory look, and it includes Mocha tests, and takes a wide range of influences into account, so it might be worth adding to your microjs/component library bookmarks for the next time you really need some of the features this library provides. I thought the name "dejavu" was a nod to the plethora of similar libraries out there, but I think it refers to the fact it looks more like OO in other languages.


libraries oo spreadsheets excel presentations

Inverted, controldeck.js, xlsx

Posted on .


Inverted (GitHub: philmander / inverted, License: MIT, npm: inverted) by Phil Mander is an inversion of control container. Used in conjunction with AMD, Inverted uses a separate configuration file to express how classes are instantiated and how they interact. Once these defaults and relationships have been defined, an application context can be created, and instances of the classes can be used.

Phil has provided several examples on the Inverted site that use AMD, but he's also included a CommonJS example that could be used with Node. The API is mostly based around callbacks. For example, fetching an instance is performed with appContext.getProto('name', fn), where fn receives the instance as the first argument.

JavaScript module loading systems such as the CommonJS and AMD manage the loading of your application's dependencies, but they don't actually inject dependencies and wire your code together. Inverted uses a separate application configuration file to define how your Javascript 'classes' interact without needing to add any library specific code within your modules.


One of the controldeck.js demos.

controldeck.js (GitHub: dfcb / controldeck.js, License: MIT) from Draftfcb in Chicago is a small Node web application that provides a remote control for HTML presentations. This offers a simple way of using a mobile phone to control a slideshow.

Socket.IO is used to communicate between the controller and the slides, and the authors have demos running on AppFog.


xlsx (GitHub: Niggler / js-xlsx, License: MIT, npm: xlsx) by Niggler is an implementation of the ISO 29500 Office Open XML specification. The author states that it has been tested with some simple Excel 2011 files, but is still a nascent attempt at supporting the format.

It's designed to work with Node and browsers, and the project's homepage has a browser-based demo. This project was created in response to Stephen Hardy's xlsx.js project -- there was a lengthy discussion on the license of the project which some felt is ambiguous: stephen-hardy / xlsx.js, issue #8: Use a more permissive license.


jquery oo jquery-ui

jQuery Roundup: 1.8.3, UI 1.9.2, oolib.js

Posted on .

Note: You can send your plugins and articles in for review through our contact form or @dailyjs.

jQuery 1.8.3

jQuery 1.8.3 and jQuery Color 2.1.1 are out. There are a few interesting bug fixes in this release that you might want to check out:

jQuery UI 1.9.2

jQuery UI 1.9.2 is out:

This update brings bug fixes for Accordion, Autocomplete, Button, Datepicker, Dialog, Menu, Tabs, Tooltip and Widget Factory.

The 1.9.2 changelog contains a full breakdown of the recent changes.


oolib.js (GitHub: idya / oolib, License: MIT) by Zsolt Szloboda is a JavaScript object-oriented library that is conceptually similar to jQuery UI's Widget Factory. It supports private methods, class inheritance, object initialisation and deinitialisation, super methods, and it's fairly small (min: 1.6K, gz: 0.7K).

It looks like this in practice:

var MyClass = oo.createClass({  
  _create: function(foo) {
    this.myField = foo;

  _myPrivateMethod: function(bar) {
    return this.myField + bar;

  myPublicMethod: function(baz) {
    return this._myPrivateMethod(baz);

var MySubClass = oo.createClass(MyClass, {  
  _myPrivateMethod: function(bar) {
    return this.myField + bar + 1;


language oo backbone.js

Colonne, n8iv, Three Bad Parts

Posted on .


Colonne (GitHub: rtsinani / colonne, License: MIT) by "rtsinani" is a small Backbone.js library that extends Backbone.History to expose two new properties: path and params:

// URL fragment: /products/search?names=apple&names=nectarine&page=1

Backbone.history.path               // 'products/search'  
Backbone.history.params['names']    // ['apple', 'nectarine']  
Backbone.history.params['page']     // '1'  

It also works with Backbone.history.navigateWith.

The author has included Backbone's router tests to demonstrate that Backbone's original functionality still works, and has added new tests for Colonne.


n8iv (License: MIT) by Christos Constandinou is an OO library that extends native objects with Object.defineProperty. The author has written lots of documentation that's viewable on GitHub at constantology / n8iv / docs. The documentation shows what objects have been extended and what the n8iv classes provide.

For example, there's an event library that works like this:

var observer = n8iv.Observer.create();  
observer.log = console.log;

observer.on('foo', log)  
        .on('foo', observer.log, observer)
        .broadcast('foo', 1, 2, 3);

The n8iv.Class library supports mixins, singletons, and super methods.

The author also notes that native methods are not overridden if they're already defined. In addition, the other n8iv libraries like n8iv.Oo.js can be used without the native extensions.

Three Bad Parts

In JavaScript - Only Three "Bad" Parts, John Paul discusses Douglas Crockford's JavaScript:The Good Parts and how there are only really three "bad" parts. His post is actually more about learning the language properly than problems inherent to JavaScript.

John argues that once this, prototypal inheritance, and functions are properly understood, then budding JavaScript developers can be more productive.

When was the last time that you had a really hard time using the void keyword or were foiled by type coercion?