Below is a Javascript code which attempts to parse some protobuf input data.
'use strict';
import protobuf from 'protobufjs';
const proto = protobuf.loadSync('gtfs-realtime.proto');
const FeedMessage = proto.lookupType('transit_realtime.FeedMessage');
// sources is an array of Buffer containing the binary input
// const inputs = sources.map(FeedMessage.decode.bind(FeedMessage)); // this line does not work
const inputs = sources.map(x => FeedMessage.decode(x));
console.log(inputs[0].toJSON());
Why isn’t FeedMessage.decode.bind(FeedMessage)
equivalent to x => FeedMessage.decode(x)
?