The JavaScript blog.


libraries events games modules di

js13k Winners, BottleJS

Posted on .

js13k Winners

Pest Control

The js13k winners have been announced. First place went to Pest Control: Weasels by Siorki, which is like Lemmings in reverse -- instead of saving little critters you have to kill them. It's a surprisingly fun game!

Felipe Alfonso came second with Extreme Mini Massacre, and Aurélio Santos came third with ap11. This is like a simplified GTA 1 clone, all in 13k!

There are 129 games listed on the site. Most genres are covered, and there are even some pretty unique ones like Whistleblower which allows you to use the microphone to whistle different pitches to defeat enemies.

The js13k participants get t-shirts and 3.5" diskettes that contain all of the entries. Just to show off how small browser games can be... For those of us without disk drives, however, the source is at js13kGames on GitHub.


BottleJS (GitHub: young-steveo / bottlejs, License: MIT, Bower: bottlejs, npm: bottlejs) by Stephen Young is a dependency injection micro container.

It's inspired by the AngularJS API. You can register services with bottle.service('Service', Service), and then construct them with bottle.container.Service. Bottle supports middleware, so you can inject functions that intercept requests for providers just before they're made for the first time.

If you're not using AngularJS and have trouble keeping larger applications maintainable and testable, then something like Bottle might help improve your application's structure. The readme has examples and API documentation to get you started.


ajax angularjs di

ngActivityIndicator, angular-cog, dijs

Posted on .



ngActivityIndicator (GitHub: voronianski / ngActivityIndicator, License: MIT) by Dmitri Voronianski is an Angular provider for loading indicators, which you can use on directives, controllers or services.

Adding an indicator to a controller looks like this:

var app = angular.module('exampleApp', ['ngActivityIndicator']);

app.controller('MainCtrl', ['$activityIndicator', '$timeout',  
  function ($actvityIndicator, $timeout) {
    $timeout(function () {
    }, 3000);

There's a directive called ng-activity-indicator which can be used to inject the indicator into the DOM automatically.


angular-cog (GitHub: chinmaymk / angular-cog, License: MIT) by Chinmay Kulkarni is a library for writing declarative Ajax requests with Angular.

The full set of directives are as follows:

<div cog-verb="{url}"  

Requesting JSON content should place it in the $data variable, so you can access it in cog-success and then pass it to something bound in $scope.

The documentation includes notes on how to set up a loading indicator -- maybe you could try ngActivityIndicator?


dijs (GitHub: cmtt / dijs, License: WTFPL) by Matthias Thoemmes is a dependency injection module for Node and browsers that's inspired by Angular. There are methods for defining a namespace, describing the modules, and resolving dependencies.

For describing dependencies, it supports function notation and array notation:

// Function notation
var mod = Di();  
mod.provide('Pi', Math.PI, true);  
mod.provide('2Pi', function(Pi) { return 2*Pi; });

// Array notation
var mod = Di();  
mod.provide('Math.Pi', Math.PI, true);  
mod.provide('2Pi', ['Math.Pi', function (Pi) {  
  return function () {
    return 2*Pi;

There's a lot more to it than this, and you might find it useful if you've got used to DI through Angular but want to use it elsewhere.


node modules objective-c di

Node Roundup: Ben Noordhuis, Node.app, Infect.js

Posted on .

Ben Noordhuis

Every time I write about a new Node release, I notice how much work Ben Noordhuis has done. He's been an important contributor to Node and libuv, and has always seemed patient and polite on the mailing list.

Ben Noordhuis decided to leave Node and libuv. If you're not familiar with his work, take a look at the Node ChangeLog -- Ben's commits go back to summer 2010. Ben will be missed!



Node.app (GitHub: node-app / Interpreter, License: MIT) is a project to bring Node's API to JavaScriptCore. The aim is a drop-in replacement that's compatible with Node's master branch, and to reuse the JavaScript in Node's lib/ directory (the core modules).

It needs the latest iOS or Mac OS X, and if you check out the source you'll need to get the submodules (git submodule update --init --recursive).

The list of currently working modules includes partial fs support, util, url, events, path, stream, querystring, and assert. The process object is also supported.

I've only had a brief look at the source in node-app / Nodelike, but it looks like they're writing Objective-C to add the necessary libuv bindings. This is the code you'll find in src/ in joyent / node.


Infect.js (GitHub: amwmedia / infect.js, License: MIT, npm: infect) by Andrew Worcester is a dependency injection module. It's not specifically for Node, but I was intrigued by the idea of bringing AngularJS-style DI to Node projects.

Registering a dependency. A simple call to infect.set() with the name you want to use, and the mutable object you'd like to register will do the trick. In the example below we are using a function, but you can register any type of mutable value (Functions, Arrays, Objects, etc).

infect.set('Logger', function(str) {  
  // prepend a time to every log line
  console.log((new Date()).toLocaleTimeString() + ' ==> ' + str);

It supports function injection (infect.func) and class injection (infect.func with a constructor function). Andrew has included jsFiddle examples in the readme, so you can play around with the code.