MIRROR: javascript for ๐Ÿœ's, a tiny runtime with big ambitions
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

bring that one test from the long dead justjs for nostalgia sake

+37
+37
examples/demo/extra.js
··· 1 + const rgbToHex = (r, g, b) => '#' + ((1 << 24) + (r << 16) + (g << 8) + b).toString(16).slice(1); 2 + 3 + const date = { 4 + diff: (date1, date2) => Math.ceil(Math.abs(date1.getTime() - date2.getTime()) / 86400000), 5 + isWeek: date => date.getDay() % 6 !== 0, 6 + timeFrom: date => date.toTimeString().slice(0, 8) 7 + }; 8 + 9 + const math = { 10 + randInt: (min = 0, max = 1) => Math.floor(Math.random() * (max - min + 1)) + min, 11 + randFloat: (min = 0, max = 1) => Math.random() * (max - min + 1) + min 12 + }; 13 + 14 + const temp = { 15 + ctof: celsius => (celsius * 9) / 5 + 32, 16 + ftoc: fahrenheit => ((fahrenheit - 32) * 5) / 9 17 + }; 18 + 19 + String.prototype.reverse = function () { 20 + return [...this].reverse().join(''); 21 + }; 22 + 23 + String.prototype.json = function () { 24 + return JSON.parse(this); 25 + }; 26 + 27 + console.log(rgbToHex(255, 0, 244)); 28 + console.log(date.timeFrom(new Date())); 29 + console.log(date.diff(new Date('2020-10-21'), new Date())); 30 + console.log(date.isWeek(new Date())); 31 + console.log(math.randInt(0, 5)); 32 + console.log(math.randFloat(0, 5)); 33 + console.log(temp.ctof(15)); 34 + console.log(temp.ftoc(15)); 35 + 36 + console.log('hello world'.reverse()); 37 + console.log('{"hello":"world"}'.json()['hello']);