Skip to content

Commit ee5e896

Browse files
author
Brian Lonsdorf
committed
add old v1 class js libs
1 parent 633f16b commit ee5e896

File tree

9 files changed

+1440
-0
lines changed

9 files changed

+1440
-0
lines changed

Bacon.min.js

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

array.js

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
(function(){
2+
3+
var _flatten = function(xs) {
4+
return xs.reduce(function(a,b){return a.concat(b);}, []);
5+
};
6+
7+
var _fmap = function(f) {
8+
var xs = this;
9+
return xs.map(function(x) { return f(x); }); //avoid index
10+
};
11+
12+
Object.defineProperty(Array.prototype, 'fmap',{
13+
value: _fmap,
14+
writable: true,
15+
configurable: true,
16+
enumerable: false
17+
});
18+
19+
var _empty = function() { return []; };
20+
21+
Object.defineProperty(Array.prototype, 'empty',{
22+
value: _empty,
23+
writable: true,
24+
configurable: true,
25+
enumerable: false
26+
});
27+
28+
var _chain = function(f) { return _flatten(this.fmap(f)); };
29+
30+
Object.defineProperty(Array.prototype, 'chain',{
31+
value: _chain,
32+
writable: true,
33+
configurable: true,
34+
enumerable: false
35+
});
36+
37+
var _of = function(x) { return [x]; };
38+
39+
Object.defineProperty(Array.prototype, 'of',{
40+
value: _of,
41+
writable: true,
42+
configurable: true,
43+
enumerable: false
44+
});
45+
46+
var _ap = function(a2) {
47+
var a1 = this;
48+
return _flatten(a1.map(function(f){
49+
return a2.map(function(a){ return f(a); })
50+
}));
51+
};
52+
53+
Object.defineProperty(Array.prototype, 'ap',{
54+
value: _ap,
55+
writable: true,
56+
configurable: true,
57+
enumerable: false
58+
});
59+
60+
})();

0 commit comments

Comments
 (0)