tape-measure.js 408 B

12345678910111213141516
  1. /*
  2. Fraction.js v5.0.0 10/1/2024
  3. https://raw.org/article/rational-numbers-in-javascript/
  4. Copyright (c) 2024, Robert Eisele (https://raw.org/)
  5. Licensed under the MIT license.
  6. */
  7. const Fraction = require('fraction.js');
  8. function closestTapeMeasure(frac) {
  9. // A tape measure is usually divided in parts of 1/16
  10. return Fraction(frac).roundTo("1/16");
  11. }
  12. console.log(closestTapeMeasure("1/3")); // 5/16