Code coverage report for src/types.js

Statements: 100% (9 / 9)      Branches: 100% (2 / 2)      Functions: 100% (0 / 0)      Lines: 100% (9 / 9)      Ignored: none     

All files » src/ » types.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29        1 1             1 1 1 5 4       1               1
/**
 * An enum of types that are serializable by Wasabi
 * @class Types
 */
var iota = 0;
var fromString = {
    sint: iota++,
    uint: iota++,
    float: iota++,
    string: iota++
};
 
var fromValue = {};
var k;
for (k in fromString) {
    if (fromString.hasOwnProperty(k)) {
        fromValue[fromString[k]] = k;
    }
}
 
var Types = {
    fromString: fromString,
    fromValue: fromValue,
    // bits needed to encode the type data
    // ceiling of log base 2 of the number of types
    bitsNeeded: Math.ceil(Math.log(iota) / Math.log(2))
};
 
module.exports = Types;