adamrenklint/bap

View on GitHub
lib/types/numberInRange.js

Summary

Maintainability
A
0 mins
Test Coverage
B
83%
function numberInRange (type, from, to) {

  return {
    set: function (newVal) {
      if (newVal >= from && newVal <= to) {
        return {
          val: newVal,
          type: type
        };
      }
      else {
        return {
          val: newVal,
          type: typeof newVal
        };
      }
    }
  };

}

module.exports = numberInRange;