-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutils.js
32 lines (26 loc) · 777 Bytes
/
utils.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
const parseCookies = (request) => {
var list = {},
rc = request.headers.cookie;
rc && rc.split(';').forEach(function( cookie ) {
var parts = cookie.split('=');
list[parts.shift().trim()] = decodeURI(parts.join('='));
});
return list;
}
const fillArrayWithTrueValues = (arr, obj) => {
Object.keys(obj).map(key => {
if(obj[key]){
arr.push(key)
}
})
}
const removeFromArray = (array, item) => {
var index = array.indexOf(item);
if (index !== -1) array.splice(index, 1);
}
module.exports = {
parseCookies: parseCookies,
removeFromArray: removeFromArray,
fillArrayWithTrueValues: fillArrayWithTrueValues,
url: 'https://bricks-in-the-wall.herokuapp.com' //http://localhost:3000
}