Repository navigation
Expand file tree
/
Copy pathunderscore.util.operators.js
More file actions
90 lines (85 loc) · 1.76 KB
/
Copy pathunderscore.util.operators.js
File metadata and controls
90 lines (85 loc) · 1.76 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
// Underscore-contrib (underscore.function.arity.js 0.0.1)
// (c) 2013 Michael Fogus, DocumentCloud and Investigative Reporters & Editors
// Underscore-contrib may be freely distributed under the MIT license.
(function(root) {
// Baseline setup
// --------------
// Establish the root object, `window` in the browser, or `global` on the server.
var _ = root._ || require('underscore');
// Mixing in the operator functions
// -----------------------------
_.mixin({
add: function(x, y) {
return x + y;
},
sub: function(x, y) {
return x - y;
},
mul: function(x, y) {
return x * y;
},
div: function(x, y) {
return x / y;
},
mod: function(x, y) {
return x % y;
},
inc: function(x) {
return ++x;
},
dec: function(x) {
return --x;
},
neg: function(x) {
return -x;
},
eq: function(x, y) {
return x == y;
},
seq: function(x, y) {
return x === y;
},
neq: function(x, y) {
return x != y;
},
sneq: function(x, y) {
return x !== y;
},
not: function(x) {
return !x;
},
gt: function(x, y) {
return x > y;
},
lt: function(x, y) {
return x < y;
},
gte: function(x, y) {
return x >= y;
},
lte: function(x, y) {
return x <= y;
},
bitwiseAnd: function(x, y) {
return x & y;
},
bitwiseOr: function(x, y) {
return x | y;
},
bitwiseXor: function(x, y) {
return x ^ y;
},
bitwiseNot: function(x) {
return ~x;
},
bitwiseLeft: function(x, y) {
return x << y;
},
bitwiseRight: function(x, y) {
return x >> y;
},
bitwiseZ: function(x, y) {
return x >>> y;
}
});
})(this);