Code coverage report for number/toInt.js

Statements: 100% (5 / 5)      Branches: 100% (0 / 0)      Functions: 100% (3 / 3)      Lines: 100% (4 / 4)     

All files » number/ » toInt.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 161               1 12     1      
define(function(){
 
    /**
     * "Convert" value into an 32-bit integer.
     * Works like `Math.floor` if val > 0 and `Math.ceil` if val < 0.
     * IMPORTANT: val will wrap at 2^31 and -2^31.
     * Perf tests: http://jsperf.com/vs-vs-parseint-bitwise-operators/7
     */
    function toInt(val){
        return ~~val;
    }
 
    return toInt;
 
});