was.js – Blame information for rev 1

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 office 1 /*************************************************************************/
2 /* Copyright (C) 2017 Wizardry and Steamworks - License: GNU GPLv3 */
3 /*************************************************************************/
4 if (!Array.prototype.product) {
5 Array.prototype.product = function(b) {
6 var a = this;
7 return $.map(
8 Array(Math.max(this.length, a.length)),
9 function(e, i) {
10 var o = {};
11 o[a[i]] = b[i];
12 return o;
13 });
14 };
15 }
16 $.extend({
17 product: function(a, b) {
18 return $.map(
19 Array(Math.max(this.length, a.length)),
20 function(e, i) {
21 var o = {};
22 o[a[i]] = b[i];
23 return o;
24 });
25 }
26 });
27  
28 /*************************************************************************/
29 /* Copyright (C) 2017 Wizardry and Steamworks - License: GNU GPLv3 */
30 /*************************************************************************/
31 if (!Array.prototype.stride) {
32 Array.prototype.stride = function(s) {
33 return this.filter(function(e, i) {
34 return i % s === 0;
35 });
36 };
37 }
38 $.extend({
39 stride: function(a, s) {
40 return a.filter(function(e, i) {
41 return i % s === 0;
42 });
43 }
44 });
45  
46 /*************************************************************************/
47 /* Copyright (C) 2017 Wizardry and Steamworks - License: GNU GPLv3 */
48 /*************************************************************************/
49 if (!Array.prototype.chunk) {
50 Array.prototype.chunk = function(n) {
51 if (!this.length)
52 return [];
53 return [this.slice(0, n)]
54 .concat(this.slice(n).chunk(n));
55 };
56 }
57 $.extend({
58 chunk: function(a, n) {
59 if (!a.length)
60 return [];
61 return [a.slice(0, n)]
62 .concat(a.slice(n).chunk(n));
63 }
64 });