was.js

Subversion Repositories:
Compare Path: Rev
With Path: Rev
?path1? @ 16  →  ?path2? @ 17
/trunk/lib/lambda/aggregators.js
@@ -5,21 +5,25 @@
/*************************************************************************/
if (!Array.prototype.switch) {
Array.prototype.switch = function(d, ...c) {
if(c.length % 2 != 0)
if(c.length % 2 !== 0) {
throw "Pairs of predicates expected for cases";
}
(Array.isArray(this) ? this : [ this ]).forEach((s) => {
var m = false;
for(i = 0; i < c.length; i += 2) {
if(!c[i](s))
for(var i = 0; i < c.length; i += 2) {
if(!c[i](s)) {
continue;
if(!c[i + 1](s))
}
if(!c[i + 1](s)) {
continue;
}
m = true;
}
if(!m)
d(s)
if(!m) {
d(s);
}
});
};
}
@@ -31,21 +35,25 @@
/*************************************************************************/
$.extend({
switch: function(q, d, ...c) {
if(c.length % 2 != 0)
if(c.length % 2 !== 0) {
throw "Pairs of predicates expected for cases";
}
(Array.isArray(q) ? q : [ q ]).forEach((s) => {
var m = false;
for(i = 0; i < c.length; i += 2) {
if(!c[i](s))
for(var i = 0; i < c.length; i += 2) {
if(!c[i](s)) {
continue;
if(!c[i + 1](s))
}
if(!c[i + 1](s)) {
continue;
}
m = true;
}
if(!m)
d(s)
if(!m) {
d(s);
}
});
}
});