added promise defer(func) helper for writing wrappers around synchronous functions.