was.js – Diff between revs 41 and 48

Subversion Repositories:
Rev:
Show entire fileIgnore whitespace
Rev 41 Rev 48
Line 39... Line 39...
39 $.extend({ 39 $.extend({
40 stride: wasStride 40 stride: wasStride
41 }); 41 });
42 } 42 }
Line 43... Line -...
43   -  
44 /*************************************************************************/ -  
45 /* Copyright (C) 2017 Wizardry and Steamworks - License: GNU GPLv3 */ -  
46 /*************************************************************************/ 43  
47 // Vanilla JavaScript 44 // Vanilla JavaScript
48 function wasChunk(a, n) { -  
49 if (!a.length) { -  
50 return []; -  
51 } -  
52 return [a.slice(0, n)] 45 function wasChunk(a, n) {
53 .concat(a.slice(n).wasChunk(n)); 46 return new Array.from(new Array(Math.ceil(a.length/n)), (_,i)=>a.slice(i*n,i*n+n));
54 } 47 }
55 if (!Array.prototype.chunk) { 48 if (!Array.prototype.chunk) {
56 Array.prototype.chunk = function(a, n) { 49 Array.prototype.chunk = function(a, n) {
57 return wasChunk(this, n); 50 return wasChunk(this, n);