was.js

Subversion Repositories:
Compare Path: Rev
With Path: Rev
?path1? @ 17  →  ?path2? @ 15
/trunk/lib/lambda/aggregators.js
@@ -5,25 +5,21 @@
/*************************************************************************/
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(var i = 0; i < c.length; i += 2) {
if(!c[i](s)) {
for(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)
});
};
}
@@ -35,25 +31,21 @@
/*************************************************************************/
$.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(var i = 0; i < c.length; i += 2) {
if(!c[i](s)) {
for(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)
});
}
});