was.js – Diff between revs 51 and 53

Subversion Repositories:
Rev:
Show entire fileIgnore whitespace
Rev 51 Rev 53
Line 1... Line 1...
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];
Line 109... Line 139...
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) {}
Line 117... Line 148...
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 */
Line 186... Line 217...
186 KeyValueSet: wasKeyValueSet 217 < m; ++i) { KeyValueSet: wasKeyValueSet
187 } 218 < m; ++i) { }
188 }; 219 < m; ++i) { };
189 } 220 < m; ++i) {}
Line 190... Line 221...
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;
Line 206... Line 234...
206 } 234 < m; ++i) {}
207   235 < m; ++i) {
208 /*************************************************************************/ 236 < m; ++i) {/*************************************************************************/