@c_phillips/ipp-browser
Version:
IPP for the browse and node
24 lines • 788 B
JavaScript
// To serialize and deserialize, we need to be able to look
// things up by key or by value. This little helper just
// converts the arrays to objects and tacks on a 'lookup' property.
export function xref(arr) {
let obj = {};
arr.forEach(function (item, index) {
obj[item] = index;
});
obj.lookup = arr;
return obj;
}
export function extend(destination, source) {
for (let property in source) {
if (source[property] && source[property].constructor === Object) {
destination[property] = destination[property] || {};
extend(destination[property], source[property]);
}
else {
destination[property] = source[property];
}
}
return destination;
}
//# sourceMappingURL=ipputil.js.map