index.js 498 B

12345678910111213141516171819
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.getRoundingMethod = getRoundingMethod;
  6. var roundingMap = {
  7. ceil: Math.ceil,
  8. round: Math.round,
  9. floor: Math.floor,
  10. trunc: function trunc(value) {
  11. return value < 0 ? Math.ceil(value) : Math.floor(value);
  12. } // Math.trunc is not supported by IE
  13. };
  14. var defaultRoundingMethod = 'trunc';
  15. function getRoundingMethod(method) {
  16. return method ? roundingMap[method] : roundingMap[defaultRoundingMethod];
  17. }