-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbool.js
36 lines (33 loc) · 836 Bytes
/
bool.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
var curry = require('./curry');
var utils = require('./utils');
var id = require('./id');
var reorder = require('./reorder');
var bool = {
not: function(fn) {
return curry.setArityLike(fn, function() {
return !fn.apply(null, arguments);
});
},
and: function(f, g) {
return function() {
return !!(f.apply(null, arguments) && g.apply(null, arguments));
};
},
or: function(f, g) {
return function() {
return !!(f.apply(null, arguments) || g.apply(null, arguments));
};
},
retTrue: id.constant(true),
retFalse: id.constant(false),
ltToCompare: function(pred) {
return function(a, b) {
return pred(a, b) ? -1 : pred(b, a) ? 1 : 0;
}
},
gtToCompare: function(pred) {
return reorder.flip(curriedBool.ltToCompare(pred));
}
};
var curriedBool = curry.curryObject(bool);
module.exports = curriedBool;