| /* | |
| Fraction.js v5.0.0 10/1/2024 | |
| https://raw.org/article/rational-numbers-in-javascript/ | |
| Copyright (c) 2024, Robert Eisele (https://raw.org/) | |
| Licensed under the MIT license. | |
| */ | |
| const Fraction = require('fraction.js'); | |
| function toFraction(frac) { | |
| var map = { | |
| '1:4': "ΒΌ", | |
| '1:2': "Β½", | |
| '3:4': "ΒΎ", | |
| '1:7': "β ", | |
| '1:9': "β ", | |
| '1:10': "β ", | |
| '1:3': "β ", | |
| '2:3': "β ", | |
| '1:5': "β ", | |
| '2:5': "β ", | |
| '3:5': "β ", | |
| '4:5': "β ", | |
| '1:6': "β ", | |
| '5:6': "β ", | |
| '1:8': "β ", | |
| '3:8': "β ", | |
| '5:8': "β ", | |
| '7:8': "β " | |
| }; | |
| return map[frac.n + ":" + frac.d] || frac.toFraction(false); | |
| } | |
| console.log(toFraction(Fraction(0.25))); // ΒΌ | |