{"library":"proto-parser","title":"Proto Parser","description":"proto-parser is a JavaScript/TypeScript library specifically designed to parse Protocol Buffer (proto) files and generate an Abstract Syntax Tree (AST). Currently at version 0.0.9, it is in early development, suggesting potential for rapid updates and API evolution, though no explicit release cadence is mentioned beyond frequent updates. Unlike `protobuf.js`, on which it is partially based and from which it reuses some code, `proto-parser` focuses exclusively on the parsing aspect, omitting encoding/decoding functionalities. This specialization results in a smaller codebase, improved performance, and a 'purer' AST structure. It offers native TypeScript support and aims for basic AST compatibility with `protobuf.js`, making it suitable for users who primarily need to analyze or transform proto definitions without the overhead of runtime message handling.","language":"javascript","status":"active","last_verified":"Sun Apr 19","install":{"commands":["npm install proto-parser"],"cli":null},"imports":["import * as t from 'proto-parser';\nconst protoDocument = t.parse(content);","import type { ProtoDocument } from 'proto-parser';","const protoParser = require('proto-parser');\nconst protoDocument = protoParser.parse(content);"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import * as t from 'proto-parser';\n\nconst content = `\nsyntax = 'proto3';\n\npackage myapp.v1;\n\n// A simple message for demonstration\nmessage Foo {\n  string key = 1; // Unique identifier\n  int32 value = 2; // Associated integer value\n  repeated string tags = 3; // List of tags\n}\n`;\n\nconst protoDocument = t.parse(content, { keepCase: false, resolve: true }) as t.ProtoDocument;\n\nif (protoDocument && 'root' in protoDocument && protoDocument.root && protoDocument.root.nested) {\n  console.log('Successfully parsed proto file. Root definition:');\n  console.log(JSON.stringify(protoDocument.root.nested.Foo, null, 2));\n} else if ('message' in protoDocument) {\n  console.error('Parsing failed:', protoDocument.message); // Handle ProtoError case\n} else {\n  console.error('Unexpected parsing result.');\n}","lang":"typescript","description":"Demonstrates parsing a proto3 file content string into an AST, with options.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}