1
0
mirror of https://github.com/stolksdorf/homebrewery.git synced 2025-12-24 04:01:28 +00:00
This commit is contained in:
Scott Tolksdorf
2016-12-30 16:44:37 -05:00
parent 924b398768
commit 1173af5803
7 changed files with 317 additions and 13 deletions

23
server/utils.js Normal file
View File

@@ -0,0 +1,23 @@
const _ = require('lodash');
module.exports = {
getGoodBrewTitle : (text) => {
const titlePos = text.indexOf('# ');
if(titlePos !== -1){
const ending = text.indexOf('\n', titlePos);
return text.substring(titlePos + 2, ending);
}else{
return _.find(text.split('\n'), (line)=>{
return line;
});
}
},
replaceByMap : (text, mapping) => {
return _.reduce(mapping, (r, search, replace) => {
return r.split(search).join(replace)
}, text)
}
}