-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
69 lines (58 loc) · 1.77 KB
/
index.js
File metadata and controls
69 lines (58 loc) · 1.77 KB
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
// const express = require('express')
import fs from 'fs';
import express from 'express';
const app = express()
import Zet from './lib/zet.js';
// Declarations
// import http from 'http';
// Initialization
const port = 80;
async function mainHandler(request, response) {
console.log('Request:', request.url);
let content = '';
switch (request.url) {
case '/index.html':
case '/':
content = fs.readFileSync('./pages/index.html');
response.writeHead(200, { "Content-Type": 'text/html' });
response.end(content, "utf-8");
break;
default:
content = 'Error';
try {
content = fs.readFileSync('.'+request.url);
} catch (error) {
console.error(error);
}
//response.writeHead(200, { "Content-Type": 'text/html' });
response.end(content, "utf-8");
break;
}
}
app.get('/*', mainHandler);
app.use(express.static('static'))
app.listen(port, () => {
console.log(`Callosal HUB listening on port ${port}`)
});
// const g_Server = http.createServer(mainHandler).listen(g_Port);
// console.log('Server is running');
let a = new Zet(["A", "B", "C"]);
let b = new Zet(["C", "D", "E"]);
let c = new Zet(["B", "C", "D"]);
let r1 = Zet.union(a, b).dump();
// output(r);
//=> [Zet] {1, 2, 3, 4, 5}
let r2 = a.union(b, c).dump();
//=> [Zet] {1, 2, 3, 4, 5}
let r3 = a.intersection(b).dump();
//=> [Zet] {3}
let r4 = a.symmetricDifference(c).dump();
// r.dump();
//=> [Zet] {1, 4}
console.log('a subset of b? = ',a.subset(b));
//=> false
let r5_1 = a.filter(i => i % 2).dump();
let r5_2 = a.filter(i => i=="B").dump();
//=> [Zet] {1, 3}
// console.log(r);
console.log('r4 subset of r2? = ',r4.subset(r2));