# grpc-alt-proto-loader

> gRPC utility library for loading .proto files

Latest version **0.5.0** (published 2018-07-30) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install grpc-alt-proto-loader
pnpm add grpc-alt-proto-loader
yarn add grpc-alt-proto-loader
bun add grpc-alt-proto-loader
```

## Health

**Score 40/100 (D)** — status: abandoned.

Positive: has types; no vulnerabilities; high maintenance score; high quality score.

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 0.5.0 |
| Published | 2018-07-30 |
| First published | 2018-07-20 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | bundled |
| Module format | CommonJS |
| Node | >=6 |
| Dependencies | 4 |
| Unpacked size | 23.8 KB |
| Known vulnerabilities | 0 (+11 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 4841 |
| Author | Google Inc. |
| Maintainers | dvisz-inf |

## Links

- npm: https://www.npmjs.com/package/grpc-alt-proto-loader
- Repository: https://github.com/grpc/grpc-node
- Homepage: https://grpc.io/
- Issues: https://github.com/grpc/grpc-node/issues
- npm.io page: https://npm.io/package/grpc-alt-proto-loader

## Dependencies (4)

- [lodash](https://npm.io/package/lodash.md) ^4.17.5
- [protobufjs](https://npm.io/package/protobufjs.md) 6.8.6
- [@types/node](https://npm.io/package/@types/node.md) ^9.4.6
- [@types/lodash](https://npm.io/package/@types/lodash.md) ^4.14.104

## Recent versions

- 0.5.0 (latest) — 2018-07-30
- 0.4.1 — 2018-07-20
- 0.4.0 — 2018-07-20

## README

# gRPC Protobuf Loader

A utility package for loading `.proto` files for use with gRPC, using the latest Protobuf.js package.

## Installation

```sh
npm install @grpc/proto-loader
```

## Usage

```js
const protoLoader = require('@grpc/proto-loader');
const grpcLibrary = require('grpc');
// OR
const grpcLibrary = require('@grpc/grpc-js');

protoLoader.load(protoFileName, options).then(packageDefinition => {
  const packageObject = grpcLibrary.loadPackageDefinition(packageDefinition);
});
// OR
const packageDefinition = protoLoader.loadSync(protoFileName, options);
const packageObject = grpcLibrary.loadPackageDefinition(packageDefinition);
```

The options parameter is an object that can have the following optional properties:

| Field name | Valid values | Description
|------------|--------------|------------
| `keepCase` | `true` or `false` | Preserve field names. The default is to change them to camel case.
| `longs` | `String` or `Number` | The type to use to represent `long` values. Defaults to a `Long` object type.
| `enums` | `String` | The type to use to represent `enum` values. Defaults to the numeric value.
| `bytes` | `Array` or `String` | The type to use to represent `bytes` values. Defaults to `Buffer`.
| `defaults` | `true` or `false` | Set default values on output objects. Defaults to `false`.
| `arrays` | `true` or `false` | Set empty arrays for missing array values even if `defaults` is `false` Defaults to `false`.
| `objects` | `true` or `false` | Set empty objects for missing object values even if `defaults` is `false` Defaults to `false`.
| `oneofs` | `true` or `false` | Set virtual oneof properties to the present field's name. Defaults to `false`.
| `includeDirs` | An array of strings | A list of search paths for imported `.proto` files.

The following options object closely approximates the existing behavior of `grpc.load`:

```js
const options = {
  keepCase: true,
  longs: String,
  enums: String,
  defaults: true,
  oneofs: true
}
```

---
_Source: https://npm.io/package/grpc-alt-proto-loader · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
