-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpurity.ts
55 lines (43 loc) · 926 Bytes
/
purity.ts
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
interface Homepage {
}
const axios = {
post: (o: any)=> void
}
const generateHomePages = (homepage: Homepage) => {
createFreeFP(homepage)
createVipFP(homepage)
// createVipFP mutated homepage
createPartnerHp(homepage)
}
let counter = 0
const doStuff = () => {
counter++
} // impure as counter changed
const log = (msg: string) => {
console.log(msg)
} // impure as now there is a msg in stdout
const saveChanges = (u: any) => {
axios.post(u)
} // impure as the db changed
const foo = (n: number) : number => {
let result = 0
if(n % 2 === 0) {
result = n
}
return result
}
class Counter {
private val: number = 0
public inc(){
this.val++
}
public getCounter(): number {
return this.val
}
}
const createFreeFP = (hp: Homepage) => {
}
const createVipFP = (hp: Homepage) => {
}
const createPartnerHp = (hp: Homepage) => {
}