• Version 0.7.10
  • Published
  • 118 kB
  • 4 dependencies
  • Apache-2.0 license


npm i @grpc/proto-loader
yarn add @grpc/proto-loader
pnpm add @grpc/proto-loader


gRPC utility library for loading .proto files



function fromJSON

fromJSON: (json: Protobuf.INamespace, options?: Options) => PackageDefinition;

    function isAnyExtension

    isAnyExtension: (obj: object) => obj is AnyExtension;

      function load

      load: (
      filename: string | string[],
      options?: Options
      ) => Promise<PackageDefinition>;
      • Load a .proto file with the specified options.

        Parameter filename

        One or multiple file paths to load. Can be an absolute path or relative to an include path.


        options.keepCase Preserve field names. The default is to change them to camel case.


        options.longs The type that should be used to represent long values. Valid options are Number and String. Defaults to a Long object type from a library.


        options.enums The type that should be used to represent enum values. The only valid option is String. Defaults to the numeric value.


        options.bytes The type that should be used to represent bytes values. Valid options are Array and String. The default is to use Buffer.


        options.defaults Set default values on output objects. Defaults to false.


        options.arrays Set empty arrays for missing array values even if defaults is false. Defaults to false.


        options.objects Set empty objects for missing object values even if defaults is false. Defaults to false.


        options.oneofs Set virtual oneof properties to the present field's name


        options.json Represent Infinity and NaN as strings in float fields, and automatically decode google.protobuf.Any values.


        options.includeDirs Paths to search for imported .proto files.

      function loadFileDescriptorSetFromBuffer

      loadFileDescriptorSetFromBuffer: (
      descriptorSet: Buffer,
      options?: Options
      ) => PackageDefinition;

        function loadFileDescriptorSetFromObject

        loadFileDescriptorSetFromObject: (
        descriptorSet: Parameters<typeof descriptor.FileDescriptorSet.fromObject>[0],
        options?: Options
        ) => PackageDefinition;

          function loadSync

          loadSync: (filename: string | string[], options?: Options) => PackageDefinition;


            interface AnyExtension

            interface AnyExtension {}
            • This type exists for use with code generated by the proto-loader-gen-types tool. This type should be used with another interface, e.g. MessageType & AnyExtension for an object that is converted to or from a google.protobuf.Any message. For example, when processing an Any message:

              if (isAnyExtension(message)) {
              switch (message['@type']) {
              case TYPE1_URL:
              handleType1(message as AnyExtension & Type1);
              case TYPE2_URL:
              handleType2(message as AnyExtension & Type2);
              // ...

            property '@type'

            '@type': string;
            • The fully qualified name of the message type that this object represents, possibly including a URL prefix.

            interface Deserialize

            interface Deserialize<T> {}

              call signature

              (bytes: Buffer): T;

                interface EnumTypeDefinition

                interface EnumTypeDefinition extends ProtobufTypeDefinition {}

                  property format

                  format: 'Protocol Buffer 3 EnumDescriptorProto';

                    interface MessageTypeDefinition

                    interface MessageTypeDefinition extends ProtobufTypeDefinition {}

                      property format

                      format: 'Protocol Buffer 3 DescriptorProto';

                        interface MethodDefinition

                        interface MethodDefinition<
                        OutputRequestType = RequestType,
                        OutputResponseType = ResponseType
                        > {}

                          property originalName

                          originalName?: string;

                            property path

                            path: string;

                              property requestDeserialize

                              requestDeserialize: Deserialize<OutputRequestType>;

                                property requestSerialize

                                requestSerialize: Serialize<RequestType>;

                                  property requestStream

                                  requestStream: boolean;

                                    property requestType

                                    requestType: MessageTypeDefinition;

                                      property responseDeserialize

                                      responseDeserialize: Deserialize<OutputResponseType>;

                                        property responseSerialize

                                        responseSerialize: Serialize<ResponseType>;

                                          property responseStream

                                          responseStream: boolean;

                                            property responseType

                                            responseType: MessageTypeDefinition;

                                              interface PackageDefinition

                                              interface PackageDefinition {}

                                                index signature

                                                [index: string]: AnyDefinition;

                                                  interface ProtobufTypeDefinition

                                                  interface ProtobufTypeDefinition {}

                                                    property fileDescriptorProtos

                                                    fileDescriptorProtos: Buffer[];

                                                      property format

                                                      format: string;

                                                        property type

                                                        type: object;

                                                          interface Serialize

                                                          interface Serialize<T> {}

                                                            call signature

                                                            (value: T): Buffer;

                                                              interface ServiceDefinition

                                                              interface ServiceDefinition {}

                                                                index signature

                                                                [index: string]: MethodDefinition<object, object>;

                                                                  Type Aliases

                                                                  type AnyDefinition

                                                                  type AnyDefinition = ServiceDefinition | MessageTypeDefinition | EnumTypeDefinition;

                                                                    type Options

                                                                    type Options = Protobuf.IParseOptions &
                                                                    Protobuf.IConversionOptions & {
                                                                    includeDirs?: string[];

                                                                      Package Files (2)

                                                                      Dependencies (4)

                                                                      Dev Dependencies (9)

                                                                      Peer Dependencies (0)

                                                                      No peer dependencies.


                                                                      To add a badge like this onejsDocs.io badgeto your package's README, use the codes available below.

                                                                      You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/@grpc/proto-loader.

                                                                      • Markdown
                                                                      • HTML
                                                                        <a href="https://www.jsdocs.io/package/@grpc/proto-loader"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>