was.js – Diff between revs 47 and 48

Subversion Repositories:
Rev:
Show entire fileIgnore whitespace
Rev 47 Rev 48
Line 1... Line 1...
1 /*! was.js - v1.0.5 - 2019-12-01 1 /*! was.js - v1.0.6 - 2020-12-08
2 * http://grimore.org 2 * http://grimore.org
3 * Copyright (c) 2019 [object Object]; Licensed GPL-3.0 */ 3 * Copyright (c) 2020 [object Object]; Licensed GPL-3.0 */
4 /* Copyright (C) 2017 Wizardry and Steamworks - License: GNU GPLv3 */ 4 /* Copyright (C) 2017 Wizardry and Steamworks - License: GNU GPLv3 */
5 /*************************************************************************/ 5 /*************************************************************************/
6 function wasProduct(a, b) { 6 function wasProduct(a, b) {
7 var m = Math.max(a.length, b.length); 7 var m = Math.max(a.length, b.length);
8 var o = {}; 8 var o = {};
Line 41... Line 41...
41 $.extend({ 41 $.extend({
42 stride: wasStride 42 stride: wasStride
43 }); 43 });
44 } 44 }
Line 45... Line -...
45   -  
46 /*************************************************************************/ -  
47 /* Copyright (C) 2017 Wizardry and Steamworks - License: GNU GPLv3 */ -  
48 /*************************************************************************/ 45  
49 // Vanilla JavaScript 46 // Vanilla JavaScript
50 function wasChunk(a, n) { -  
51 if (!a.length) { -  
52 return []; -  
53 } -  
54 return [a.slice(0, n)] 47 function wasChunk(a, n) {
55 .concat(a.slice(n).wasChunk(n)); 48 return new Array.from(new Array(Math.ceil(a.length/n)), (_,i)=>a.slice(i*n,i*n+n));
56 } 49 }
57 if (!Array.prototype.chunk) { 50 if (!Array.prototype.chunk) {
58 Array.prototype.chunk = function(a, n) { 51 Array.prototype.chunk = function(a, n) {
59 return wasChunk(this, n); 52 return wasChunk(this, n);