The JavaScript blog.


node modules linux data structures trees

Node Roundup: 0.10.13, Node Linux, Tree Model

Posted on .

You can send in your Node projects for review through our contact form.

Node 0.10.13

Node 0.10.13 was released yesterday. Updates include libuv, npm, and fixes for the following core modules: tls, http, zlib, and buffer.

Node Linux

Corey Butler sent in node-linux (GitHub: coreybutler / node-linux, License: MIT, npm: node-linux), which is a follow up to node-windows and node-mac. The Mac and Windows versions provided an integration layer for working with OS-specific features like event logging and service management. The Linux version creates System V init.d files that run Node scripts and daemons.

The author is planning to add systemd and upstart script generation, and notes in the readme that he'd like contributions in those areas if possible.



tree-model-js (GitHub: joaonuno / tree-model-js, License: MIT, npm: tree-model) by Joao Nuno Silva is a module for manipulating and traversing tree-like structures. It's available for Node, but also supports browsers and AMD.

Trees can be defined with a JSON-friendly syntax:

var tree = new TreeModel();  
var root = tree.parse({  
  id: 1,
  children: [{
      id: 11,
      children: [{id: 111}]
    }, {
      id: 12,
      children: [{id: 121}, {id: 122}]
    }, {
      id: 13

Nodes can then be traversed with .walk, removed with .drop, and added with .addChild.


testing node modules ETL linux fs

Node Roundup: Mocha, Banzai, Inotify

Posted on .

You can send your Node modules and articles in for review through our [contact form](/contact.html) or [@dailyjs](http://twitter.com/dailyjs).


Mocha (GitHub: visionmedia / mocha, License: MIT, npm:
mocha) by TJ Holowaychuk is a new test framework that works both in Node and browsers. It runs tests serially, making it intuitive, and
includes a huge collection of reporters including a TAP reporter. It
even comes with a sane setup/teardown implementation, allowing code to
be run before and after each test or the whole suite.

Like other test frameworks, Mocha uses an asynchronous "done" function.
However, calling it is optional for synchronous code, and it can even
accept an error to improve test reporting:

describe('User', function(){
  describe('#save()', function(){
    it('should save without error', function(done){
      var user = new User('Luna');

TJ's example shows that for methods that include an error as the first
argument, then this will be automatically passed to done:

describe('User', function(){
  describe('#save()', function(){
    it('should save without error', function(done){
      var user = new User('Luna');

Mocha can work with any assertion library, which allows alternative
assertion libraries like
should.js to be used. It's even possible to use BDD style tests describe() / it() or
TDD: suite() / test().

TJ considers Mocha to be
Expresso successor, and it does seem to address a lot of things that were missing from Expresso.


Banzai (npm: banzai) by Pedro Teixeira is a document processing framework (or an
that uses the concept of pipelines to represent state and perform
multiple operations on a document. On the surface, a pipeline looks like
a combination of an event-based API and a state machine:

  .on('initial', initialHandler, {
      next: 'order received email sent'
  .on('order received email sent', orderEmailSentHandler, {
      priority: 2
    , condition: allItemsAvailable
    , next: 'items available'
  .on('order received email sent', confirmationEmailSentHandler, {
      priority: 1
    , next: 'items not available'
  .on('items not available', itemsNotAvailableHandler)
  .on('items available', itemsAvailableHandler, {
    next: 'order placed'
  .on('order placed', orderPlacedHandler, {
    next: 'order placed email sent'

Each pipeline is backed by a document store, and this is designed to be
extensible. The first document store to be implemented is
banzai-couchdb-store, but document stores only require a minimum of two functions to work with
Banzai (load(docId, callback) and save(doc,
) so shouldn't be too difficult to write support for
more databases.

Pedro's documentation includes a lot more details on pipelines, state
handling, state stores, and work queues. Banzai seems like a useful tool
for working with format conversion, but Pedro also notes it's been used
with Amazon Mechanical Turk.

Node Inotify

Node Inotify (License: MIT, npm: inotify) by Camilo Aguilar is an
inotify API for Node and Linux. This library has been kicking around for over a
year now, but the author and several contributors have been actively
working on it.

The README includes a detailed code example, but the API is fairly
straightforward: by using an instance of Inotify,
addWatch() can be used to watch files or directories for
changes. The callback fired when the file system changes receives an
event which includes a mask that details what kind of change occurred.