-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathutilities.js
More file actions
32 lines (25 loc) · 767 Bytes
/
utilities.js
File metadata and controls
32 lines (25 loc) · 767 Bytes
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
module.exports.jsonResponse = function jsonResponse(data, response) {
var jsonData = JSON.stringify(data);
response.writeHead(200, 'application/json');
response.end(jsonData);
};
module.exports.emptyResponse = function emptyResponse(response) {
response.writeHead(200);
response.end();
};
module.exports.statusResponse = function statusResponse(status, response) {
response.writeHead(status);
response.end();
};
module.exports.isAvailable = function isAvailable(arguments) {
for (i = 0; i < arguments.length; i++)
if (arguments[i] === undefined)
return false;
return true;
};
module.exports.clone = function clone(object) {
var clone = {};
for(var prop in object)
clone[prop] = object[prop];
return clone;
};