Skip to content

Instantly share code, notes, and snippets.

@OlofMoriya
Created February 3, 2022 19:12
Show Gist options
  • Save OlofMoriya/51337b6ae3589b524cb38d67c8f3cdd4 to your computer and use it in GitHub Desktop.
Save OlofMoriya/51337b6ae3589b524cb38d67c8f3cdd4 to your computer and use it in GitHub Desktop.
Bread
const args = process.argv
.slice(2)
.map(arg => arg.split('='))
.reduce((args, [value, key]) => {
args[value] = key || true;
return args;
}, {});
if (args["c"] && isNaN(args["c"])){
console.log("incorrect parameter c. Needs to be a number.");
}
var fToCConversion = (x) => { return (Math.floor((x - 32) * 5/9)); };
var temp = (x) => { return args["f"] ? x : fToCConversion(x); };
var ccl = (...strings) => {
function getColor(c) {
var color = '';
switch(c){
case 'r':
color = '\x1b[31m';
break;
case 'g':
color = '\x1b[32m';
break;
case 'y':
color = '\x1b[33m';
break;
case 'b':
color = '\x1b[34m';
break;
default:
color = '\x1b[30m';
}
return color;
}
const reset = '\x1b[0m';
strings.splice(0,0,'');
var print = strings.reduce((acc, val)=>{
if (val["c"]){
var color = getColor(val["c"]);
acc = acc + color + val["t"] + reset;
} else {
acc += val;
}
return acc;
});
console.log(print);
};
var tempText = args["f"] ? "ºF" : "ºC";
//var fullDoughWeight = 245 + 187 + 643 + 950 + 100;
var weatLevening = {"Starter": 20, "Weat Flour": 100, "Water": 125};
var ryeLevening = {"Starter": 5, "Rye Flour": 100, "Water": 82};
var dough = {"Bread flour": 950, "Whole weat flour": 100, "Water": 642};
var count = (args["c"] || 2)
var ratio = count / 2;
var warmEnvironment = !!args["w"];
console.log("Start by making your two levenings");
console.log("Weat levening:");
for (var propName in weatLevening){
ccl({t: weatLevening[propName] * ratio + "g", c: 'g'}, ':\t', propName );
}
console.log("Rye levening:");
for (var propName in ryeLevening){
ccl({t: ryeLevening[propName] * ratio + "g", c: 'g'}, ':\t', propName );
}
console.log("");
console.log("Mix in the rest of your water and flour");
for (var propName in dough){
ccl({t: dough[propName] * ratio + "g", c: 'g'}, ':\t', propName );
}
ccl('-- Rest ', {t:30, c:'r'}, ' minutes --');
var salt = 22.5;
console.log("");
ccl('Mix in ', {t: 22.5 * ratio + "g",c:'g'}, ' of salt');
console.log("Cover the dough");
console.log("");
var firstRestTime = warmEnvironment ? 50 : 60;
for (var i = 1; i <= 3; i++){
ccl('-- Rest ' + i + ' ', {t:firstRestTime, c:'r'}, ' minutes --');
ccl('Do a 4 fold');
}
console.log();
console.log("Move the dough to a flat surface with plenty of flour.");
ccl('Split the dough into ', {c:'y', t: count}, ' equal pieces');
ccl('Fold the dough into ', {c:'y', t: count}, ' loafs with 4-5 folds each.');
console.log("Use a bit less flour if you're planning to cover the dough with seeds.");
console.log("Place the formed loafs on plates");
console.log("");
ccl('-- Rest ', {c:'r', t: '10-30'}, ' minutes --');
console.log("");
console.log("Move the bread to the final resting container.");
var finalRest = warmEnvironment? 2.5 : 3;
ccl('-- Final rest ', {t:finalRest, c:'r'}, ' hours --');
console.log("");
ccl('Preheat the oven to ', {t:temp(500), c:'b'}, tempText);
console.log("Score the top and place it in the oven with the lid.");
ccl('Lower oven to ', {t:temp(460), c:'b'}, tempText);
ccl('-- Cook for ', {t:23, c:'r'}, ' minutes with cover');
ccl('Lower oven to ', {t:temp(425),c:'b'}, tempText + ' and remove the lid.')
ccl('-- Cook for ', {t:'20-30', c:'r'}, ' minutes or until wanted level of crustiness.');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment