Globalize.parseint("foo") returns 0, should return NaN
When the string does not contain a recognizable number, Globalize.parseInt returns 0, as opposite to parseInt, which returns NaN. It is essential to return NaN, since otherwise the caller cannot distinguish between invalid data and input data representing the number zero.
The problem is in the function
truncate = function( value ) { return value | 0; };
which is currently used in two contexts: 1) to define Globalize.parseInt so that it truncates the return value of Globalize.parseFloat, and 2) in formatNumber when using the "d" format code.
Minimal fix: change the statement to
truncate = function( value ) { return isNaN(value) ? NaN : value | 0 ; }
Can also do: Math.round( value > 0 ? value - 0.5 : value + 0.5 );
EDIT: After running perf tests, I think your solution is the best should this be desired.
http://jsperf.com/javascript-trunc/3