Sha256: 30152086e8682fac76a2b63cca9ae89238dfa88b0b6b81e79bb689db2879c017
Contents?: true
Size: 476 Bytes
Versions: 69
Compression:
Stored size: 476 Bytes
Contents
var MAX_INT = require('./MAX_INT'); /** * "Convert" value into an 31-bit unsigned integer (since 1 bit is used for sign). * IMPORTANT: value wil wrap at 2^31, if negative will return 0. */ function toUInt31(val){ // we do not use lang/toNumber because of perf and also because it // doesn't break the functionality return (val <= 0)? 0 : (val > MAX_INT? ~~(val % (MAX_INT + 1)) : ~~val); } module.exports = toUInt31;
Version data entries
69 entries across 69 versions & 2 rubygems