let foo = Object.fromEntries(bar.map((v) => [v.id, v])); let foo = Object.fromEntries(bar.map((v) => [v.id, v])); import { map } from "my-iter-lib";
Object.fromEntries(map((v) => [v.id, v], bar));
Or with the proposed iterator-helpers: Object.fromEntries(
Iterator.from(bar).map((v) => [v.id, v]),
)
However the inner arrays are harder to get rid of... In fact even OP’s oneliner defines the inner arrays. I would hope there were some engine optimizations though which could minimize their footprint.