sprintf for node.js based on Alexandru Marasteanu's browser version