A useful function for handling node-style callbacks.