-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathcommons.js
36 lines (35 loc) · 1.03 KB
/
commons.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
33
34
35
36
require("./lib").loadLibrary([{
"object": GLOBAL,
"functions": [
function loop(times, func) {
var i, ret;
if (times > 0) {
for (i = times; i; i -= 1) {
ret = func(times - i);
if (ret !== undefined) {
return ret;
}
}
return ret;
}
},
function skip1() {
return Array.prototype.slice.call(arguments, 1);
},
function joinSlashes(arr) {
return arr.join("/");
},
function writeResponse(res, type, text) {
res.writeHead(200, {
"Content-Type": type
});
res.end(text.constructor === Array ? text.join("\n") : text);
},
function writeHtmlResponse(res, html) {
writeResponse(res, "text/HTML", html);
},
function writePlainResponse(res, text) {
writeResponse(res, "text/Plain", text);
}
]}
]);