Node-csssprite is a project mainly written in JavaScript, it's free.
create sprite image and css out of a bunch of icon images
see test/create-sprite.js