The JavaScript blog.


functional node apps rss haskell

RSS Pipes, type-check

Posted on .

RSS Pipes

RSS Pipes (GitHub: dai-shi / rss-pipes, License: BSD) by Daishi Kato is an Express app for aggregating RSS feeds. It has a lightweight database wrapper for PostgreSQL and SQLite using the jugglingdb, which seems like a cleaner ORM that some of the Node database ORMs I've used, and it keeps the route handlers lightweight which is good practice in Express applications.

One of the useful features it has is filtering feeds. For example, you can filter for keywords or truncate the result set. In this respect it's like a simple version of Yahoo! Pipes. The client-side portion of the project uses Bootstrap, so you could probably customise it if you wanted.


Haskell makes an appearance in type-check (GitHub: gkz / type-check, License: MIT, npm: type-check) by George Zahariev. It performs runtime type checking using a Haskell inspired syntax:

var typeCheck = require('type-check').typeCheck;  
typeCheck('Number', 1);               // true  
typeCheck('Number', 'str');           // false

typeCheck('Number | String', 2);      // true  
typeCheck('Number | String', 'str');  // true

typeCheck('{x: Number, y: Boolean, ...}', {x: 2, y: false, z: 3});  // true  

It works in browsers and Node, and apparently has 100% statement, branch, and line test coverage. It seems like something that might add an extra level of readability to test code, but could also be useful for validating user input.


node modules express mongo rss feeds

Node Roundup: Mongorito, Memcacher, Restify, Versionator, FeedSub

Posted on .


Mongorito (License: MIT, npm: mongorito) by Vadim Demedes is a new MongoDB ODM with some interesting features: it has built-in caching using Memcacher (another module by the same author), and a small codebase by building on Mongolian. Automatic caching can even be set up, simply by setting a Memcached host using Mongorito.cache.

Mongorito has a model class, and the author gives examples in both JavaScript and CoffeeScript:

var Post = (function(){  
  function Post() {
    Post.__super__.constructor.call(this, 'posts');

  Post.prototype.validateTitle = function(callback) {
    if (!this.title) {
    } else {

Post = Mongorito.bake(Post);

Post.find(function(err, posts){  
  var length = posts.length;
  for (var i = 0; i < length; i++) {
    // posts[i] is an instance of the Post class
    posts[i].remove(function() {

The model definitions offer an alternative to Mongoose, and may appeal to those working on CoffeeScript-based projects:

class Post  
  constructor: ->
    super 'posts'

Post = Mongorito.bake Post

post = new Post  
post.title = 'About Mongorito'

post.save (err) ->  
  # saved!

Despite being a new library, the author says the code is being used in production software, and he's written some Mocha unit tests.


Memcacher (License: MIT, npm: memcacher) also by Vadim Demedes adds additional functionality to the Memcached module by Arnout Kazemier, in the form of tags and chainable methods:

  .set('test-key', 'value', 2592000, ['some-tag'])
  .get('test-key', function(err, value) {
    // This callback intentionally left blank

It's a small but significant addition that should help those working with Memcached.


Restify (GitHub: mcavage / node-restify, License: MIT, npm: restify) by Mark Cavage is a new Express-inspired framework for building REST APIs. It includes both client and server support, so it'll consume REST services as well as serve them.

Creating a basic server and setting up middleware looks just like Express:

var server = restify.createServer({  
  name: 'myapp',
  version: '1.0.0'

server.listen(8080, function() {  
  console.log('%s listening at %s', server.name, server.url);

It made me wonder if it's Connect middleware compatible, because setting up routes looks the same as Express as well:

server.get('/echo/:name', function(req, res, next) {  
  return next();

There are a healthy amount of unit tests (built with the tap module), detailed documentation, and a demo app.


Versionator (GitHub: serby / versionator, License: New BSD, npm: versionator) by Paul Serby is Connect middleware for managing static asset caching. The basic middleware allows a global application version to be set, and adds an extra path to asset URLs so they'll effectively be expired when the app version changes:

app.version = '0.1.0';  
var basic = require('versionator').createBasic(app.version);

app.configure(function() {  
  app.use(basic.middleware('v' + app.version))
    .use(express.static(__dirname + '/public', { maxAge: 2592000000 }));

Assuming a client-side script is at /js/app.js, it'll now be available from /js/v0.1.0/app.js. There's a Jade helper so the original URL can be referenced in templates.

There's also 'mapped' middleware, which will only change resource locations when the files have changed.


FeedSub (License: MIT, npm: feedsub) by Roly Fentanes is an event-based feed downloader, that works the way a Node developer would expect:

var FeedSub = require('feedsub');

reader = new FeedSub('http://feeds.feedburner.com/dailyjs', {  
  interval: 10 // check feed every 10 minutes

reader.on('item', function(item) {  
  console.log('Got item!');


It'll also do a conditional GET based on the last modified headers:

// check headers for conditional get
if (res.headers['last-modified']) {  
  self.getOpts['If-Modified-Since'] = res.headers['last-modified'];
if (res.headers.etag) {  
  self.getOpts['If-None-Match'] = res.headers.etag;


jquery events plugins rss

jQuery Roundup: 1.7 RC1, $.Callbacks, jquery.rss, sessionTimeout

Posted on .

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

jQuery 1.7 RC1

jQuery 1.7 RC1 has
been released. Meanwhile, the jQuery Standards

has been created, which aims to represent jQuery users to standards
bodies such as the W3C and TC39.

The jQuery Standards Team is driven by jQuery team members Yehuda Katz and Paul Irish who some of you may know. Yeuhda and Paul have extenstively worked with standards bodies and browser vendors in a number of capacities over the years.

Demystifying jQuery 1.7's \$.Callbacks

In Demystifying jQuery 1.7's
, Addy Osmani explains the origins of \$.Callbacks and
provides detailed examples on how to use it.

The general idea behind pub/sub (the Observer pattern) is the promotion of loose coupling in applications. Rather than single objects calling on the methods of other objects, an object instead subscribes to a specific task or activity of another object and is notified when it occurs.

Looking at the source in in jQuery 1.7 is interesting because
\$.Callbacks is now used in several places. For example,
the new
deferred.js is built with it, and
ajax.js is as well.

I was trying to compare Node's EventEmitter with
\$.Callbacks and discovered Comparison Between Different
Observer Pattern

by Miller Medeiros, which is an interesting post on this subject.


jquery.rss (License: MIT) by Sascha Depold and DaWanda GmbH is an RSS reading and transformation
library. It uses the Google Feed
to download feeds straight from
the browser. It comes complete with support for simple templates and

$("#rss-feeds").rss("http://feeds.feedburner.com/premiumpixels", {
  // how many entries do you want? default: 4
  limit: 10,

  // will request the API via https; default: false
  ssl: true,

  // template for the html transformation
  // default: "{entry}[{author}@{date}] {title}{shortBodyPlain}{/entry}"
  template: "{entry}{title}{/entry}",

  // additional token definition for in-template-usage
  // default: {}
  tokens: {
    foo: 'bar',
    bar: function(entry, tokens) { return entry.title }


sessionTimeout (Source: jquery.sessionTimeout.1.0.js) is a simple plugin for handling session timeouts in the browser. It will
poll a URL, and show a jQuery UI dialog when the time limit has been

  message :     'Your session is about to expire.'
, keepAliveUrl: '/sessions/alive'
, redirUrl:     '/sessions/timed-out'
, logoutUrl:    '/sessions/destroy'
, warnAfter:    900000
, redirAfter:   1200000