was.js – Diff between revs 27 and 29

Subversion Repositories:
Rev:
Show entire fileIgnore whitespace
Rev 27 Rev 29
Line 7... Line 7...
7 function wasSwitch(q, d, ...c) { 7 function wasSwitch(q, d, ...c) {
8 if(c.length % 2 !== 0) { 8 if(c.length % 2 !== 0) {
9 throw "Pairs of predicates expected for cases"; 9 throw "Pairs of predicates expected for cases";
10 } 10 }
Line 11... Line 11...
11 11
12 (Array.isArray(this) ? this : [ this ]).forEach((s) => { 12 (Array.isArray(q) ? q : [ q ]).forEach((s) => {
13 var m = false; 13 var m = false;
14 for(var i = 0; i < c.length; i += 2) { 14 for(var i = 0; i < c.length; i += 2) {
15 if(!c[i](s)) { 15 if(!c[i](s)) {
16 continue; 16 continue;
Line 25... Line 25...
25 d(s); 25 d(s);
26 } 26 }
27 }); 27 });
28 } 28 }
29 if (!Array.prototype.switch) { 29 if (!Array.prototype.switch) {
30 Array.prototype.switch = wasSwitch; 30 Array.prototype.switch = function(d, ...c) {
-   31 wasSwitch(this, d, ...c)
-   32 };
31 } 33 }
32 // jQuery 34 // jQuery
33 if(typeof jQuery === 'function') { 35 if(typeof jQuery === 'function') {
34 $.extend({ 36 $.extend({
35 switch: wasSwitch 37 switch: wasSwitch