Permalink
Browse files

Added Message#asJSON option for bytes conversion

  • Loading branch information...
dcodeIO committed Dec 12, 2016
1 parent ce41d0e commit 52cd8b5a891ec8e11611127c8cfa6b3a91ff78e3

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.

Large diffs are not rendered by default.

Oops, something went wrong.

Large diffs are not rendered by default.

Oops, something went wrong.
BIN +46 Bytes (100%) dist/protobuf.min.js.gz
Binary file not shown.

Large diffs are not rendered by default.

Oops, something went wrong.
@@ -50,6 +50,8 @@
"long": "^3.2.0"
},
"devDependencies": {
"@types/long": "^3.0.31",
"@types/node": "0.0.3",
"benchmark": "^2.1.2",
"browserify": "^13.1.1",
"bundle-collapser": "^1.2.1",
@@ -69,7 +71,7 @@
"tap-spec": "^4.1.1",
"tape": "^4.6.3",
"tsd-jsdoc": "dcodeIO/tsd-jsdoc",
"typescript": "^2.2.0-dev.20161202",
"typescript": "^2.2.0-dev.20161212",
"vinyl-buffer": "^1.0.0",
"vinyl-fs": "^2.4.4",
"vinyl-source-stream": "^1.1.0",

This file was deleted.

Oops, something went wrong.
@@ -266,7 +266,11 @@ FieldPrototype.jsonConvert = function(value, options) {
? typeof value === "number"
? value
: util.Long.fromValue(value).toNumber()
: util.Long.fromValue(value, this.type.charAt(0) === "u").toString();
: util.Long.fromValue(value, this.type.charAt(0) === "u").toString()
else if (options.bytes && this.type === "bytes")
return options.bytes === Array
? Array.prototype.slice.call(value)
: util.base64.encode(value, 0, value.length);
}
return value;
};
@@ -33,6 +33,9 @@ var MessagePrototype = Message.prototype;
* @param {*} [options.enum=Number] Enum value conversion type.
* Valid values are `String` and `Number` (the global types).
* Defaults to the numeric ids.
* @param {*} [options.bytes] Bytes value conversion type.
* Valid values are `Array` and `String` (the global types).
* Defaults to return the underlying buffer type.
* @param {boolean} [options.defaults=false] Also sets default values on the resulting object
* @returns {Object.<string,*>} JSON object
*/
@@ -1,6 +1,6 @@
/*
* protobuf.js v6.1.0 TypeScript definitions
* Generated Mon, 12 Dec 2016 22:50:39 UTC
* Generated Mon, 12 Dec 2016 23:18:49 UTC
*/
declare module "protobufjs" {
@@ -508,6 +508,9 @@ declare module "protobufjs" {
* @param {*} [options.enum=Number] Enum value conversion type.
* Valid values are `String` and `Number` (the global types).
* Defaults to the numeric ids.
* @param {*} [options.bytes] Bytes value conversion type.
* Valid values are `Array` and `String` (the global types).
* Defaults to return the underlying buffer type.
* @param {boolean} [options.defaults=false] Also sets default values on the resulting object
* @returns {Object.<string,*>} JSON object
*/

0 comments on commit 52cd8b5

Please sign in to comment.