Skip to content

Commit

Permalink
Be nice to AMD, allow reconfiguration of Reader/Writer interface
Browse files Browse the repository at this point in the history
  • Loading branch information
dcodeIO committed Dec 3, 2016
1 parent 4885b82 commit 0ae6675
Show file tree
Hide file tree
Showing 10 changed files with 254 additions and 126 deletions.
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ protobuf.js [![travis][travis-image]][travis-url] [![npm][npm-image]][npm-url] [

Features
--------
* Rapid [runtime code generation](#performance)
* Lightning fast through [runtime code generation](#performance)
* Exhaustive [browser support](#compatibility)
* Managed [TypeScript support](#usage-with-typescript)
* Elaborate [documentation](#documentation)
* Elaborate [API documentation](#documentation)
* Convenient [CLI utilities](#command-line)
* Seamless [browserify integration](#browserify-integration)

Expand Down Expand Up @@ -294,13 +294,15 @@ The `pbjs` command line utility can be used to bundle and translate between .pro
```
Consolidates imports and converts between file formats.
-t, --target Specifies the target format. [json, proto2, proto3]
-t, --target Specifies the target format. [json, proto2, proto3, static]
Also accepts a path to require a custom target.
-p, --path Adds a directory to the include path.
-o, --out Saves to a file instead of writing to stdout.
-w, --wrap Specifies an alternative wrapper for the static target.
usage: pbjs [options] file1.proto file2.json ...
```

Expand Down Expand Up @@ -356,7 +358,7 @@ $> npm run types

### Browserify integration

protobuf.js integrates seamlessly into your browserify build-process. There are a few optional tweaks, though:
protobuf.js integrates nicely into your browserify build-process. There are a few possible tweaks, though:

* If performance is a concern or IE8 support is required, you should make sure to exclude the browserified `buffer` module and let protobuf.js do its thing with Uint8Array/Array instead.
* If you do not need int64 support, you can exclude the `long` module.
Expand Down
169 changes: 111 additions & 58 deletions dist/protobuf.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/protobuf.js.map

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions dist/protobuf.min.js

Large diffs are not rendered by default.

Binary file modified dist/protobuf.min.js.gz
Binary file not shown.
2 changes: 1 addition & 1 deletion dist/protobuf.min.js.map

Large diffs are not rendered by default.

13 changes: 13 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,16 @@ protobuf.inherits = require("./inherits");
protobuf.types = require("./types");
protobuf.common = require("./common");
protobuf.util = util;

// Be nice to AMD
/* eslint-disable no-undef */
if (typeof define === 'function' && define.amd)
define(["long"], function(Long) {
if (Long) {
protobuf.util.Long = Long;
protobuf.Reader.configure();
protobuf.Writer.configure();
}
return protobuf;
});
/* eslint-enable no-undef */
Loading

0 comments on commit 0ae6675

Please sign in to comment.