Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

objectConverter can work without Function. #94

Closed
KaKi87 opened this issue Nov 11, 2022 · 1 comment
Closed

objectConverter can work without Function. #94

KaKi87 opened this issue Nov 11, 2022 · 1 comment

Comments

@KaKi87
Copy link

KaKi87 commented Nov 11, 2022

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

@mbostock
Copy link
Member

Related #26 (comment) #80 #87.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants