nit: more secure if (typeof cb === 'function')