was.js – Diff between revs 51 and 53
?pathlinks?
Rev 51 | Rev 53 | |||
---|---|---|---|---|
1 | /*! was.js - v1.0.8 - 2020-12-08 |
1 | /*! was.js - v1.0.8 - 2020-12-08 |
|
2 | * http://grimore.org |
2 | * http://grimore.org |
|
3 | * Copyright (c) 2020 [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 wasArrayToObject(a) { |
||
- | 7 | var o = {}; |
||
- | 8 | a.reduce(function(a, c, i) { |
||
- | 9 | i = Math.floor(i / 2); |
||
- | 10 | if (!a[i]) { |
||
- | 11 | a[i] = []; |
||
- | 12 | } |
||
- | 13 | a[i].push(c); |
||
- | 14 | return a; |
||
- | 15 | }, []).forEach(function(c, i, a) { |
||
- | 16 | o[c[0]] = c[1]; |
||
- | 17 | }, o); |
||
- | 18 | return o; |
||
- | 19 | } |
||
- | 20 | if (!Array.prototype.toObject) { |
||
- | 21 | Array.prototype.toObject = function() { |
||
- | 22 | return wasArrayToObject(this); |
||
- | 23 | }; |
||
- | 24 | } |
||
- | 25 | // jQuery |
||
- | 26 | if(typeof jQuery === 'function') { |
||
- | 27 | $.extend({ |
||
- | 28 | toObject: wasArrayToObject |
||
- | 29 | }); |
||
- | 30 | } |
||
- | 31 | |
||
- | 32 | |
||
- | 33 | /*************************************************************************/ |
||
- | 34 | /* Copyright (C) 2017 Wizardry and Steamworks - License: GNU GPLv3 */ |
||
- | 35 | /*************************************************************************/ |
||
6 | function wasProduct(a, b) { |
36 | function wasProduct(a, b) { |
|
7 | var m = Math.max(a.length, b.length); |
37 | var m = Math.max(a.length, b.length); |
|
8 | var o = {}; |
38 | var o = {}; |
|
9 | for(var i = 0; i < m; ++i) { |
39 | for(var i = 0; i < m; ++i) {> |
|
10 | o[a[i]] = b[i]; |
40 | < m; ++i) { o[a[i]] = b[i];> |
|
11 | } |
41 | < m; ++i) { }> |
|
12 | return o; |
42 | < m; ++i) { return o;> |
|
13 | } |
43 | < m; ++i) {}> |
|
14 | if (!Array.prototype.product) { |
44 | < m; ++i) {if (!Array.prototype.product) {> |
|
15 | Array.prototype.product = function(b) { |
45 | < m; ++i) { Array.prototype.product = function(b) {> |
|
16 | return wasProduct(this, b); |
46 | < m; ++i) { return wasProduct(this, b);> |
|
17 | }; |
47 | < m; ++i) { };> |
|
18 | } |
48 | < m; ++i) {}> |
|
19 | // jQuery |
49 | < m; ++i) {// jQuery> |
|
20 | if(typeof jQuery === 'function') { |
50 | < m; ++i) {if(typeof jQuery === 'function') {> |
|
21 | $.extend({ |
51 | < m; ++i) { $.extend({> |
|
22 | product: wasProduct |
52 | < m; ++i) { product: wasProduct> |
|
23 | }); |
53 | < m; ++i) { });> |
|
24 | } |
54 | < m; ++i) {}> |
|
25 | |
55 | < m; ++i) {> |
|
26 | /*************************************************************************/ |
56 | < m; ++i) {/*************************************************************************/> |
|
27 | /* Copyright (C) 2017 Wizardry and Steamworks - License: GNU GPLv3 */ |
57 | < m; ++i) {/* Copyright (C) 2017 Wizardry and Steamworks - License: GNU GPLv3 */> |
|
28 | /*************************************************************************/ |
58 | < m; ++i) {/*************************************************************************/> |
|
29 | function wasStride(a, s) { |
59 | < m; ++i) {function wasStride(a, s) {> |
|
30 | return a.filter(function(e, i) { |
60 | < m; ++i) { return a.filter(function(e, i) {> |
|
31 | return i % s === 0; |
61 | < m; ++i) { return i % s === 0;> |
|
32 | }); |
62 | < m; ++i) { });> |
|
33 | } |
63 | < m; ++i) {}> |
|
34 | if (!Array.prototype.stride) { |
64 | < m; ++i) {if (!Array.prototype.stride) {> |
|
35 | Array.prototype.stride = function(s) { |
65 | < m; ++i) { Array.prototype.stride = function(s) {> |
|
36 | return wasStride(this, s); |
66 | < m; ++i) { return wasStride(this, s);> |
|
37 | }; |
67 | < m; ++i) { };> |
|
38 | } |
68 | < m; ++i) {}> |
|
39 | // jQuery |
69 | < m; ++i) {// jQuery> |
|
40 | if(typeof jQuery === 'function') { |
70 | < m; ++i) {if(typeof jQuery === 'function') {> |
|
41 | $.extend({ |
71 | < m; ++i) { $.extend({> |
|
42 | stride: wasStride |
72 | < m; ++i) { stride: wasStride> |
|
43 | }); |
73 | < m; ++i) { });> |
|
44 | } |
74 | < m; ++i) {}> |
|
45 | |
75 | < m; ++i) {> |
|
46 | // Vanilla JavaScript |
76 | < m; ++i) {// Vanilla JavaScript> |
|
47 | function wasChunk(a, n) { |
77 | < m; ++i) {function wasChunk(a, n) {> |
|
48 | return Array.from(new Array(Math.ceil(a.length/n)), (_,i)=>a.slice(i*n,i*n+n)); |
78 | < m; ++i) { return Array.from(new Array(Math.ceil(a.length/n)), (_,i)=>a.slice(i*n,i*n+n));> |
|
49 | } |
79 | < m; ++i) {}> |
|
50 | if (!Array.prototype.chunk) { |
80 | < m; ++i) {if (!Array.prototype.chunk) {> |
|
51 | Array.prototype.chunk = function(a, n) { |
81 | < m; ++i) { Array.prototype.chunk = function(a, n) {> |
|
52 | return wasChunk(this, n); |
82 | < m; ++i) { return wasChunk(this, n);> |
|
53 | }; |
83 | < m; ++i) { };> |
|
54 | } |
84 | < m; ++i) {}> |
|
55 | // jQuery |
85 | < m; ++i) {// jQuery> |
|
56 | if(typeof jQuery === 'function') { |
86 | < m; ++i) {if(typeof jQuery === 'function') {> |
|
57 | $.extend({ |
87 | < m; ++i) { $.extend({> |
|
58 | chunk: wasChunk |
88 | < m; ++i) { chunk: wasChunk> |
|
59 | }); |
89 | < m; ++i) { });> |
|
60 | } |
90 | < m; ++i) {}> |
|
61 | |
91 | < m; ++i) {> |
|
62 | /*************************************************************************/ |
92 | < m; ++i) {/*************************************************************************/> |
|
63 | /* Copyright (C) 2017 Wizardry and Steamworks - License: GNU GPLv3 */ |
93 | < m; ++i) {/* Copyright (C) 2017 Wizardry and Steamworks - License: GNU GPLv3 */> |
|
64 | /*************************************************************************/ |
94 | < m; ++i) {/*************************************************************************/> |
|
65 | /*stackoverflow.com/questions/7837456/how-to-compare-arrays-in-javascript*/ |
95 | < m; ++i) {/*stackoverflow.com/questions/7837456/how-to-compare-arrays-in-javascript*/> |
|
66 | /*************************************************************************/ |
96 | < m; ++i) {/*************************************************************************/> |
|
67 | // Vanilla JavaScript |
97 | < m; ++i) {// Vanilla JavaScript> |
|
68 | function wasEquals(a, b) { |
98 | < m; ++i) {function wasEquals(a, b) {> |
|
69 | // if the other array is a falsy value, return |
99 | < m; ++i) { // if the other array is a falsy value, return> |
|
70 | if (!b) { |
100 | < m; ++i) { if (!b) {> |
|
71 | return false; |
101 | < m; ++i) { return false;> |
|
72 | } |
102 | < m; ++i) { }> |
|
73 | |
103 | < m; ++i) {> |
|
74 | // compare lengths - can save a lot of time |
104 | < m; ++i) { // compare lengths - can save a lot of time > |
|
75 | if (a.length !== b.length) { |
105 | < m; ++i) { if (a.length !== b.length) {> |
|
76 | return false; |
106 | < m; ++i) { return false;> |
|
77 | } |
107 | < m; ++i) { }> |
|
78 | |
108 | < m; ++i) {> |
|
79 | for (var i = 0, l = a.length; i < l; i++) { |
109 | < m; ++i) { for (var i = 0, l = a.length; i < l; i++) {> |
|
80 | // Check if we have nested arrays |
110 | < m; ++i) { // Check if we have nested arrays> |
|
81 | if (a[i] instanceof Array && b[i] instanceof Array) { |
111 | < m; ++i) { if (a[i] instanceof Array && b[i] instanceof Array) {> |
|
82 | // recurse into the nested arrays |
112 | < m; ++i) { // recurse into the nested arrays> |
|
83 | if (!a[i].equals(b[i])) { |
113 | < m; ++i) { if (!a[i].equals(b[i])) {> |
|
84 | return false; |
114 | < m; ++i) { return false;> |
|
85 | } |
115 | < m; ++i) { }> |
|
86 | } else if (a[i] !== b[i]) { |
116 | < m; ++i) { } else if (a[i] !== b[i]) {> |
|
87 | // Warning - two different object instances will never be equal: {x:20} != {x:20} |
117 | < m; ++i) { // Warning - two different object instances will never be equal: {x:20} != {x:20}> |
|
88 | return false; |
118 | < m; ++i) { return false;> |
|
89 | } |
119 | < m; ++i) { }> |
|
90 | } |
120 | < m; ++i) { }> |
|
91 | return true; |
121 | < m; ++i) { return true;> |
|
92 | } |
122 | < m; ++i) {}> |
|
93 | if (!Array.prototype.equals) { |
123 | < m; ++i) {if (!Array.prototype.equals) {> |
|
94 | // attach the .equals method to Array's prototype to call it on any array |
124 | < m; ++i) { // attach the .equals method to Array's prototype to call it on any array> |
|
95 | Array.prototype.equals = function(a, b) { |
125 | < m; ++i) { Array.prototype.equals = function(a, b) {> |
|
96 | return wasEquals(this, b); |
126 | < m; ++i) { return wasEquals(this, b);> |
|
97 | }; |
127 | < m; ++i) { };> |
|
98 | } |
128 | < m; ++i) {}> |
|
99 | // jQuery |
129 | < m; ++i) {// jQuery> |
|
100 | if(typeof jQuery === 'function') { |
130 | < m; ++i) {if(typeof jQuery === 'function') {> |
|
101 | $.extend({ |
131 | < m; ++i) { $.extend({> |
|
102 | equals: wasEquals |
132 | < m; ++i) { equals: wasEquals> |
|
103 | }); |
133 | < m; ++i) { });> |
|
104 | } |
134 | < m; ++i) {}> |
|
105 | |
135 | < m; ++i) {> |
|
106 | /*************************************************************************/ |
136 | < m; ++i) {/*************************************************************************/> |
|
107 | /* Node.JS package export. */ |
137 | < m; ++i) {/* Node.JS package export. */> |
|
108 | /*************************************************************************/ |
138 | < m; ++i) {/*************************************************************************/> |
|
109 | if(typeof module !== 'undefined' && typeof module.exports !== 'undefined') { |
139 | < m; ++i) {if(typeof module !== 'undefined' && typeof module.exports !== 'undefined') {> |
|
110 | module.exports.collections = { |
140 | < m; ++i) { module.exports.collections = {> |
|
111 | product: wasProduct, |
141 | < m; ++i) { product: wasProduct,> |
|
112 | stride: wasStride, |
142 | < m; ++i) { stride: wasStride,> |
|
113 | chunk: wasChunk, |
143 | < m; ++i) { chunk: wasChunk,> |
|
114 | equals: wasEquals |
144 | < m; ++i) { equals: wasEquals,> |
|
- | 145 | < m; ++i) { toObject: wasArrayToObject> |
||
115 | }; |
146 | < m; ++i) { };> |
|
116 | } |
147 | < m; ++i) {}> |
|
117 | |
148 | < m; ++i) {> |
|
118 | /* Copyright (C) 2015 Wizardry and Steamworks - License: GNU GPLv3 */ |
149 | < m; ++i) {/* Copyright (C) 2015 Wizardry and Steamworks - License: GNU GPLv3 */> |
|
119 | /*************************************************************************/ |
150 | < m; ++i) {/*************************************************************************/> |
|
120 | function wasCSVToArray(csv) { |
151 | < m; ++i) {function wasCSVToArray(csv) {> |
|
121 | var l = []; |
152 | < m; ++i) { var l = [];> |
|
122 | var s = []; |
153 | < m; ++i) { var s = [];> |
|
123 | var m = ""; |
154 | < m; ++i) { var m = "";> |
|
124 | |
155 | < m; ++i) { > |
|
125 | do { |
156 | < m; ++i) { do {> |
|
126 | var a = csv.charAt(0); |
157 | < m; ++i) { var a = csv.charAt(0);> |
|
127 | csv = csv.slice(1, csv.length); |
158 | < m; ++i) { csv = csv.slice(1, csv.length);> |
|
128 | if(a === ",") { |
159 | < m; ++i) { if(a === ",") {> |
|
129 | if(s[s.length-1] !== '"') { |
160 | < m; ++i) { if(s[s.length-1] !== '"') {> |
|
130 | l.push(m); |
161 | < m; ++i) { l.push(m);> |
|
131 | m = ""; |
162 | < m; ++i) { m = "";> |
|
132 | continue; |
163 | < m; ++i) { continue;> |
|
133 | } |
164 | < m; ++i) { }> |
|
134 | m += a; |
165 | < m; ++i) { m += a;> |
|
135 | continue; |
166 | < m; ++i) { continue;> |
|
136 | } |
167 | < m; ++i) { }> |
|
137 | if(a === '"' && csv.charAt(0) === a) { |
168 | < m; ++i) { if(a === '"' && csv.charAt(0) === a) {> |
|
138 | m += a; |
169 | < m; ++i) { m += a;> |
|
139 | csv = csv.slice(1, csv.length); |
170 | < m; ++i) { csv = csv.slice(1, csv.length);> |
|
140 | continue; |
171 | < m; ++i) { continue;> |
|
141 | } |
172 | < m; ++i) { }> |
|
142 | if(a === '"') { |
173 | < m; ++i) { if(a === '"') {> |
|
143 | if(s[s.length-1] !== a) { |
174 | < m; ++i) { if(s[s.length-1] !== a) {> |
|
144 | s.push(a); |
175 | < m; ++i) { s.push(a);> |
|
145 | continue; |
176 | < m; ++i) { continue;> |
|
146 | } |
177 | < m; ++i) { }> |
|
147 | s.pop(); |
178 | < m; ++i) { s.pop();> |
|
148 | continue; |
179 | < m; ++i) { continue;> |
|
149 | } |
180 | < m; ++i) { }> |
|
150 | m += a; |
181 | < m; ++i) { m += a;> |
|
151 | } while(csv !== ""); |
182 | < m; ++i) { } while(csv !== "");> |
|
152 | |
183 | < m; ++i) { > |
|
153 | l.push(m); |
184 | < m; ++i) { l.push(m);> |
|
154 | |
185 | < m; ++i) { > |
|
155 | return l; |
186 | < m; ++i) { return l;> |
|
156 | } |
187 | < m; ++i) {}> |
|
157 | |
188 | < m; ++i) {> |
|
158 | /*************************************************************************/ |
189 | < m; ++i) {/*************************************************************************/> |
|
159 | /* Copyright (C) 2015 Wizardry and Steamworks - License: GNU GPLv3 */ |
190 | < m; ++i) {/* Copyright (C) 2015 Wizardry and Steamworks - License: GNU GPLv3 */> |
|
160 | /*************************************************************************/ |
191 | < m; ++i) {/*************************************************************************/> |
|
161 | function wasArrayToCSV(a) { |
192 | < m; ++i) {function wasArrayToCSV(a) {> |
|
162 | var csv = []; |
193 | < m; ++i) { var csv = [];> |
|
163 | for(var i=0; i<a.length; ++i) { |
194 | < m; ++i) { for(var i=0; i<a.length; ++i) {> |
|
164 | var cell = a[i].toString().replace('"', '""'); |
195 | < m; ++i) { var cell = a[i].toString().replace('"', '""');> |
|
165 | if(/"\s,\r\n/.test(cell)) { |
196 | < m; ++i) { if(/"\s,\r\n/.test(cell)) {> |
|
166 | csv[i] = '"' + cell + '"'; |
197 | < m; ++i) { csv[i] = '"' + cell + '"';> |
|
167 | continue; |
198 | < m; ++i) { continue;> |
|
168 | } |
199 | < m; ++i) { }> |
|
169 | csv[i] = cell; |
200 | < m; ++i) { csv[i] = cell;> |
|
170 | } |
201 | < m; ++i) { }> |
|
171 | return csv.join(); |
202 | < m; ++i) { return csv.join();> |
|
172 | } |
203 | < m; ++i) {}> |
|
173 | |
204 | < m; ++i) {> |
|
174 | /* Node.JS package export. */ |
205 | < m; ++i) {/* Node.JS package export. */> |
|
175 | /*************************************************************************/ |
206 | < m; ++i) {/*************************************************************************/> |
|
176 | if(typeof module !== 'undefined' && typeof module.exports !== 'undefined') { |
207 | < m; ++i) {if(typeof module !== 'undefined' && typeof module.exports !== 'undefined') {> |
|
177 | /* global wasCSVToArray, wasArrayToCSV, wasKeyValueToObject, wasKeyValueGet, wasKeyValueSet */ |
208 | < m; ++i) { /* global wasCSVToArray, wasArrayToCSV, wasKeyValueToObject, wasKeyValueGet, wasKeyValueSet */> |
|
178 | module.exports.formats = { |
209 | < m; ++i) { module.exports.formats = {> |
|
179 | csv: { |
210 | < m; ++i) { csv: {> |
|
180 | CSVToArray: wasCSVToArray, |
211 | < m; ++i) { CSVToArray: wasCSVToArray,> |
|
181 | ArrayToCSV: wasArrayToCSV |
212 | < m; ++i) { ArrayToCSV: wasArrayToCSV> |
|
182 | }, |
213 | < m; ++i) { },> |
|
183 | kvp: { |
214 | < m; ++i) { kvp: {> |
|
184 | KeyValueToObject: wasKeyValueToObject, |
215 | < m; ++i) { KeyValueToObject: wasKeyValueToObject,> |
|
185 | KeyValueGet: wasKeyValueGet, |
216 | < m; ++i) { KeyValueGet: wasKeyValueGet,> |
|
186 | KeyValueSet: wasKeyValueSet |
217 | < m; ++i) { KeyValueSet: wasKeyValueSet> |
|
187 | } |
218 | < m; ++i) { }> |
|
188 | }; |
219 | < m; ++i) { };> |
|
189 | } |
220 | < m; ++i) {}> |
|
190 | |
221 | < m; ++i) {> |
|
191 | /* Copyright (C) 2017 Wizardry and Steamworks - License: GNU GPLv3 */ |
222 | < m; ++i) {/* Copyright (C) 2020 Wizardry and Steamworks - License: GNU GPLv3 */> |
|
192 | /*************************************************************************/ |
223 | < m; ++i) {/*************************************************************************/> |
|
193 | function wasKeyValueToObject(a) { |
224 | < m; ++i) {function wasKeyValueToObject(data) {> |
|
194 | var o = {}; |
225 | < m; ++i) { var result = {};> |
|
195 | a.reduce(function(a, c, i) { |
226 | < m; ++i) { data.split('&').forEach((kvp) => {> |
|
196 | i = Math.floor(i / 2); |
- | ||
197 | if (!a[i]) { |
227 | < m; ++i) { var kv = kvp.split('=')> |
|
198 | a[i] = []; |
- | ||
199 | } |
- | ||
200 | a[i].push(c); |
- | ||
201 | return a; |
228 | < m; ++i) { .filter((kv) => > |
|
202 | }, []).forEach(function(c, i, a) { |
229 | < m; ++i) { kv[0] !== 'undefined' && kv[1] !== 'undefined'); > |
|
- | 230 | < m; ++i) { result[kv[0]] = kv[1];> |
||
203 | o[c[0]] = c[1]; |
231 | < m; ++i) {> |
|
204 | }, o); |
232 | < m; ++i) { });> |
|
205 | return o; |
233 | < m; ++i) { return result;> |
|
206 | } |
234 | < m; ++i) {}> |
|
207 | |
235 | < m; ++i) {> |
|
208 | /*************************************************************************/ |
236 | < m; ++i) {/*************************************************************************/> |
|
209 | /* Copyright (C) 2017 Wizardry and Steamworks - License: GNU GPLv3 */ |
237 | < m; ++i) {/* Copyright (C) 2017 Wizardry and Steamworks - License: GNU GPLv3 */> |
|
210 | /*************************************************************************/ |
238 | < m; ++i) {/*************************************************************************/> |
|
211 | function wasKeyValueSet(k, v, data) { |
239 | < m; ++i) {function wasKeyValueSet(k, v, data) {> |
|
212 | return data.split('&') |
240 | < m; ++i) { return data.split('&')> |
|
213 | .map(c => c.split('=')[0] === k ? `${k}=${v}` : c) |
241 | < m; ++i) { .map(c => c.split('=')[0] === k ? `${k}=${v}` : c)> |
|
214 | .concat(`${k}=${v}`) |
242 | < m; ++i) { .concat(`${k}=${v}`)> |
|
215 | .filter((e,i,s) => s.indexOf(e) === i) |
243 | < m; ++i) { .filter((e,i,s) => s.indexOf(e) === i)> |
|
216 | .join('&'); |
244 | < m; ++i) { .join('&');> |
|
217 | } |
245 | < m; ++i) {}> |
|
218 | |
246 | < m; ++i) {> |
|
219 | |
247 | < m; ++i) {> |
|
220 | /*************************************************************************/ |
248 | < m; ++i) {/*************************************************************************/> |
|
221 | /* Copyright (C) 2017 Wizardry and Steamworks - License: GNU GPLv3 */ |
249 | < m; ++i) {/* Copyright (C) 2017 Wizardry and Steamworks - License: GNU GPLv3 */> |
|
222 | /*************************************************************************/ |
250 | < m; ++i) {/*************************************************************************/> |
|
223 | function wasKeyValueGet(k, data) { |
251 | < m; ++i) {function wasKeyValueGet(k, data) {> |
|
224 | return data.split('&').reduce((a, c) => { |
252 | < m; ++i) { return data.split('&').reduce((a, c) => {> |
|
225 | var s = c.split('='); |
253 | < m; ++i) { var s = c.split('=');> |
|
226 | return s[0] === k ? s[1] : a; |
254 | < m; ++i) { return s[0] === k ? s[1] : a;> |
|
227 | }, ''); |
255 | < m; ++i) { }, '');> |
|
228 | } |
256 | < m; ++i) {}> |
|
229 | /* Copyright (C) 2017 Wizardry and Steamworks - License: GNU GPLv3 */ |
257 | < m; ++i) {/* Copyright (C) 2017 Wizardry and Steamworks - License: GNU GPLv3 */> |
|
230 | /*************************************************************************/ |
258 | < m; ++i) {/*************************************************************************/> |
|
231 | /* fuss/lambda_calculus/functional_programming/aggregators @ grimore.org */ |
259 | < m; ++i) {/* fuss/lambda_calculus/functional_programming/aggregators @ grimore.org */> |
|
232 | /*************************************************************************/ |
260 | < m; ++i) {/*************************************************************************/> |
|
233 | function wasSwitch(q, d, ...c) { |
261 | < m; ++i) {function wasSwitch(q, d, ...c) {> |
|
234 | if(c.length % 2 !== 0) { |
262 | < m; ++i) { if(c.length % 2 !== 0) {> |
|
235 | throw "Pairs of predicates expected for cases"; |
263 | < m; ++i) { throw "Pairs of predicates expected for cases";> |
|
236 | } |
264 | < m; ++i) { }> |
|
237 | |
265 | < m; ++i) { > |
|
238 | (Array.isArray(q) ? q : [ q ]).forEach((s) => { |
266 | < m; ++i) { (Array.isArray(q) ? q : [ q ]).forEach((s) => {> |
|
239 | var m = false; |
267 | < m; ++i) { var m = false;> |
|
240 | for(var i = 0; i < c.length; i += 2) { |
268 | < m; ++i) { for(var i = 0; i < c.length; i += 2) {> |
|
241 | if(!c[i](s)) { |
269 | < m; ++i) { if(!c[i](s)) {> |
|
242 | continue; |
270 | < m; ++i) { continue;> |
|
243 | } |
271 | < m; ++i) { }> |
|
244 | if(!c[i + 1](s)) { |
272 | < m; ++i) { if(!c[i + 1](s)) {> |
|
245 | continue; |
273 | < m; ++i) { continue;> |
|
246 | } |
274 | < m; ++i) { }> |
|
247 | m = true; |
275 | < m; ++i) { m = true;> |
|
248 | } |
276 | < m; ++i) { }> |
|
249 | |
277 | < m; ++i) { > |
|
250 | if(!m) { |
278 | < m; ++i) { if(!m) {> |
|
251 | d(s); |
279 | < m; ++i) { d(s);> |
|
252 | } |
280 | < m; ++i) { }> |
|
253 | }); |
281 | < m; ++i) { });> |
|
254 | } |
282 | < m; ++i) {}> |
|
255 | if (!Array.prototype.switch) { |
283 | < m; ++i) {if (!Array.prototype.switch) {> |
|
256 | Array.prototype.switch = function() { |
284 | < m; ++i) { Array.prototype.switch = function() {> |
|
257 | wasSwitch(this, arguments[0], arguments.slice(1)); |
285 | < m; ++i) { wasSwitch(this, arguments[0], arguments.slice(1));> |
|
258 | }; |
286 | < m; ++i) { };> |
|
259 | } |
287 | < m; ++i) {}> |
|
260 | // jQuery |
288 | < m; ++i) {// jQuery> |
|
261 | if(typeof jQuery === 'function') { |
289 | < m; ++i) {if(typeof jQuery === 'function') {> |
|
262 | $.extend({ |
290 | < m; ++i) { $.extend({> |
|
263 | switch: wasSwitch |
291 | < m; ++i) { switch: wasSwitch> |
|
264 | }); |
292 | < m; ++i) { });> |
|
265 | } |
293 | < m; ++i) {}> |
|
266 | |
294 | < m; ++i) {> |
|
267 | /*************************************************************************/ |
295 | < m; ++i) {/*************************************************************************/> |
|
268 | /* Node.JS package export. */ |
296 | < m; ++i) {/* Node.JS package export. */> |
|
269 | /*************************************************************************/ |
297 | < m; ++i) {/*************************************************************************/> |
|
270 | if(typeof module !== 'undefined' && typeof module.exports !== 'undefined') { |
298 | < m; ++i) {if(typeof module !== 'undefined' && typeof module.exports !== 'undefined') {> |
|
271 | module.exports.lambda = { |
299 | < m; ++i) { module.exports.lambda = {> |
|
272 | switch: wasSwitch |
300 | < m; ++i) { switch: wasSwitch> |
|
273 | }; |
301 | < m; ++i) { };> |
|
274 | } |
302 | < m; ++i) {}> |
|
275 | |
303 | < m; ++i) {> |
|
276 | /* Copyright (C) 2015 Wizardry and Steamworks - License: GNU GPLv3 */ |
304 | < m; ++i) {/* Copyright (C) 2015 Wizardry and Steamworks - License: GNU GPLv3 */> |
|
277 | /*************************************************************************/ |
305 | < m; ++i) {/*************************************************************************/> |
|
278 | function wasMapValueToRange(value, xMin, xMax, yMin, yMax) { |
306 | < m; ++i) {function wasMapValueToRange(value, xMin, xMax, yMin, yMax) {> |
|
279 | return yMin + ( |
307 | < m; ++i) { return yMin + (> |
|
280 | ( yMax - yMin ) * ( value - xMin ) / ( xMax - xMin ) |
308 | < m; ++i) { ( yMax - yMin ) * ( value - xMin ) / ( xMax - xMin )> |
|
281 | ); |
309 | < m; ++i) { );> |
|
282 | } |
310 | < m; ++i) {}> |
|
283 | |
311 | < m; ++i) {> |
|
284 | /*************************************************************************/ |
312 | < m; ++i) {/*************************************************************************/> |
|
285 | /* Node.JS package export. */ |
313 | < m; ++i) {/* Node.JS package export. */> |
|
286 | /*************************************************************************/ |
314 | < m; ++i) {/*************************************************************************/> |
|
287 | if(typeof module !== 'undefined' && typeof module.exports !== 'undefined') { |
315 | < m; ++i) {if(typeof module !== 'undefined' && typeof module.exports !== 'undefined') {> |
|
288 | module.exports.mathematics = { |
316 | < m; ++i) { module.exports.mathematics = {> |
|
289 | MapValueToRange: wasMapValueToRange |
317 | < m; ++i) { MapValueToRange: wasMapValueToRange> |
|
290 | }; |
318 | < m; ++i) { };> |
|
291 | } |
319 | < m; ++i) {}> |
|
292 | |
320 | < m; ++i) {> |
|
293 | /* Copyright (C) 2015 Wizardry and Steamworks - License: GNU GPLv3 */ |
321 | < m; ++i) {/* Copyright (C) 2015 Wizardry and Steamworks - License: GNU GPLv3 */> |
|
294 | /*************************************************************************/ |
322 | < m; ++i) {/*************************************************************************/> |
|
295 | function wasHexToRGB(hex) { |
323 | < m; ++i) {function wasHexToRGB(hex) {> |
|
296 | var shortRegEx = /^#?([a-f\d])([a-f\d])([a-f\d])$/i; |
324 | < m; ++i) { var shortRegEx = /^#?([a-f\d])([a-f\d])([a-f\d])$/i;> |
|
297 | hex = hex.replace( |
325 | < m; ++i) { hex = hex.replace(> |
|
298 | shortRegEx, |
326 | < m; ++i) { shortRegEx,> |
|
299 | function(m, r, g, b) { |
327 | < m; ++i) { function(m, r, g, b) {> |
|
300 | return r + r + g + g + b + b; |
328 | < m; ++i) { return r + r + g + g + b + b;> |
|
301 | } |
329 | < m; ++i) { }> |
|
302 | ); |
330 | < m; ++i) { );> |
|
303 | |
331 | < m; ++i) {> |
|
304 | var result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex); |
332 | < m; ++i) { var result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);> |
|
305 | return result ? { |
333 | < m; ++i) { return result ? {> |
|
306 | r: parseInt(result[1], 16), |
334 | < m; ++i) { r: parseInt(result[1], 16),> |
|
307 | g: parseInt(result[2], 16), |
335 | < m; ++i) { g: parseInt(result[2], 16),> |
|
308 | b: parseInt(result[3], 16) |
336 | < m; ++i) { b: parseInt(result[3], 16)> |
|
309 | } : null; |
337 | < m; ++i) { } : null;> |
|
310 | } |
338 | < m; ++i) {}> |
|
311 | |
339 | < m; ++i) {> |
|
312 | /*************************************************************************/ |
340 | < m; ++i) {/*************************************************************************/> |
|
313 | /* Copyright (C) 2015 Wizardry and Steamworks - License: GNU GPLv3 */ |
341 | < m; ++i) {/* Copyright (C) 2015 Wizardry and Steamworks - License: GNU GPLv3 */> |
|
314 | /*************************************************************************/ |
342 | < m; ++i) {/*************************************************************************/> |
|
315 | function wasRGBToHex(r, g, b) { |
343 | < m; ++i) {function wasRGBToHex(r, g, b) {> |
|
316 | return "#" + ( |
344 | < m; ++i) { return "#" + (> |
|
317 | (1 << 24) +><> |
345 | < m; ++i) { (1 << 24) +><>> |
|
318 | |
346 | < m; ++i) {<< 24) +< 24) + (r << 16) +><>><>> |
|
319 | |
347 | < m; ++i) {<< 24) +< 24) +<< 16) +< 16) + (g << 8) +><>><>><>> |
|
320 | |
348 | < m; ++i) {<< 24) +< 24) +<< 16) +< 16) +<< 8) +< 8) + b><>><>><>> |
|
321 | |
349 | < m; ++i) {<< 24) +< 24) +<< 16) +< 16) +<< 8) +< 8) + ).toString(16).slice(1);><>><>><>> |
|
322 | |
350 | < m; ++i) {<< 24) +< 24) +<< 16) +< 16) +<< 8) +< 8) +}><>><>><>> |
|
323 | |
351 | < m; ++i) {<< 24) +< 24) +<< 16) +< 16) +<< 8) +< 8) +><>><>><>> |
|
324 | |
352 | < m; ++i) {<< 24) +< 24) +<< 16) +< 16) +<< 8) +< 8) +/*************************************************************************/><>><>><>> |
|
325 | |
353 | < m; ++i) {<< 24) +< 24) +<< 16) +< 16) +<< 8) +< 8) +/* Node.JS package export. */><>><>><>> |
|
326 | |
354 | < m; ++i) {<< 24) +< 24) +<< 16) +< 16) +<< 8) +< 8) +/*************************************************************************/><>><>><>> |
|
327 | |
355 | < m; ++i) {<< 24) +< 24) +<< 16) +< 16) +<< 8) +< 8) +if(typeof module !== 'undefined' && typeof module.exports !== 'undefined') {><>><>><>> |
|
328 | |
356 | < m; ++i) {<< 24) +< 24) +<< 16) +< 16) +<< 8) +< 8) + module.exports.physics = {><>><>><>> |
|
329 | |
357 | < m; ++i) {<< 24) +< 24) +<< 16) +< 16) +<< 8) +< 8) + HexToRGB: wasHexToRGB,><>><>><>> |
|
330 | |
358 | < m; ++i) {<< 24) +< 24) +<< 16) +< 16) +<< 8) +< 8) + RGBToHex: wasRGBToHex><>><>><>> |
|
331 | |
359 | < m; ++i) {<< 24) +< 24) +<< 16) +< 16) +<< 8) +< 8) + };><>><>><>> |
|
332 | |
360 | < m; ++i) {<< 24) +< 24) +<< 16) +< 16) +<< 8) +< 8) +}><>><>><>> |
|
333 | |
361 | < m; ++i) {<< 24) +< 24) +<< 16) +< 16) +<< 8) +< 8) +><>><>><>> |
|
334 | |
362 | < m; ++i) {<< 24) +< 24) +<< 16) +< 16) +<< 8) +< 8) + |
|
335 | |
363 | < m; ++i) {<< 24) +< 24) +<< 16) +< 16) +<< 8) +< 8) + |
|
336 | |
364 | < m; ++i) {<< 24) +< 24) +<< 16) +< 16) +<< 8) +< 8) + |