
Security News
Axios Supply Chain Attack Reaches OpenAI macOS Signing Pipeline, Forces Certificate Rotation
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.
protobuf-array-stream
Advanced tools
Stream and decode Protocol Buffer arrays without memory issues - perfect for processing large datasets
Stream and decode Protocol Buffer arrays without memory issues. While other libraries need the entire message in memory, this one processes array elements directly from the source stream - making it perfect for large datasets.
npm install protobuf-array-stream
First, you need to load your Protocol Buffer definitions. The library exposes these methods directly from protobufjs for convenience:
import { RepeatedFieldStream } from "protobuf-array-stream";
import { createReadStream } from "fs";
// 1. Load from a .proto file (async)
const root1 = await RepeatedFieldStream.loadRootFromFile(
"path/to/messages.proto",
);
// 2. Load from a .proto file (sync)
const root2 = RepeatedFieldStream.loadRootFromFileSync(
"path/to/messages.proto",
);
// 3. Load from a proto definition string
const root3 = RepeatedFieldStream.loadRootFromSource(`
syntax = "proto3";
message NumberList {
repeated int32 numbers = 1;
}
`);
// 4. Load from JSON schema
const root4 = RepeatedFieldStream.loadRootFromJSON({
nested: {
NumberList: {
fields: {
numbers: {
id: 1,
rule: "repeated",
type: "int32",
},
},
},
},
});
You're building an anti-cheat system for your massively multiplayer game. Players are generating TONS of data:
syntax = "proto3";
message GameLog {
repeated PlayerAction actions = 1;
}
message PlayerAction {
int64 timestamp = 1;
string player_id = 2;
string action = 3;
Position position = 4;
}
message Position {
float x = 1;
float y = 2;
float z = 3;
}
Process large game session logs efficiently:
const sessionStream = createReadStream("game_session.bin");
const decodeStream = new RepeatedFieldStream({
root,
messageName: "GameLog",
});
const analyzeStream = new Transform({
objectMode: true,
transform(action, _, callback) {
const { timestamp, playerId, action: move, position } = action;
if (move === "shoot" && position.y > 500) {
console.log(
`Detected: ${playerId} at height ${position.y} on ${new Date(timestamp.toNumber())}`,
);
}
callback(null, action);
},
});
sessionStream.pipe(decodeStream).pipe(analyzeStream);
The stream emits errors in these cases:
stream.on("error", (error) => {
console.error("Stream error:", error.message);
});
new RepeatedFieldStream(options)Creates a new transform stream for processing Protocol Buffer repeated fields.
root: Root namespace from protobufjs containing message definitionsmessageName: Name of the message type to decodeloadRootFromFile(path: string): Promise<Root>Asynchronously loads Protocol Buffer definitions from a .proto file.
path: Path to the .proto fileloadRootFromFileSync(path: string): RootSynchronously loads Protocol Buffer definitions from a .proto file.
path: Path to the .proto fileloadRootFromSource(source: string): RootLoads Protocol Buffer definitions from a string containing proto definitions.
source: String containing the proto definitionsloadRootFromJSON(json: object): RootLoads Protocol Buffer definitions from a JSON object.
json: JSON object containing the proto definitionsMIT License - see the LICENSE file for details
FAQs
Stream and decode Protocol Buffer arrays without memory issues - perfect for processing large datasets
We found that protobuf-array-stream demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.

Security News
Open source is under attack because of how much value it creates. It has been the foundation of every major software innovation for the last three decades. This is not the time to walk away from it.

Security News
Socket CEO Feross Aboukhadijeh breaks down how North Korea hijacked Axios and what it means for the future of software supply chain security.