Some basic utility functions. I want to avoid coupling this to large JavaScript libraries.
Detects the type of the result and wraps it with a num or int_