was.js
/tags/1.0.2/lib/formats/kvp/kvp.js |
@@ -0,0 +1,26 @@ |
/*************************************************************************/ |
/* Copyright (C) 2017 Wizardry and Steamworks - License: GNU GPLv3 */ |
/*************************************************************************/ |
function wasKeyValueToObject(a) { |
var o = {}; |
a.reduce(function(a, c, i) { |
i = Math.floor(i / 2); |
if (!a[i]) { |
a[i] = []; |
} |
a[i].push(c); |
return a; |
}, []).forEach(function(c, i, a) { |
o[c[0]] = c[1]; |
}, o); |
return o; |
} |
|
/*************************************************************************/ |
/* Node.JS package export. */ |
/*************************************************************************/ |
if(typeof variable !== 'undefined') { |
module.exports.formats = { |
KeyValueToObject: wasKeyValueToObject |
}; |
} |