was.js
/trunk/dist/was.js |
@@ -1,4 +1,4 @@ |
/*! was.js - v1.0.1 - 2019-03-04 |
/*! was.js - v1.0.1 - 2019-08-01 |
* http://grimore.org |
* Copyright (c) 2019 [object Object]; Licensed GPL-3.0 */ |
/* Copyright (C) 2017 Wizardry and Steamworks - License: GNU GPLv3 */ |
@@ -219,18 +219,18 @@ |
/* fuss/lambda_calculus/functional_programming/aggregators @ grimore.org */ |
/*************************************************************************/ |
// Vanilla ES6 JavaScript |
function wasSwitch(q, d, ...c) { |
if(c.length % 2 !== 0) { |
function wasSwitch() { |
if(arguments.length - 2 % 2 !== 0) { |
throw "Pairs of predicates expected for cases"; |
} |
|
(Array.isArray(q) ? q : [ q ]).forEach((s) => { |
(Array.isArray(arguments[0]) ? arguments[0] : [ arguments[0] ]).forEach((s) => { |
var m = false; |
for(var i = 0; i < c.length; i += 2) { |
if(!c[i](s)) { |
for(var i = 2; i < arguments.length; i += 2) { |
if(!arguments[i](s)) { |
continue; |
} |
if(!c[i + 1](s)) { |
if(!arguments[i + 1](s)) { |
continue; |
} |
m = true; |
@@ -237,13 +237,13 @@ |
} |
|
if(!m) { |
d(s); |
arguments[1](s); |
} |
}); |
} |
if (!Array.prototype.switch) { |
Array.prototype.switch = function(d, ...c) { |
wasSwitch(this, d, ...c); |
Array.prototype.switch = function() { |
wasSwitch(this, arguments[0], arguments.slice(1)); |
}; |
} |
// jQuery |