Node Roundup: Plunker, Mixr, FnQueue, timekeeper

07 Mar 2012 | By Alex Young | Tags node modules testing mocking assets apps async
You can send in your Node projects for review through our contact form or @dailyjs.

Plunker

Plunker

Plunker (GitHub: ggoodman / stsh, License: MIT) by Geoff Goodman is a web application for editing web snippets. It’s inspired by other popular services like jsFiddle, but has Node source that you can fork, and has an interface more suited to editing multiple files. It has all the obvious features like syntax highlighting, using the venerable Ace editor. The interface has been built with Twitter’s Bootstrap, so it also serves as an example of a Bootstrap web application.

There’s a public API for Plunker which allows “plunks” to be created, updated, retrieved, and deleted.

Mixr

Mixr (npm: mixr) by Alex Barlow is an Express compiler and pre-processor for client-side JavaScript and CSS. It can also handle other formats like LESS and CoffeeScript. To use Mixr, write client-side code in separate files, then include other files using comments:

//= require lib/jquery.min.js
//= require main.js
//= require something.js.coffee

In this example, Mixr would automatically process the CoffeeScript file.

During development, it’s possible to compile assets on each request:

app.configure(function(){
  Mixr.addHelpers(app);
});

app.configure('development', function(){
  // Add Mixr routes for development mode only
  Mixr.addExpressRoutes(app);
});

Then during deployment, a compiled file can be generated with ./node_modules/mixr/bin/mixr compile.

FnQueue

FnQueue (License: MIT, npm: fnqueue) by Kilian Ciuffolo is a utility for chaining functions:

new FnQueue({
  // This will wait for 'searchSomething'
  funnyStuff: function(processSomething, callback) {
    callback(null, 'ciao!');
  },
  searchSomething: function(callback) {
    callback(err, results);
  },
}, function(err, data) {
    if (err) {
      throw(err);
    }

    console.log(data.searchSomething);
  }
});

If you want to read more about Node’s wealth of control flow libraries, check out New Control Flow Libraries.

timekeeper

I often find myself needing to travel time, so rather than hacking Date I’d prefer to use mocks through Veselin Todorov’s timekeeper (License: MIT, npm: timekeeper) library. Time can be frozen by using timekeeper.freeze(date). Once the normal passage of time is required, the fourth dimension can be corrected simply by calling timekeeper.reset().

The only caveat is setTimeout and setInteval won’t work as expected until timekeeper.reset() is called.


blog comments powered by Disqus