-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprototype.js
More file actions
113 lines (87 loc) · 1.64 KB
/
prototype.js
File metadata and controls
113 lines (87 loc) · 1.64 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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
/*
Comp()
.var('x').let(2)
.do(console.log);
*/
function Comp(v) {
this.value = v || 0;
this.do = function(fun) {
fun(this.value);
return this;
}
this.set = function(v) {
this.value = v;
return this;
}
return this;
}
Comp(10)
.do(console.log)
.set(2)
.do(console.log);
function CompF(f) {
this.comp = f || function() { return 0; };
this.do = function(fun) {
currentComp = this.comp();
this.comp = function() { return fun(currentComp); };
return this;
};
this.set = function(v) {
this.comp = function() { return v; };
return this;
};
this.bind = function(f) {
return f(this);
};
this.run = function() {
return this.comp();
};
return this;
}
CompF()
.set(2)
.do(console.log)
.run();
function CompP() {
this.comp = [];
this.do = function(fun) {
currentComp = this.comp();
this.comp = function() { return fun(currentComp); };
return this;
};
this.set = function(v) {
this.comp = function() { return v; };
return this;
};
this.bind = function(f) {
return f(this);
};
this.let = function(o) {
return this;
};
this.run = function() {
return this.comp();
};
return this;
}
CompP()
.set(2)
.let({
x: console.log,
y: console.log
})
.do(console.log)
.run();
var k = {
a: [1,2,3]
}
function CC() {
this.vars = {};
this.let = function(ass) {
for(var varName in ass)
console.log(varName);
}
return this;
}
CC()
.let({a:1});