d3/d3-dsv

`objectConverter` can work without `Function`.

KaKi87 opened this issue · 1 comments

Hello,

The objectConverter function, if I understand it correctly, takes an array of keys, and returns a function, that takes an array of values, and returns an object.

I'm guessing preserving IE11 compatibility was the goal, so here's an alternative that still does, while working without Function :

function objectConverter(columns){
    return function(d){
        var o = {};
        columns.forEach(function(name, i){
            o[name] = d[i];
        });
        return o;
    };
}

And, for future reference, here's another one that uses the latest syntax :

const objectConverter = columns => d => Object.fromEntries(columns.map((name, i) => [name, d[i]]));

Thanks