mirror of
https://github.com/stolksdorf/homebrewery.git
synced 2025-12-24 04:01:28 +00:00
'Created
This commit is contained in:
23
server/utils.js
Normal file
23
server/utils.js
Normal 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)
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user